/* ===================================
   SCFV - Sistema de Controle de Fluxo de Viaturas
   CSS Global Modernizado (Clean Corporate)
   =================================== */

   :root {
    /* Paleta de Cores Moderna */
    --primary-color: #2c3e50;    /* Azul Escuro Profundo */
    --primary-light: #34495e;
    --secondary-color: #3498db;  /* Azul Vibrante */
    --secondary-hover: #2980b9;
    
    --accent-color: #e67e22;     /* Laranja para destaque */

    /* Cores de Estado */
    --success-color: #2ecc71;
    --success-bg: #d5f5e3;
    --danger-color: #e74c3c;
    --danger-bg: #fadbd8;
    --warning-color: #f1c40f;
    --warning-bg: #fcf3cf;
    --info-color: #3498db;
    --info-bg: #d6eaf8;

    /* Cores de Fundo e Texto */
    --bg-body: #f4f6f9;          /* Cinza muito claro, quase branco */
    --bg-white: #ffffff;
    --bg-panel: #ffffff;

    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #bdc3c7;
    --text-on-primary: #ffffff;

    /* Bordas e Sombras (Glass/Soft UI) */
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);

    /* Dimensões */
    --border-radius: 12px;
    --border-radius-sm: 6px;
    --header-height: 80px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: linear-gradient(to bottom, #e8eef3 0%, var(--bg-body) 200px);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ===================================
   Layout e Estrutura
   =================================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.container-fluid {
    width: 100%;
    padding: 20px;
}

/* Cabeçalho */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
    height: var(--header-height);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 3px solid var(--secondary-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 20px;
    max-width: 100%;
}

.brand {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 0;
}

.logo-icon {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 8px;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.logo-icon:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: brightness(1.1);
}

header .logo {
    font-size: 1.75rem;
    font-weight: 700;
    color: white;
    line-height: 1.2;
    margin: 0;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

header p {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.85);
    margin: 0;
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Informações do Usuário no Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.user-info:hover {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.user-details {
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-role {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    padding: 3px 10px;
    border-radius: 12px;
    display: inline-block;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.user-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--secondary-color), var(--secondary-hover));
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    transition: var(--transition);
}

.user-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

/* Skeleton Loading para User Info */
.skeleton-line {
    height: 12px;
    background-color: #e0e0e0;
    border-radius: 4px;
    margin-bottom: 4px;
    width: 100px;
    animation: pulse 1.5s infinite;
}

@keyframes pulse { 0% { opacity: 0.6; } 50% { opacity: 1; } 100% { opacity: 0.6; } }

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
}

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

.btn.loading {
    position: relative;
    color: transparent;
    pointer-events: none;
    cursor: not-allowed;
}

.btn.loading::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

/* Overlay de loading para modais */
.modal-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    border-radius: 8px;
}

.modal-loading-overlay .spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Menu Lateral (Sidebar) */
.sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    width: 260px;
    height: calc(100vh - var(--header-height));
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-light) 100%);
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    z-index: 90;
    transition: var(--transition);
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.sidebar nav {
    padding: 1.5rem 0;
}

.sidebar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0;
    margin: 0;
}

.sidebar li {
    position: relative;
}

.sidebar a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 1rem 1.5rem;
    transition: var(--transition);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 3px solid transparent;
}

.sidebar a i {
    font-size: 1.25rem;
    min-width: 24px;
}

.sidebar a:hover, .sidebar a.active {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--secondary-color);
}

/* Logout em destaque */
.logout-item {
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.5rem;
    margin-top: 1rem;
}

.logout-item a {
    color: #ff8a80;
}

.logout-item a:hover {
    background-color: rgba(231, 76, 60, 0.2);
    border-left-color: var(--danger-color);
}

/* Submenu */
.sidebar .has-submenu {
    position: relative;
}

.sidebar .submenu-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.sidebar .submenu-arrow {
    margin-left: auto;
    font-size: 1rem;
    transition: transform 0.3s ease;
}

.sidebar .has-submenu.submenu-open .submenu-arrow {
    transform: rotate(180deg);
}

.sidebar .submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background-color: rgba(0, 0, 0, 0.1);
}

.sidebar .has-submenu.submenu-open .submenu {
    max-height: 500px;
}

.sidebar .submenu li {
    margin: 0;
}

.sidebar .submenu a {
    padding: 0.75rem 1.5rem 0.75rem 3.5rem;
    font-size: 0.9rem;
    border-left: 3px solid transparent;
}

.sidebar .submenu a:hover,
.sidebar .submenu a.active {
    background-color: rgba(255, 255, 255, 0.15);
    border-left-color: var(--secondary-color);
}

/* Wrapper do conteúdo principal */
.main-wrapper {
    margin-left: 260px;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
}

/* Botão toggle (mobile) */
.sidebar-toggle {
    position: fixed;
    top: 90px;
    left: 15px;
    z-index: 95;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
}

.sidebar-toggle:hover {
    background-color: var(--secondary-hover);
    transform: scale(1.1);
}

.sidebar-toggle i {
    font-size: 1.5rem;
}

