/* ─── Variables ──────────────────────────────────────────────────── */
:root {
    --sidebar-width: 240px;
    --sidebar-bg: #1a1d23;
    --sidebar-accent: #3b82f6;
    --topbar-height: 56px;
    --text-muted-light: #6b7280;
}

html, body {
    height: 100%;
    margin: 0;
    font-size: 14px;
}

/* ─── App Layout ─────────────────────────────────────────────────── */
.app-wrapper {
    display: flex;
    min-height: 100vh;
    background: #f0f2f5;
}

/* ─── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #c9d1d9;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    padding: 20px 20px 16px;
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.avatar {
    width: 36px; height: 36px;
    background: var(--sidebar-accent);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
}

.user-info {
    overflow: hidden;
    display: flex; flex-direction: column;
}

.user-info small { color: var(--text-muted-light); font-size: 0.7rem; line-height: 1; }
.user-info span { font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-nav {
    flex: 1;
    padding: 10px 0;
    display: flex;
    flex-direction: column;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #8b949e;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #e6edf3;
}

.sidebar-link.active {
    background: rgba(59,130,246,0.15);
    color: #60a5fa;
    border-left-color: var(--sidebar-accent);
    font-weight: 600;
}

.sidebar-footer {
    padding: 12px 0;
    border-top: 1px solid rgba(255,255,255,0.06);
}

/* ─── Main Content ───────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ─── Topbar ─────────────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    position: sticky; top: 0; z-index: 99;
}

.sidebar-toggle { color: #6b7280 !important; }
.sidebar-toggle:hover { color: #111 !important; }

/* ─── Stats Cards ────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.78rem; color: var(--text-muted-light); margin-top: 3px; }

/* ─── Tables ─────────────────────────────────────────────────────── */
.table th { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: #6b7280; }
.table td { vertical-align: middle; font-size: 0.875rem; }

/* ─── Login ──────────────────────────────────────────────────────── */
.login-body {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a1d23 0%, #23293a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    margin: 0;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 36px 32px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
}

.letter-spacing-3 { letter-spacing: 0.3em; }

/* ─── Viatura Status Dot ─────────────────────────────────────────── */
.viatura-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #6c757d;
}
.viatura-dot.estado-1 { background: #198754; box-shadow: 0 0 0 3px rgba(25,135,84,0.2); }
.viatura-dot.estado-2 { background: #fd7e14; box-shadow: 0 0 0 3px rgba(253,126,20,0.2); }

/* ─── Legend Dot ─────────────────────────────────────────────────── */
.legend-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

/* ─── Leaflet Map Marker ─────────────────────────────────────────── */
.viatura-marker {
    position: relative;
}
.viatura-marker-pin {
    width: 26px; height: 26px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    background: var(--mc, #6c757d);
    border: 2px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.35);
}
.viatura-marker-label {
    position: absolute;
    top: -22px; left: 50%;
    transform: translateX(-50%);
    background: rgba(15,15,15,0.82);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    letter-spacing: 0.02em;
}

/* ─── Detail Hero ────────────────────────────────────────────────── */
.detail-hero {
    background: linear-gradient(135deg, #1a1d23 0%, #2d3748 100%);
    border-radius: 12px;
    padding: 26px 28px 22px;
    color: #fff;
    position: relative;
    overflow: hidden;
}
.detail-hero::before {
    content: '';
    position: absolute;
    top: -30px; right: -30px;
    width: 180px; height: 180px;
    border-radius: 50%;
    background: rgba(59,130,246,0.1);
    pointer-events: none;
}

/* ─── Patient Avatar ─────────────────────────────────────────────── */
.patient-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.1rem;
    flex-shrink: 0;
}

/* ─── Spin Animation ─────────────────────────────────────────────── */
.spin { animation: spin-anim 0.8s linear infinite; }
@keyframes spin-anim {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ─── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
}
