/* ========================================
   RESET E VARIÁVEIS
======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2563eb;
    --primary-dark: #1e40af;
    --secondary-color: #10b981;
    --background: #f8fafc;
    --surface: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;
}

/* ========================================
   ESTILOS GERAIS
======================================== */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

/* Container Principal */
.container {
    max-width: 700px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   LOGO
======================================== */
.logo-container {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
}

.logo-container img {
    max-width: 280px;
    height: auto;
    transition: var(--transition);
}

.logo-container img:hover {
    transform: scale(1.02);
}

/* ========================================
   TÍTULOS
======================================== */
h2 {
    color: var(--text-primary);
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 25px;
    text-align: center;
}

h3 {
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
}

/* ========================================
   ALERTAS
======================================== */
.alert {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border-left: 4px solid var(--success);
    color: #155724;
    padding: 20px;
    margin-bottom: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    animation: slideInDown 0.4s ease;
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert b {
    font-weight: 700;
    color: #0f5132;
}

/* ========================================
   FORMULÁRIOS
======================================== */
form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: block;
}

input[type="text"],
input[type="email"],
select,
textarea {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    transition: var(--transition);
    background: var(--surface);
    color: var(--text-primary);
}

input[type="text"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    resize: vertical;
    min-height: 120px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23334155' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* ========================================
   BOTÕES
======================================== */
button[type="submit"],
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-md);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

button[type="submit"]:hover,
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: linear-gradient(135deg, var(--primary-dark) 0%, #1e3a8a 100%);
}

button[type="submit"]:active,
.btn-primary:active {
    transform: translateY(0);
}

/* ========================================
   LINKS
======================================== */
a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    display: inline-block;
    margin-top: 20px;
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

/* ========================================
   TABELAS
======================================== */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

th, td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background: var(--background);
    font-weight: 700;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 13px;
    letter-spacing: 0.5px;
}

tr:hover {
    background: var(--background);
}

tr:last-child td {
    border-bottom: none;
}

/* ========================================
   CARDS
======================================== */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.card-header {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.card-body {
    color: var(--text-secondary);
}

/* ========================================
   RESPONSIVIDADE
======================================== */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 24px 20px;
        border-radius: 8px;
    }
    
    h2 {
        font-size: 24px;
    }
    
    .logo-container img {
        max-width: 200px;
    }
    
    input[type="text"],
    input[type="email"],
    select,
    textarea {
        padding: 12px 14px;
        font-size: 16px; /* Evita zoom no iOS */
    }
    
    button[type="submit"],
    .btn-primary {
        width: 100%;
        padding: 16px;
    }
    
    table {
        font-size: 14px;
    }
    
    th, td {
        padding: 12px 8px;
    }
    
    /* Tornar tabela rolável em telas pequenas */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 20px 16px;
    }
    
    h2 {
        font-size: 22px;
    }
    
    .alert {
        padding: 16px;
        font-size: 14px;
    }
}

/* ========================================
   UTILITÁRIOS
======================================== */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.text-muted {
    color: var(--text-secondary);
}

.font-bold {
    font-weight: 700;
}

/* ========================================
   LOADING STATE
======================================== */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   PAINEL ADMINISTRATIVO
======================================== */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    flex-wrap: wrap;
    gap: 15px;
}

.admin-nav {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.admin-nav a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--background);
    border-radius: 8px;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 14px;
    transition: var(--transition);
    text-decoration: none;
    margin: 0;
}

.admin-nav a:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.filter-form {
    background: var(--surface);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    margin-bottom: 25px;
    border: 1px solid var(--border-color);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    padding: 12px 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
}

.btn-secondary:hover {
    background: var(--border-color);
    transform: translateY(-1px);
}

/* Tabela Admin */
.admin-table {
    width: 100%;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table th {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 16px 12px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.admin-table tr:hover {
    background: var(--background);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.status-badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-nova {
    background: #fef3c7;
    color: #92400e;
}

.status-analise {
    background: #dbeafe;
    color: #1e40af;
}

.status-respondida {
    background: #d1fae5;
    color: #065f46;
}

.mensagem-preview {
    max-width: 400px;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
}

/* Formulário inline na tabela */
.inline-form {
    margin: 0;
}

.inline-form select {
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
}

/* Botão de ação na tabela */
.btn-action {
    display: inline-block;
    padding: 8px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
}

.btn-action:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Login Page */
.login-container {
    max-width: 400px;
    margin: 50px auto;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.login-container h2 {
    margin-bottom: 30px;
}

.error-message {
    background: #fef2f2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 600;
}

/* Responder Page */
.resposta-section {
    background: var(--background);
    padding: 20px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    border-left: 4px solid var(--primary-color);
}

.resposta-anterior {
    background: #f0f9ff;
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-left: 3px solid var(--primary-color);
}

.resposta-data {
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 8px;
}

/* Gráfico */
.chart-container {
    background: var(--surface);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}

/* ========================================
   RESPONSIVIDADE ADMIN
======================================== */
@media (max-width: 768px) {
    .admin-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .admin-nav {
        width: 100%;
    }
    
    .admin-nav a {
        flex: 1;
        justify-content: center;
        font-size: 12px;
        padding: 8px 12px;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-table {
        font-size: 13px;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 10px 8px;
    }
    
    .mensagem-preview {
        max-width: 200px;
        font-size: 13px;
    }
    
    /* Tornar tabela rolável */
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* ========================================
   IMPRESSÃO
======================================== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 20px;
    }
    
    button, a, .admin-nav, .filter-form {
        display: none;
    }
}