/* Overlay para mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 85;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Footer */
footer {
    text-align: center;
    padding: 40px 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 40px;
    border-top: 1px solid var(--border-color);
}

/* ===================================
   Componentes de UI
   =================================== */

/* Cards Modernos */
.card {
    background: var(--bg-white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    padding: 0; /* Header/Body controlam padding */
    margin-bottom: 2rem;
    transition: var(--transition);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

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

.card-header {
    padding: 1.25rem 1.5rem;
    background-color: white;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

/* Botões Modernos */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    text-align: center;
}

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

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
}
.btn-primary:hover { background-color: var(--secondary-hover); }

.btn-success {
    background-color: var(--success-color);
    color: white;
    box-shadow: 0 4px 6px rgba(46, 204, 113, 0.2);
}
.btn-success:hover { filter: brightness(0.9); }

.btn-danger {
    background-color: var(--danger-color);
    color: white;
    box-shadow: 0 4px 6px rgba(231, 76, 60, 0.2);
}
.btn-danger:hover { filter: brightness(0.9); }

.btn-warning {
    background-color: var(--warning-color);
    color: white;
}
.btn-warning:hover { filter: brightness(0.95); }

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}
.btn-secondary:hover { background-color: #7f8c8d; }

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Formulários Estilizados */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

input, select, textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background-color: #fafafa;
    font-family: inherit;
    color: var(--text-primary);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Tabelas Bonitas */
table {
    width: 100%;
    border-collapse: separate; /* Permite bordas arredondadas */
    border-spacing: 0;
    background: transparent;
}

thead th {
    background-color: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
    text-align: left;
}

thead th:first-child { border-top-left-radius: var(--border-radius-sm); }
thead th:last-child { border-top-right-radius: var(--border-radius-sm); }

tbody tr {
    background-color: white;
    transition: var(--transition);
}

tbody tr:hover {
    background-color: #f1f9fe;
    transform: scale(1.005); /* Efeito sutil de zoom */
    box-shadow: var(--shadow-sm);
    z-index: 10;
    position: relative;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    vertical-align: middle;
}

/* Badges e Status */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.35em 0.8em;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success { background-color: var(--success-bg); color: #27ae60; }
.badge-danger { background-color: var(--danger-bg); color: #c0392b; }
.badge-warning { background-color: var(--warning-bg); color: #d35400; }
.badge-info { background-color: var(--info-bg); color: #2980b9; }
.badge-secondary { background-color: #f0f2f5; color: var(--text-secondary); }

/* Alertas */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
    border-left: 4px solid transparent;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: fadeIn 0.3s ease-out;
}

.alert-success { background-color: var(--success-bg); border-color: var(--success-color); color: #155724; }
.alert-danger { background-color: var(--danger-bg); border-color: var(--danger-color); color: #721c24; }
.alert-warning { background-color: var(--warning-bg); border-color: var(--warning-color); color: #856404; }
.alert-info { background-color: var(--info-bg); border-color: var(--info-color); color: #0c5460; }

/* Grid System Simplificado */
.row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.col { flex: 1; }
.col-2 { flex: 0 0 calc(16.666% - 1.25rem); }
.col-3 { flex: 0 0 calc(25% - 1.125rem); }
.col-4 { flex: 0 0 calc(33.333% - 1rem); }
.col-6 { flex: 0 0 calc(50% - 0.75rem); }
.col-8 { flex: 0 0 calc(66.666% - 0.5rem); }
.col-9 { flex: 0 0 calc(75% - 0.375rem); }
.col-12 { flex: 0 0 100%; }

/* Animações */
.fade-in {
    animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Overlay e Content (Com a correção aplicada) */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6); /* Backdrop mais escuro e azulado */
    backdrop-filter: blur(4px); /* Efeito glass */
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.modal-overlay:not(.hidden) {
    display: flex;
    opacity: 1;
}

.hidden { display: none !important; }

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: scale(1);
}

/* Utilitários */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

/* Responsividade Mobile */
@media (max-width: 768px) {
    .container { padding: 15px; }

    header {
        height: auto;
        position: sticky;
        top: 0;
    }

    .header-content {
        flex-direction: column;
        padding: 15px 20px;
        gap: 15px;
    }

    .brand {
        width: 100%;
        justify-content: center;
        padding-bottom: 10px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    }

    .logo-icon {
        width: 60px;
        height: 60px;
    }

    header .logo {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.85rem;
    }

    .user-info {
        width: 100%;
        justify-content: space-between;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.15);
    }

    .user-details {
        text-align: left;
    }

    .user-avatar {
        width: 40px;
        height: 40px;
    }

    /* Sidebar responsivo */
    .sidebar {
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 100;
    }

    .sidebar.active {
        left: 0;
    }

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

    .sidebar-toggle {
        display: flex;
    }

    .col, [class*="col-"] { flex: 0 0 100% !important; max-width: 100%; }

    table { display: block; overflow-x: auto; white-space: nowrap; }

    .card-header { flex-direction: column; gap: 10px; align-items: flex-start; }
    .card-header button { width: 100%; }

    .stats-grid { grid-template-columns: 1fr; }
}