/* ==========================================================================
   1. ESTILOS GERAIS E LAYOUT BASE
   ========================================================================== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f2f5;
    color: #333;
    line-height: 1.6;
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column; 
    justify-content: center;
    align-items: center;
}

footer {
    text-align: center;
    padding: 20px 50px;
    background-color: #333;
    color: #aaa;
    margin-top: auto;
    font-size: 0.9em;
}

/* ==========================================================================
   2. CABEÇALHO (HEADER)
   ========================================================================== */
header {
    background-color: #004d99;
    padding: 20px 50px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 20px;
}

header.login-header {
    justify-content: center;
}

header.dashboard-header {
    justify-content: space-between;
}

header img {
    max-width: 200px;
    height: auto;
}

header h1 {
    color: #fff;
    margin: 0;
    font-size: 1.8em;
    white-space: nowrap;
}

.logout-button, .back-button {
    background-color: #e74c3c;
    color: #fff;
    padding: 8px 15px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.logout-button:hover, .back-button:hover {
    background-color: #c0392b;
}

/* ==========================================================================
   3. CONTAINERS, TÍTULOS E MENSAGENS
   ========================================================================== */
.dashboard-container, .form-container, .login-form-container, .ticket-view-container {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    width: 100%;
    box-sizing: border-box;
}

.login-form-container {
    max-width: 450px;
    margin-top: 30px;
}

.form-container {
    max-width: 500px;
    margin-top: 30px;
}

.ticket-view-container {
    max-width: 900px;
    margin: 30px auto;
}

h2 {
    color: #004d99;
    text-align: center;
    border-bottom: 2px solid #004d99;
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 25px;
}

h3 {
    color: #004d99;
    margin: 0;
}

.error-message {
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    text-align: center;
    font-size: 0.9em;
}

.success-modal {
    width: 100%;
    max-width: 450px;
    box-sizing: border-box;
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-left: 5px solid #28a745;
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    margin: 20px 0;
}

.success-modal h3 {
    margin: 0 0 10px 0;
    color: #155724;
}

.success-modal p {
    margin: 0;
}

/* ==========================================================================
   4. FORMULÁRIOS
   ========================================================================== */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 8px;
    color: #555;
}

input[type="text"], input[type="email"], input[type="password"], select, textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1em;
    font-family: inherit;
}

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

button {
    background-color: #007bff;
    color: #fff;
    padding: 15px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    width: 100%;
}

.password-container {
    position: relative;
}

.password-toggle-icon {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    cursor: pointer;
    color: #888;
}

/* ==========================================================================
   5. DASHBOARD E LAYOUT COM SIDEBAR
   ========================================================================== */
.dashboard-layout {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 30px;
    width: 100%;
    max-width: 1200px;
    margin: 30px auto;
}

.dashboard-sidebar {
    flex: 0 0 280px;
}

.dashboard-main-content {
    flex: 1;
    min-width: 0;
}

.sidebar-widget {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 25px;
}

.sidebar-widget h3 {
    margin: 0 0 15px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
    font-size: 1.1em;
}

.profile-info p {
    margin: 0 0 8px 0;
    font-size: 0.95em;
    word-wrap: break-word;
}

.sidebar-nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav li a {
    display: block;
    padding: 12px;
    text-decoration: none;
    color: #007bff;
    font-weight: bold;
    border-radius: 5px;
    transition: background-color 0.2s ease;
}

.sidebar-nav li a:hover {
    background-color: #f0f8ff;
}

.dashboard-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* ==========================================================================
   6. CAIXAS DE ESTATÍSTICAS (STAT BOXES)
   ========================================================================== */
.stat-boxes-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background-color: #ffffff;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    text-align: center;
    border-left: 5px solid;
}

.stat-box .stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: #333;
}

.stat-box .stat-label {
    font-size: 1em;
    color: #6c757d;
    margin-top: 5px;
}

