/* ============================================
   DeltaMEC - Design System
   ============================================ */

:root {
    --sidebar-width: 230px;
    --sidebar-bg: #0f1117;
    --sidebar-hover: #1c1f2b;
    --sidebar-active: #6366f1;
    --navbar-height: 50px;
    --body-bg: #f4f6f9;
    --card-bg: #ffffff;
    --card-shadow: 0 1px 4px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0,0,0,0.03);
    --card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --accent: #6366f1;
    --accent-light: #eef2ff;
    --success: #10b981;
    --success-light: #ecfdf5;
    --warning: #f59e0b;
    --warning-light: #fffbeb;
    --danger: #ef4444;
    --danger-light: #fef2f2;
    --font-size-base: 0.8125rem;
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: var(--font-size-base);
    background-color: var(--body-bg);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   LOGIN PAGE
   ============================================ */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f1117 0%, #1e1b4b 50%, #312e81 100%);
    padding: 1rem;
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-logo i {
    font-size: 2.2rem;
    color: var(--accent);
}

.login-logo h1 {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 0.35rem;
    letter-spacing: -0.02em;
}

.login-logo p {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.login-card .form-control {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    font-size: 0.8125rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-card .btn-primary {
    padding: 0.55rem;
    border-radius: var(--radius);
    font-weight: 700;
    font-size: 0.8125rem;
    background: var(--accent);
    border: none;
    letter-spacing: 0.01em;
    transition: background 0.2s, transform 0.15s;
}

.login-card .btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

.login-error {
    display: none;
    background: var(--danger-light);
    color: var(--danger);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    margin-bottom: 0.75rem;
    border: 1px solid #fecaca;
    font-weight: 500;
}

/* ============================================
   APP LAYOUT
   ============================================ */

.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform 0.3s ease;
    border-right: 1px solid rgba(255, 255, 255, 0.04);
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
    color: #fff;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    letter-spacing: -0.02em;
}

.sidebar-brand i {
    color: var(--accent);
    font-size: 1.1rem;
}

.sidebar-brand:hover {
    color: #fff;
}

#sidebarClose {
    color: #fff;
    padding: 0;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    color: #8b92a5;
    padding: 0.42rem 1rem;
    font-size: 0.76rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    transition: all 0.15s;
    border-left: 2px solid transparent;
    margin: 1px 0;
}

.sidebar-nav .nav-link:hover {
    color: #e2e4eb;
    background: var(--sidebar-hover);
}

.sidebar-nav .nav-link.active {
    color: #fff;
    background: var(--sidebar-hover);
    border-left-color: var(--accent);
    font-weight: 600;
}

.sidebar-nav .nav-link.active i {
    color: var(--accent);
}

.sidebar-nav .nav-link i {
    font-size: 0.9rem;
    width: 18px;
    text-align: center;
    opacity: 0.7;
}

.sidebar-nav .nav-link.active i {
    opacity: 1;
}

.sidebar-nav .nav-link.disabled {
    opacity: 0.35;
    pointer-events: none;
}

.sidebar-nav .nav-link .badge {
    font-size: 0.55rem;
    padding: 0.15rem 0.35rem;
    font-weight: 600;
}

.nav-section {
    padding: 1rem 1rem 0.3rem;
    font-size: 0.58rem;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: #4b5167;
    font-weight: 700;
    list-style: none;
}

/* ============================================
   TOP NAVBAR
   ============================================ */

