/* ============ DESIGN TOKENS ============ */
:root {
    --bg: #08080c;
    --bg-elevated: #131319;
    --surface: rgba(255, 255, 255, 0.035);
    --surface-hover: rgba(255, 255, 255, 0.06);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.16);
    --sidebar-bg: #0c0c12;

    --text: #f4f4f6;
    --text-secondary: #a1a1ae;
    --text-muted: #6b6b78;

    --accent: #6366f1;
    --accent-2: #8b5cf6;
    --accent-hover: #818cf8;
    --accent-soft: rgba(99, 102, 241, 0.14);
    --cyan: #22d3ee;

    --success: #22c55e;
    --success-text: #4ade80;
    --success-soft: rgba(34, 197, 94, 0.14);

    --danger: #f43f5e;
    --danger-text: #fb7185;
    --danger-soft: rgba(244, 63, 94, 0.14);

    --warning: #f59e0b;
    --warning-text: #fbbf24;
    --warning-soft: rgba(245, 158, 11, 0.14);

    --radius-lg: 20px;
    --radius: 14px;
    --radius-sm: 10px;

    --shadow-lg: 0 24px 48px rgba(0, 0, 0, 0.55);
    --shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
}

html, body {
    background: var(--bg);
}

body {
    color: var(--text);
    min-height: 100vh;
    background-image:
        radial-gradient(at 15% 0%, rgba(99, 102, 241, 0.16) 0px, transparent 55%),
        radial-gradient(at 85% 100%, rgba(34, 211, 238, 0.10) 0px, transparent 55%);
    background-attachment: fixed;
}

a { color: inherit; }

/* ============ APP SHELL / SIDEBAR ============ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.nav-toggle-checkbox { display: none; }

.topbar {
    display: none;
}

.sidebar {
    width: 264px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 18px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 8px 26px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.brand-title {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.25;
    letter-spacing: 0.2px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 16px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.15s ease;
    position: relative;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 2;
}

.nav-item:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.nav-item.active {
    background: var(--accent-soft);
    color: #c7d2fe;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -18px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: linear-gradient(180deg, var(--accent), var(--accent-2));
    border-radius: 0 4px 4px 0;
}

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding-top: 16px;
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 8px;
}

.user-avatar-sm {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

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

.logout-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--danger-text);
    font-size: 13px;
    font-weight: 600;
    background: var(--danger-soft);
    border: 1px solid rgba(244, 63, 94, 0.2);
    transition: all 0.15s ease;
}

.logout-btn:hover {
    background: var(--danger);
    color: #fff;
}

.logout-btn svg { width: 15px; height: 15px; }

.sidebar-overlay {
    display: none;
}

/* ============ MAIN CONTENT ============ */
.main {
    flex: 1;
    min-width: 0;
    padding: 40px 44px 60px;
}

.main-inner {
    max-width: 1180px;
    margin: 0 auto;
}

.main-inner.narrow {
    max-width: 560px;
}

.main-inner.medium {
    max-width: 820px;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
}

.page-header .header-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #a5b4fc;
    flex-shrink: 0;
}

.page-header .header-icon svg { width: 22px; height: 22px; }