.stat-box.color-aberto { border-color: #007bff; }
.stat-box.color-progresso { border-color: #ffc107; }
.stat-box.color-fechado { border-color: #6c757d; }
.stat-box.color-total { border-color: #17a2b8; }

/* ==========================================================================
   7. TABELA DE TICKETS E BADGES DE STATUS
   ========================================================================== */
.tickets-table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th, table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background-color: #f2f2f2;
    color: #555;
}

table tbody tr:hover {
    background-color: #f9f9f9;
}

td[data-label="Status"], td[data-label="Ações"] {
    text-align: center;
}

.status-badge {
    display: inline-block;
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
}

.status-badge.status-aberto {
    background-color: #007bff;
}

.status-badge.status-em-progresso {
    background-color: #ffc107;
    color: #212529;
}

.status-badge.status-fechado {
    background-color: #6c757d;
}

/* ==========================================================================
   8. VISUALIZAÇÃO DE TICKET (DETALHES E RESPOSTAS)
   ========================================================================== */
.ticket-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px 25px;
}

.detail-group.full-width {
    grid-column: 1 / -1;
}

.ticket-view-container hr {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 30px 0;
}

.resposta {
    border: 1px solid #e9ecef;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
}

.resposta-cliente {
    background-color: #f8f9fa;
}

.resposta-admin {
    background-color: #e7f5ff;
    border-color: #b3d7ff;
}

/* ==========================================================================
   9. GERENCIADOR DE USUÁRIOS (ADMIN)
   ========================================================================== */
.action-btn {
    display: inline-block;
    padding: 6px 12px;
    margin: 0 2px;
    font-size: 0.85em;
    font-weight: bold;
    text-align: center;
    text-decoration: none;
    color: #fff !important;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: opacity 0.3s ease;
}
.action-btn:hover {
    opacity: 0.8;
}
.btn-edit { background-color: #007bff; }
.btn-block { background-color: #ffc107; }
.btn-unblock { background-color: #28a745; }
.btn-delete { background-color: #dc3545; }

.custom-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}
.custom-modal-box {
    background-color: #fff;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
}
.custom-modal-box h3 {
    margin-top: 0;
    font-size: 1.2em;
}
.custom-modal-actions {
    margin-top: 25px;
}
.custom-modal-btn {
    padding: 10px 25px;
    margin: 0 10px;
    color: #fff;
    border: none;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
}
.modal-confirm-safe { background-color: #28a745; }
.modal-confirm-warning { background-color: #ffc107; }
.modal-confirm-danger { background-color: #dc3545; }
.modal-cancel-btn { background-color: #6c757d; }

/* ==========================================================================
   10. MENSAGEM DE BLOQUEIO PARA MOBILE (APENAS NO INDEX)
   ========================================================================== */
.mobile-block-message {
    display: none !important;
}

@media (max-width: 1024px) {
    body.page-login {
        overflow: hidden;
    }
    
    .page-login > header,
    .page-login > main,
    .page-login > footer {
        display: none !important;
    }

    .mobile-block-message {
        display: flex !important;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: #f0f2f5;
        z-index: 9999;
        padding: 20px;
        box-sizing: border-box;
    }

    .mobile-block-content {
        background-color: #ffffff;
        padding: 40px 25px;
        border-radius: 8px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
        text-align: center;
        max-width: 450px;
        width: 95%;
    }

    .mobile-block-logo {
        max-width: 180px;
        height: auto;
        margin-bottom: 30px;
    }

    .mobile-block-content h2 {
        border-bottom: 1px solid #eee;
        padding-bottom: 15px;
        margin-bottom: 15px;
        font-size: 1.5em;
        color: #333;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .mobile-block-content p {
        margin: 0 0 30px 0;
        font-size: 1.1em;
        color: #555;
        font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }
    
    .mobile-block-link {
        display: inline-block;
        padding: 12px 25px;
        background-color: #007bff;
        color: #ffffff;
        text-decoration: none;
        border-radius: 5px;
        font-weight: bold;
    }
}

/* ==========================================================================
   11. RESPONSIVIDADE GERAL
   ========================================================================== */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        padding: 20px;
    }
    
    .ticket-details {
        grid-template-columns: 1fr;
    }

    .detail-group {
        flex: 1 1 100%;
    }
    
    .dashboard-layout {
        flex-direction: column;
    }
    
    .dashboard-sidebar {
        width: 100%;
        flex-basis: auto;
    }
}

@media (max-width: 600px) {
    table thead {
        display: none;
    }
    table, table tbody, table tr, table td {
        display: block;
        width: 100%;
    }

    table tr {
        margin-bottom: 15px;
        border: 1px solid #ddd;
        border-radius: 8px;
    }
    
    table td {
        text-align: right;
        padding-left: 50%;
        position: relative;
        border-bottom: 1px solid #eee;
    }

    table tr td:last-child {
        border-bottom: none;
    }
    
    table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 50%;
        padding-left: 15px;
        font-weight: bold;
        text-align: left;
    }
}

/* --- INÍCIO: ESTILO PROFISSIONAL PARA ESTADO VAZIO (SEM TICKETS) --- */

.no-tickets-container {
    text-align: center;
    padding: 60px 40px;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    margin-top: 20px;
}

.no-tickets-container h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.5em;
    color: #495057;
}

.no-tickets-container p {
    font-size: 1.1em;
    color: #6c757d;
    margin: 0 0 25px 0;
}

/* Esta regra vai fazer o link virar um botão azul */
.no-tickets-container a.button-primary {
    display: inline-block;
    text-decoration: none;
}

/* --- FIM: ESTILO PROFISSIONAL PARA ESTADO VAZIO --- */

/* --- INÍCIO: CORES PARA BADGES DE URGÊNCIA E NÍVEL DE SUPORTE --- */

/* Cores para Urgência */
.status-badge.urgencia-baixa {
    background-color: #28a745; /* Verde */
}
.status-badge.urgencia-média {
    background-color: #007bff; /* Azul */
}
.status-badge.urgencia-alta {
    background-color: #ffc107; /* Amarelo */
    color: #212529; /* Texto escuro */
}
.status-badge.urgencia-crítica {
    background-color: #dc3545; /* Vermelho */
}

/* Cores para Nível de Suporte */
.status-badge.nivel-nivel1 {
    background-color: #007bff; /* Azul */
}
.status-badge.nivel-nivel2 {
    background-color: #ffc107; /* Amarelo */
    color: #212529; /* Texto escuro */
}
.status-badge.nivel-nivel3 {
    background-color: #dc3545; /* Vermelho */
}

/* --- FIM: CORES PARA BADGES --- */

/* --- INÍCIO: ESTILOS FINAIS PARA INFO HEADER DO TICKET ADMIN --- */

.ticket-info-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 2px solid #004d99;
}

.ticket-info-header h2 {
    margin: 0;
    border: none;
    padding: 0;
}

.ticket-badges {
    display: flex;
    gap: 20px;
    text-align: right;
}

.badge-item span:first-child {
    font-weight: bold;
    font-size: 0.9em;
    color: #555;
    display: block;
    margin-bottom: 5px;
}

/* Correção das classes para Nível de Suporte */
.status-badge.nivel-n-vel1 {
    background-color: #007bff; /* Azul */
}
.status-badge.nivel-n-vel2 {
    background-color: #ffc107; /* Amarelo */
    color: #212529; /* Texto escuro */
}
.status-badge.nivel-n-vel3 {
    background-color: #dc3545; /* Vermelho */
}

/* --- FIM: ESTILOS FINAIS --- */

/* ==========================================================================
   12. CORREÇÃO FINAL - BADGES NÍVEL DE SUPORTE
   ========================================================================== */
/* Estas são as novas regras para as classes corrigidas que vêm do PHP (ex: nivel-1) */

.status-badge.nivel-1 {
    background-color: #007bff; /* Azul */
}

.status-badge.nivel-2 {
    background-color: #ffc107; /* Amarelo */
    color: #212529;      /* Texto escuro para contraste */
}

.status-badge.nivel-3 {
    background-color: #dc3545; /* Vermelho */
}