/* CRM Cronotacografo - Estilos */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* LOGIN */
#login-screen {
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    width: 100%;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9998;
    background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
}

#login-screen.active { display: flex; }

.login-box {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-logo { display: block; width: 250px; height: 92px; margin: 0 auto 10px; object-fit: contain; }
.login-box h3 { color: #666; margin-bottom: 25px; font-weight: 400; }

.login-box input {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.login-box input:focus {
    outline: none;
    border-color: #3949ab;
}

.error { color: #d32f2f; margin-top: 10px; font-size: 14px; }

/* APP */
#app-screen {
    min-height: 100vh;
}

#app-screen.active { display: flex; }

.sidebar {
    width: 260px;
    background: #1a237e;
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo {
    padding: 16px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo-imagem { display: block; width: 100%; height: 82px; object-fit: contain; object-position: center; }
.logo small { opacity: 0.7; font-size: 0.75em; text-transform: uppercase; letter-spacing: 1px; }

nav { flex: 1; padding: 15px 0; }

.nav-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    color: rgba(255,255,255,0.8);
    text-decoration: none;
    transition: all 0.3s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left-color: #ff9800;
}

.nav-item span { margin-right: 12px; font-size: 1.2em; }

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-footer span { font-size: 0.9em; opacity: 0.8; }

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 30px;
    min-height: 100vh;
}

/* PAGINAS */
.screen { display: none; }
.screen.active { display: flex; }
.page { display: none; }
.page.active { display: block; }

h1 { margin-bottom: 25px; color: #1a237e; font-size: 1.8em; }

/* CARDS */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid;
}

.card.blue { border-left-color: #2196f3; }
.card.red { border-left-color: #f44336; }
.card.yellow { border-left-color: #ff9800; }
.card.green { border-left-color: #4caf50; }

.card h3 { font-size: 0.9em; color: #666; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 0.5px; }
.card .big { font-size: 2.2em; font-weight: 700; color: #333; }

/* TABELAS */
.table-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover { background: #f8f9fa; }

/* STATUS */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 600;
    display: inline-block;
}

.badge-sucesso { background: #e8f5e9; color: #2e7d32; }
.badge-erro { background: #ffebee; color: #c62828; }
.badge-pendente { background: #fff3e0; color: #e65100; }
.badge-vencido { background: #ffebee; color: #c62828; }
.badge-alerta { background: #fff8e1; color: #f57f17; }

/* BOTOES */
.btn-primary {
    background: #3949ab;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover { background: #303f9f; }

.btn-secondary {
    background: white;
    color: #3949ab;
    border: 2px solid #3949ab;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-secondary:hover { background: #3949ab; color: white; }

.btn-small {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}

.btn-small:hover { background: rgba(255,255,255,0.3); }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2em;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.btn-icon:hover { background: #e3f2fd; }

.modal-sistema-content { max-width: 480px; }
.modal-sistema-mensagem { white-space: pre-line; color: #444; line-height: 1.55; margin: 18px 0 24px; }
.modal-sistema-acoes { display: flex; justify-content: flex-end; gap: 10px; }
.notificacoes { position: relative; }
.btn-sino { border: 0; background: transparent; font-size: 20px; cursor: pointer; position: relative; }
.contador-notificacoes { position: absolute; top: -7px; right: -9px; min-width: 17px; padding: 1px 4px; border-radius: 10px; background: #e53935; color: white; font-size: 11px; }
.painel-notificacoes { position: absolute; bottom: 34px; left: 0; width: 290px; max-height: 250px; overflow: auto; background: #fff; color: #333; border-radius: 8px; box-shadow: 0 8px 25px rgba(0,0,0,.22); padding: 12px; z-index: 30; }
.notificacao-item { border-bottom: 1px solid #eee; padding: 9px 2px; font-size: 13px; }
.painel-fila { display:flex; flex-wrap:wrap; gap:10px 18px; align-items:center; margin:12px 0; padding:10px 14px; border:1px solid #d8def5; border-radius:8px; background:#f7f8ff; color:#1a237e; font-size:13px; }
.painel-fila strong { font-size:14px; }
.status-atualizacao { margin: -4px 0 14px; padding: 11px 14px; border-radius: 9px; background: #e8f0fe; color: #193c7d; font-size: 14px; }
.progresso-consulta { display: flex; align-items: center; gap: 12px; }
.spinner-consulta { width: 28px; height: 28px; flex: 0 0 28px; border: 3px solid #c7d5f7; border-top-color: #3949ab; border-radius: 50%; animation: spin .8s linear infinite; }
.progresso-consulta-conteudo { min-width: 0; flex: 1; display: grid; gap: 5px; }
.progresso-consulta-conteudo strong { color: #1f318d; }
.progresso-consulta-conteudo small { color: #5d6e92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra-progresso { height: 7px; overflow: hidden; border-radius: 999px; background: #cad7f2; }
.barra-progresso span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #3949ab, #6177dc); transition: width .45s ease; }
.progresso-percentual { min-width: 42px; color: #1f318d; font-size: 18px; text-align: right; }

/* PAGE HEADER */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.page-header .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Mantém o título, busca e ações da frota sempre acessíveis durante a rolagem. */
#page-veiculos .page-header {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 -2px 14px;
    padding: 12px 2px 14px;
    background: #f0f2f5;
    box-shadow: 0 8px 10px -12px rgba(0, 0, 0, .5);
}

.page-header input {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    min-width: 200px;
}

/* Filtros da frota seguem o mesmo padrÃ£o visual dos botÃµes secundÃ¡rios. */
#page-veiculos .page-header input,
#page-veiculos .page-header select {
    height: 42px;
    padding: 0 14px;
    border: 2px solid #3949ab;
    border-radius: 8px;
    background: #fff;
    color: #3949ab;
    font-size: 14px;
    outline: none;
}

#page-veiculos .page-header input { min-width: 190px; }
#page-veiculos .page-header input[type="date"] { min-width: 178px; }
#page-veiculos .page-header select { min-width: 150px; cursor: pointer; }
#page-veiculos .page-header input:focus,
#page-veiculos .page-header select:focus { box-shadow: 0 0 0 3px rgba(57, 73, 171, .15); }

.consulta-resultado {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid #dbe4ff;
    border-radius: 10px;
    background: #f7f9ff;
}

.consulta-resultado h3 {
    color: #1a237e;
    margin-bottom: 12px;
}

.consulta-resultado-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px 16px;
}

.consulta-resultado-item {
    padding: 10px 12px;
    border-radius: 8px;
    background: white;
    border: 1px solid #e8ecfb;
}

.consulta-resultado-item strong {
    display: block;
    margin-bottom: 4px;
    color: #4a5678;
    font-size: 0.85em;
    text-transform: uppercase;
}

.consulta-resultado-erro {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 10px;
    background: #ffebee;
    color: #b71c1c;
    border: 1px solid #ffcdd2;
}

/* MODAIS */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    animation: slideIn 0.3s ease;
}

.modal-content-wide {
    max-width: 860px;
}

@keyframes slideIn {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.close {
    position: absolute;
    right: 20px; top: 15px;
    font-size: 28px;
    cursor: pointer;
    color: #999;
}

.close:hover { color: #333; }

.modal h2 { margin-bottom: 20px; color: #1a237e; }

.modal label {
    display: block;
    margin: 15px 0 6px;
    font-weight: 500;
    color: #555;
    font-size: 14px;
}

.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.modal input:focus, .modal select:focus, .modal textarea:focus {
    outline: none;
    border-color: #3949ab;
}

.modal button[type="submit"] {
    width: 100%;
    margin-top: 20px;
    padding: 14px;
}

/* FILTROS */
.filtros {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filtros button.active {
    background: #3949ab;
    color: white;
}

/* LOADING */
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px; height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: #3949ab;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ALERTAS NA TABELA */
tr.alerta { background: #fff8e1 !important; }
tr.vencido { background: #ffebee !important; }
tr.alerta:hover, tr.vencido:hover { filter: brightness(0.97); }

/* RESPONSIVO */
@media (max-width: 768px) {
    #app-screen.active { flex-direction: column; }
    .sidebar {
        position: sticky;
        top: 0;
        width: 100%;
        height: auto;
    }
    .logo { padding: 8px 16px; }
    .logo-imagem { width: 150px; height: 42px; }
    .sidebar nav {
        display: flex;
        overflow-x: auto;
        padding: 0;
    }
    .nav-item {
        flex: 0 0 auto;
        padding: 12px 14px;
        border-left: 0;
        border-bottom: 3px solid transparent;
    }
    .nav-item:hover, .nav-item.active { border-bottom-color: #ff9800; }
    .sidebar-footer { padding: 10px 16px; }
    .main-content {
        width: 100%;
        margin-left: 0;
        padding: 16px;
    }
    .cards { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
    #page-veiculos .page-header { top: 0; }
    .login-box {
        width: calc(100% - 32px);
        padding: 28px 22px;
    }
    .section { padding: 16px; }
}

/* UTILS */
.section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-top: 25px;
}

.section h2 { font-size: 1.2em; color: #333; margin-bottom: 15px; }

.config-section {
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.permissao-grupo {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.permissao-grupo h3 {
    color: #1a237e;
    margin-bottom: 12px;
    font-size: 1.1em;
    text-transform: uppercase;
}

.permissao-item {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.permissao-item label {
    margin-left: 10px;
    cursor: pointer;
    flex: 1;
}

.permissao-item input[type="checkbox"] {
    width: 18px; height: 18px;
    cursor: pointer;
}
