/* ASPI Borna GPS-Tracking */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --bg: #f8fafc;
    --sidebar-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --sidebar-width: 320px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Navbar */
.navbar {
    background: var(--primary);
    color: white;
    padding: 0 1rem;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 1000;
}
.nav-brand a { color: white; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.nav-links { display: flex; gap: 0.5rem; }
.nav-links a {
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    font-size: 0.9rem;
}
.nav-links a:hover, .nav-links a.active {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* Layout */
main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-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); }

/* History controls */
.history-controls { padding: 1rem; }
.history-stats { padding: 1rem; border-top: 1px solid var(--border); }
.stats-table { width: 100%; font-size: 0.85rem; }
.stats-table td { padding: 0.3rem 0; }
.stats-table td:last-child { text-align: right; font-weight: 600; }

/* Login */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 1rem;
}
.login-box {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 360px;
}
.login-box h1 { text-align: center; margin-bottom: 0.25rem; }
.login-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 1.5rem; }

/* Forms */
.form-group { margin-bottom: 0.75rem; }
.form-group label { display: block; margin-bottom: 0.25rem; font-size: 0.85rem; font-weight: 500; }
.form-group input, .form-group select {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.9rem;
}
.form-group input:focus, .form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.form-group input[type="color"] { padding: 0.2rem; height: 36px; }
.form-group input[type="checkbox"] { width: auto; margin-right: 0.4rem; }

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 500;
}
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: white; }
.btn-full { width: 100%; }

/* Alerts */
.alert { padding: 0.6rem 0.8rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.85rem; }
.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* Modal */
.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;
}

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

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

/* 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 2px rgba(37,99,235,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 2px rgba(37,99,235,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-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }
.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 td:first-child { font-weight: 500; }
.compare-table .color-cell { width: 20px; }

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