.top-navbar {
    height: var(--navbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.page-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.tenant-name {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

.user-dropdown {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.76rem;
    font-weight: 500;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

.content-area {
    padding: 1.15rem 1.25rem;
}

/* ============================================
   FORMS (global)
   ============================================ */

.form-control, .form-select {
    font-size: 0.8125rem;
    padding: 0.4rem 0.65rem;
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.form-control-lg {
    font-size: 0.85rem;
    padding: 0.5rem 0.85rem;
}

.form-label {
    font-size: 0.72rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.input-group-text {
    font-size: 0.8125rem;
    border: 1.5px solid var(--border-color);
    background: #f9fafb;
    color: var(--text-muted);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
    font-size: 0.76rem;
    font-weight: 600;
    padding: 0.38rem 0.85rem;
    border-radius: var(--radius);
    transition: all 0.15s;
    letter-spacing: 0.01em;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
}

.btn-primary:hover {
    background: #4f46e5;
    border-color: #4f46e5;
}

.btn-sm {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
}

.btn-action {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.72rem;
    transition: all 0.15s;
}

.btn-action:hover {
    transform: scale(1.08);
}

/* ============================================
   CARDS & KPIs
   ============================================ */

.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 0.9rem 1rem;
    box-shadow: var(--card-shadow);
    border: none;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: transparent;
    transition: background 0.2s;
}

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-hover-shadow);
}

.kpi-card:hover::before {
    background: var(--accent);
}

.kpi-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.kpi-icon.blue { background: #eef2ff; color: #6366f1; }
.kpi-icon.green { background: #ecfdf5; color: #10b981; }
.kpi-icon.yellow { background: #fffbeb; color: #f59e0b; }
.kpi-icon.red { background: #fef2f2; color: #ef4444; }
.kpi-icon.purple { background: #faf5ff; color: #a855f7; }

.kpi-value {
    font-size: 1.35rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.kpi-label {
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    margin-top: 2px;
}

/* ============================================
   TABLES
   ============================================ */

.table-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    border: none;
    padding: 1rem;
}

.table-card .table {
    margin-bottom: 0;
    font-size: 0.76rem;
}

.table thead th {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    font-weight: 700;
    border-bottom: 2px solid var(--border-color);
    padding: 0.55rem 0.5rem;
    white-space: nowrap;
}

.table td {
    padding: 0.5rem 0.5rem;
    vertical-align: middle;
    color: var(--text-primary);
    border-bottom: 1px solid #f3f4f6;
}

.table tbody tr {
    transition: background 0.1s;
}

.table tbody tr:hover {
    background: #f9fafb;
}

.table tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   BADGES
   ============================================ */

.badge-ativo {
    background: var(--success-light);
    color: var(--success);
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.65rem;
    letter-spacing: 0.02em;
}

.badge-inativo {
    background: var(--danger-light);
    color: var(--danger);
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 20px;
    font-size: 0.65rem;
    letter-spacing: 0.02em;
}

.badge {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ============================================
   DROPDOWN
   ============================================ */

.dropdown-menu {
    font-size: 0.76rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    border-radius: var(--radius);
    padding: 0.3rem;
}

.dropdown-item {
    font-size: 0.76rem;
    font-weight: 500;
    padding: 0.38rem 0.75rem;
    border-radius: 5px;
    transition: background 0.1s;
}

.dropdown-item:hover {
    background: #f3f4f6;
}

.dropdown-divider {
    margin: 0.2rem 0;
    border-color: var(--border-color);
}

/* ============================================
   MODAL
   ============================================ */

.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-bottom: 1px solid var(--border-color);
    padding: 0.85rem 1.15rem;
}

.modal-title {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.modal-body {
    padding: 1.15rem;
}

.modal-footer {
    border-top: 1px solid var(--border-color);
    padding: 0.65rem 1.15rem;
}

/* ============================================
   SEARCH BAR
   ============================================ */

#buscaRapida {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    font-weight: 500;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#buscaRapida:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.08);
}

#buscaRapida::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

#resultadoBusca {
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}

.busca-row:hover {
    background: #f3f4f6;
}

/* ============================================
   CHARTS
   ============================================ */

.kpi-card h6 {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 767.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .content-area {
        padding: 0.75rem;
    }

    .kpi-value {
        font-size: 1rem;
    }

    .kpi-card {
        padding: 0.75rem;
    }
}

/* ============================================
   OVERLAY (mobile sidebar)
   ============================================ */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
    display: block;
}

/* ============================================
   DATATABLES OVERRIDES
   ============================================ */

.dataTables_wrapper {
    font-size: 0.76rem;
}

.dataTables_wrapper .dataTables_filter input {
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    padding: 0.3rem 0.6rem;
    font-size: 0.76rem;
}

.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

.dataTables_wrapper .dataTables_length select {
    border-radius: var(--radius);
    border: 1.5px solid var(--border-color);
    font-size: 0.76rem;
}

.dataTables_wrapper .dataTables_info {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 500;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    font-size: 0.72rem !important;
    padding: 0.2rem 0.5rem !important;
    border-radius: 5px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--accent) !important;
    color: #fff !important;
    border-color: var(--accent) !important;
    font-weight: 700;
}

/* ============================================
   ALERTS & TOAST
   ============================================ */

.alert {
    font-size: 0.76rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-weight: 500;
}

.toast {
    border-radius: var(--radius);
}

.toast-body {
    font-size: 0.76rem;
    font-weight: 500;
}

/* ============================================
   LOADING SPINNER
   ============================================ */

.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 0.85rem;
    height: 0.85rem;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 0.75rem;
    top: 50%;
    margin-top: -0.425rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   TYPOGRAPHY HELPERS
   ============================================ */

h6 {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

p {
    font-size: 0.8125rem;
}

small, .small {
    font-size: 0.7rem;
}

strong {
    font-weight: 700;
}

/* ============================================
   SELECTION & SCROLLBAR
   ============================================ */

::selection {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* ============================================
   VEÍCULO CARDS (Detalhe do Cliente)
   ============================================ */

.veiculo-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 0.6rem 1rem;
    cursor: pointer;
    transition: all 0.15s;
    min-width: 140px;
    text-align: center;
    user-select: none;
}

.veiculo-card:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.veiculo-card.active {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.veiculo-card.active .veiculo-card-nome {
    color: rgba(255, 255, 255, 0.8);
}

.veiculo-card-placa {
    font-size: 0.9rem;
    font-weight: 800;
    letter-spacing: 1.5px;
    line-height: 1.2;
}

.veiculo-card-nome {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Veículo Detalhe Info */
.vd-info {
    background: #f9fafb;
    border-radius: var(--radius);
    padding: 0.55rem 0.75rem;
    height: 100%;
}

.vd-info-label {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.vd-info-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
}
