/* Sanierer-App — Mobile-First, helles Theme */
:root {
    --primary: #1976D2;
    --primary-dark: #1565C0;
    --success: #4CAF50;
    --danger: #E53935;
    --warning: #FF9800;
    --bg: #F5F5F5;
    --card: #FFFFFF;
    --text: #212121;
    --text-muted: #757575;
    --border: #E0E0E0;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Montserrat', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

/* ── Login ─────────────────────────────────────────────── */
.login-container {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, #1976D2, #0D47A1);
}

.login-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 40px 30px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow);
    text-align: center;
}

.login-card h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 4px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 28px;
}

.login-card input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
}

.login-card button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-top: 4px;
}

.login-card button:active { background: var(--primary-dark); }

/* ── App Header ────────────────────────────────────────── */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name { font-size: 13px; color: var(--text-muted); }

.btn-logout {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 18px;
    padding: 4px;
}

/* ── Suchleiste ────────────────────────────────────────── */
.search-bar {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
}

.search-bar input {
    flex: 1;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}

.search-bar input:focus { outline: none; border-color: var(--primary); }

.search-bar button,
#search-btn {
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

/* ── Standort-Bar ──────────────────────────────────────── */
.location-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 16px;
    background: #E3F2FD;
    font-size: 13px;
    color: var(--primary-dark);
}

#gps-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Karte ─────────────────────────────────────────────── */
#map {
    height: 50dvh;
    min-height: 250px;
    width: 100%;
    z-index: 1;
}

/* ── Ergebnis-Cards ────────────────────────────────────── */
.results-container {
    padding: 10px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.howto {
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.howto h4 { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 10px; }

.howto ul { list-style: none; padding: 0; }

.howto li {
    font-size: 14px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    line-height: 1.5;
}

.howto li:last-child { border-bottom: none; }

.result-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.1s;
}

.result-card:active { transform: scale(0.98); }

/* ── Install-Banner ────────────────────────────────────── */
.install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2500;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.2);
}

.install-banner.hidden { display: none; }

.btn-install {
    background: white;
    color: var(--primary);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn-dismiss {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.result-info h4 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 2px;
}

.result-info .result-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.result-distance {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}

.no-results {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Detail-Panel ──────────────────────────────────────── */
.detail-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 70dvh;
    background: var(--card);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
    z-index: 2000;
    overflow-y: auto;
    transition: transform 0.3s ease;
    transform: translateY(0);
}

.detail-panel.hidden { transform: translateY(100%); pointer-events: none; }

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px 8px;
    position: sticky;
    top: 0;
    background: var(--card);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.detail-header h2 { font-size: 18px; font-weight: 700; }

.detail-header button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 4px;
}

.detail-body { padding: 0 20px 24px; }

.detail-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }

.detail-label {
    font-weight: 600;
    min-width: 90px;
    color: var(--text-muted);
    font-size: 13px;
}

.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.btn-call, .btn-route {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-call { background: var(--success); color: white; }
.btn-route { background: var(--primary); color: white; }

.ap-section { margin-top: 12px; }
.ap-section h4 { font-size: 14px; margin-bottom: 8px; color: var(--primary); }

.ap-card {
    background: var(--bg);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 8px;
}

.ap-card .ap-name { font-weight: 600; font-size: 14px; }
.ap-card .ap-rolle { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ap-card a, .ap-link { color: var(--primary); text-decoration: none; font-size: 14px; display: inline-block; }
.ap-card .ap-notizen { font-size: 13px; color: var(--text-muted); margin-top: 4px; font-style: italic; }

.notizen-section { margin-top: 16px; padding-top: 12px; border-top: 2px solid var(--border); }
.notizen-section h4 { font-size: 14px; margin-bottom: 8px; color: var(--primary); }
.notizen-text {
    background: #FFFDE7;
    border-left: 3px solid var(--warning);
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

/* ── Admin Dashboard ───────────────────────────────────── */
.admin-container { max-width: 900px; margin: 0 auto; padding-bottom: 40px; }

.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding: 16px;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 0 16px;
}

.chart-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.chart-card h3 { font-size: 14px; margin-bottom: 12px; color: var(--text-muted); }

.admin-section { padding: 16px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.section-header h3 { font-size: 18px; font-weight: 600; }

.btn-primary {
    padding: 10px 18px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.btn-sm {
    padding: 6px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
}

.btn-sm:hover { background: var(--border); }

/* ── User-Tabelle ──────────────────────────────────────── */
.user-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.user-table th, .user-table td {
    padding: 12px 14px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}

.user-table th {
    background: var(--bg);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-muted);
}

.row-inactive { opacity: 0.5; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.badge-admin { background: #E3F2FD; color: var(--primary); }
.badge-sanierer { background: #E8F5E9; color: var(--success); }
.badge-aktiv { background: #E8F5E9; color: var(--success); }
.badge-inaktiv { background: #FFEBEE; color: var(--danger); }

/* ── Modal ─────────────────────────────────────────────── */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 20px;
}

.modal.hidden { display: none; }

.modal-content {
    background: var(--card);
    border-radius: var(--radius);
    padding: 24px;
    width: 100%;
    max-width: 420px;
    max-height: 80dvh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 { font-size: 18px; }

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-content label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 12px 0 4px;
}

.modal-content input,
.modal-content select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
}

.modal-content input:focus,
.modal-content select:focus {
    outline: none;
    border-color: var(--primary);
}

.modal-content .btn-primary { width: 100%; margin-top: 16px; padding: 12px; }

.log-list { max-height: 200px; overflow-y: auto; }

.log-entry {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.log-ip { color: var(--text-muted); font-size: 12px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 600px) {
    .charts-row { grid-template-columns: 1fr; }
    .user-table th:nth-child(4),
    .user-table td:nth-child(4),
    .user-table th:nth-child(5),
    .user-table td:nth-child(5) { display: none; }
}