.page-title {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.page-subtitle {
    font-size: 13.5px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.page-header.center {
    flex-direction: column;
    text-align: center;
    align-items: center;
}

/* ============ CARDS / SURFACES ============ */
.card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 24px 26px;
}

.card-form {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
}

.card-form > label {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

/* ============ STAT CARDS (dashboard) ============ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -30px;
    right: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--stat-glow, rgba(99,102,241,0.18));
    filter: blur(20px);
}

.stat-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--stat-soft, var(--accent-soft));
    color: var(--stat-color, #a5b4fc);
}

.stat-icon svg { width: 18px; height: 18px; }

.stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1;
}

.stat-label {
    font-size: 12.5px;
    color: var(--text-secondary);
    margin-top: 6px;
    font-weight: 500;
}

/* ============ LISTS / GRID ITEMS ============ */
.lista {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-item {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: all 0.18s ease;
}

.card-item:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.info-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.info-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.card {
    /* movement/event cards (em_uso, historico) */
}

.event-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    transition: all 0.2s ease;
}

.event-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 14px;
}

.motorista-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.motorista {
    font-size: 15.5px;
    font-weight: 600;
    color: var(--text);
}

.veiculo {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.veiculo svg {
    width: 14px;
    height: 14px;
    stroke-width: 2;
    color: var(--text-muted);
}

.horarios {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 18px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.horario-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.horario-item svg {
    width: 15px;
    height: 15px;
    color: var(--cyan);
}

.registrado-por {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
}

.badge-pulse {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
}

.badge-em-uso, .badge-warning {
    background: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-devolvido, .badge-success {
    background: var(--success-soft);
    color: var(--success-text);
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.badge-admin {
    background: var(--warning-soft);
    color: var(--warning-text);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

.badge-visualizador {
    background: var(--accent-soft);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.25);
}

/* ============ FORMS ============ */
.form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 7px;
    flex: 1;
    min-width: 150px;
}

label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input, select {
    width: 100%;
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: all 0.15s ease;
}

input::placeholder { color: var(--text-muted); }

input:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: rgba(255, 255, 255, 0.05);
}

select { cursor: pointer; appearance: none; -webkit-appearance: none; }
select option { background: #16161d; color: var(--text); }

.select-wrapper { position: relative; }

.select-arrow {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(99, 102, 241, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-add {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.3);
}

.btn-add:hover {
    filter: brightness(1.1);
}

.btn-edit {
    background: var(--accent-soft);
    border: 1px solid rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-edit:hover { background: var(--accent); color: #fff; }

.btn-delete {
    background: var(--danger-soft);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--danger-text);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-delete:hover { background: var(--danger); color: #fff; }

.card-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============ ALERTS ============ */
.alert {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.alert svg { width: 19px; height: 19px; flex-shrink: 0; }

.alert-sucesso {
    background: var(--success-soft);
    border: 1px solid rgba(34, 197, 94, 0.25);
    color: var(--success-text);
}

.alert-erro {
    background: var(--danger-soft);
    border: 1px solid rgba(244, 63, 94, 0.25);
    color: var(--danger-text);
}

/* ============ EMPTY STATE ============ */
.vazio {
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 44px 20px;
    color: var(--text-secondary);
}

.vazio-icon {
    width: 38px;
    height: 38px;
    margin: 0 auto 12px;
    color: var(--text-muted);
}

/* ============ QUICK ACTIONS GRID (dashboard) ============ */
.actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

a.action-card {
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-decoration: none;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

a.action-card:hover {
    border-color: var(--accent);
    transform: translateY(-3px);
    box-shadow: 0 16px 32px rgba(99, 102, 241, 0.18);
}

.action-icon {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: #a5b4fc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-icon svg { width: 20px; height: 20px; }

.action-title {
    font-size: 14.5px;
    font-weight: 700;
}

.action-arrow {
    margin-left: auto;
    color: var(--text-muted);
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

a.action-card:hover .action-arrow {
    transform: translateX(4px);
    color: var(--accent);
}

.action-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ============ LOGIN / STANDALONE PAGES ============ */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
}

/* ============ TABS (cadastro.php) ============ */
.tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    padding: 4px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 22px;
}

.tab-btn {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.18s ease;
}

.tab-btn.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-2));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.tab-content { display: none; }
.tab-content.active { display: flex; flex-direction: column; gap: 16px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 60;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-lg);
    }

    .nav-toggle-checkbox:checked ~ .app-shell .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 50;
    }

    .nav-toggle-checkbox:checked ~ .sidebar-overlay {
        display: block;
    }

    .topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        padding: 14px 18px;
        border-bottom: 1px solid var(--border);
        background: var(--sidebar-bg);
        position: sticky;
        top: 0;
        z-index: 40;
    }

    .hamburger {
        width: 38px;
        height: 38px;
        border-radius: var(--radius-sm);
        background: var(--surface);
        border: 1px solid var(--border);
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        flex-shrink: 0;
    }

    .hamburger svg { width: 19px; height: 19px; }

    .topbar-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 14px;
        font-weight: 700;
    }

    .main {
        padding: 24px 18px 40px;
    }

    .page-header {
        flex-wrap: wrap;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 560px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .form-row { flex-direction: column; }
    .card-actions { width: 100%; }
    .btn-edit, .btn-delete { flex: 1; justify-content: center; }
    .card-item { flex-wrap: wrap; }
    .card-form .form-row-full { flex-direction: column; }
}
