/* Helfer-hilft — Stylesheet */

:root {
    --primary: #16a34a;
    --primary-dark: #15803d;
    --primary-light: #bbf7d0;
    --danger: #dc2626;
    --danger-light: #fecaca;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f0fdf4;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #d1d5db;
    --border-light: #e5e7eb;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: white;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.nav-brand a {
    color: white;
    text-decoration: none;
    font-size: 1.25rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: 2rem;
}

.nav-links a {
    color: rgba(255,255,255,0.85);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.nav-links a:hover { background: rgba(255,255,255,0.15); color: white; }
.nav-links a.active { background: rgba(255,255,255,0.2); color: white; }
.nav-links .nav-logout { margin-left: auto; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    margin-left: auto;
}

/* Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Flash Messages */
.flash-messages { margin-bottom: 1rem; }
.flash {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.flash-success { background: var(--primary-light); color: var(--primary-dark); }
.flash-error { background: var(--danger-light); color: var(--danger); }
.flash-warning { background: #fef3c7; color: #92400e; }

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header .count {
    font-weight: 400;
    color: var(--text-muted);
    font-size: 1rem;
}

.page-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: white;
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn:hover { background: #f3f4f6; }

.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger { background: white; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }

.btn-success { background: white; color: var(--success); border-color: var(--success); }
.btn-success:hover { background: var(--success); color: white; }

.btn-secondary { background: white; color: var(--text-muted); }

.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn-full { width: 100%; justify-content: center; }

/* Tables */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.data-table th,
.data-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.025em;
    cursor: pointer;
    user-select: none;
}

.data-table th:hover { background: #f3f4f6; }

.data-table tbody tr:hover { background: #f0fdf4; }
.data-table tbody tr.row-inactive { opacity: 0.5; }

.data-table .actions {
    display: flex;
    gap: 0.375rem;
    white-space: nowrap;
}

.inline-form { display: inline; }

/* Stats Grid (Dashboard) */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    text-decoration: none;
    color: var(--text);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Info Box */
.info-box {
    background: var(--card-bg);
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.info-box h3 { margin-bottom: 0.5rem; }

/* Forms */
.form-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    max-width: 700px;
}

.form-group {
    margin-bottom: 1rem;
    flex: 1;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.375rem;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.form-group input[type="color"] {
    width: 60px;
    height: 36px;
    padding: 2px;
    cursor: pointer;
}

.form-group-small { max-width: 140px; flex: 0 0 140px; }

.form-row {
    display: flex;
    gap: 1rem;
}

.form-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
}

hr {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 1.5rem 0;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-success { background: var(--primary-light); color: var(--primary-dark); }
.badge-muted { background: #f3f4f6; color: var(--text-muted); }

/* Color Dot */
.color-dot {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    vertical-align: middle;
    border: 2px solid rgba(0,0,0,0.1);
}

/* Search Input */
.search-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    min-width: 200px;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* Inline Add Form (Leistungsarten) */
.inline-add-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.inline-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}

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

.inline-input-wide { flex: 1; min-width: 200px; }

/* Editable cells */
.editable {
    cursor: pointer;
    padding: 0.125rem 0.25rem;
    border-radius: 4px;
    min-width: 40px;
    display: inline-block;
}
.editable:hover { background: #f3f4f6; }

.editable-input {
    border: 1px solid var(--primary);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    font-size: inherit;
    font-family: inherit;
    outline: none;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Login Page */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
}

.login-card {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 380px;
}

.login-card h1 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 0.25rem;
}

.login-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Checkbox Group (Berechtigungen, Zuweisungen) */
.checkbox-group,
.zuweisungen-container {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
    max-height: 300px;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 0.25rem 0;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    flex-shrink: 0;
}

/* Upload Card (Dateiablage) */
.upload-card {
    background: var(--card-bg);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.upload-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.upload-input {
    flex: 0 0 auto;
}

.upload-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}

.upload-notiz {
    flex: 1;
    min-width: 150px;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}

.upload-notiz:focus,
.upload-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.text-muted { color: var(--text-muted); font-size: 0.85rem; }

/* Fullwidth Container (GPS-Seiten) */
.container-fullwidth {
    max-width: none;
    padding: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* GPS Dashboard Layout */
.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    min-height: calc(100vh - 56px);
}

.sidebar {
    width: 320px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.sidebar-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.sidebar-header h2 { font-size: 1rem; }
.sidebar-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--border);
    margin-top: auto;
    font-size: 0.8rem;
}

.map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* Device List */
.device-list { padding: 0.5rem; flex: 1; overflow-y: auto; }

.device-item {
    padding: 0.6rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    margin-bottom: 0.25rem;
    transition: background 0.15s;
}
.device-item:hover { background: var(--bg); }
.device-item.inactive { opacity: 0.5; }

.device-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.device-info { flex: 1; min-width: 0; }
.device-name { font-weight: 600; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-meta { font-size: 0.75rem; color: var(--text-muted); }

.device-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s;
}
.device-item:hover .device-actions { opacity: 1; }

.device-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.device-btn:hover { background: var(--bg); color: var(--text); }

/* Connection Status */
.connection-status { display: flex; align-items: center; gap: 0.4rem; }
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--danger); }
.status-dot.connecting { background: var(--warning); }

/* Route-Slots (Routenvergleich) */
.route-slots { padding: 0.5rem; flex: 1; overflow-y: auto; }

.route-slot {
    background: var(--bg);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}
.route-slot-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.6rem;
}
.route-slot-body {
    padding: 0 0.6rem 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.route-slot-body input[type="date"] {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}
.route-slot-body input[type="date"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.route-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.route-slot select {
    flex: 1;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
    min-width: 0;
}
.route-slot select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0 0.2rem;
    line-height: 1;
}
.btn-icon:hover { color: var(--danger); }

.route-actions {
    padding: 0.5rem;
    display: flex;
    gap: 0.4rem;
}
.route-actions .btn { flex: 1; font-size: 0.8rem; padding: 0.4rem 0.5rem; }

.btn-outline-danger {
    background: none;
    color: var(--danger);
    border: 1px solid var(--danger);
}
.btn-outline-danger:hover { background: #fef2f2; }

/* Vergleichstabelle */
.compare-stats { padding: 0.75rem; border-top: 1px solid var(--border); }
.compare-stats h3 { font-size: 0.9rem; margin-bottom: 0.5rem; }
.compare-table {
    width: 100%;
    font-size: 0.8rem;
    border-collapse: collapse;
}
.compare-table th, .compare-table td {
    padding: 0.3rem 0.4rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.compare-table th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; }
.compare-table .color-cell { width: 20px; }

/* Modal (GPS Admin) */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}
.modal {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 420px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-body { padding: 1rem; }
.modal-body hr { margin: 1rem 0; border: none; border-top: 1px solid var(--border); }
.modal-body h4 { margin-bottom: 0.5rem; font-size: 0.95rem; }
.modal-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
}

/* Leaflet Popup */
.leaflet-popup-content { font-size: 0.85rem; line-height: 1.4; }
.leaflet-popup-content strong { display: block; margin-bottom: 0.25rem; }

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--primary);
        flex-direction: column;
        padding: 0.5rem;
        box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .form-row { flex-direction: column; }
    .form-group-small { max-width: none; flex: 1; }
    .container { padding: 1rem; }

    .data-table th,
    .data-table td { padding: 0.5rem; font-size: 0.85rem; }

    .sidebar { width: 100%; max-height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
    .dashboard-layout { flex-direction: column; }
    .device-actions { opacity: 1; }

    .upload-row { flex-direction: column; }
    .upload-notiz { min-width: auto; }
}

/* Kalender + Kontakte */
.subtitle { color: var(--text-muted); margin-bottom: 1rem; font-size: 1.1rem; }
.row-highlight { background: var(--primary-light) !important; }
.detail-row { padding: 0.5rem 0; border-bottom: 1px solid var(--border-light); }
.detail-row:last-of-type { border-bottom: none; }
.detail-row strong { display: inline-block; min-width: 120px; }
