@import url('https://cdn.jsdelivr.net/npm/tom-select@2.3.1/dist/css/tom-select.min.css');

/* =========================================
   1. RESET E BASE
   ========================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #334155;
    background-color: #f8fafc;
}

.container {
    width: 92%;
    max-width: 1520px;
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
    z-index: 1;
}

/* =========================================
   2. HEADER E NAVEGAÇÃO
   ========================================= */
.header {
    background: linear-gradient(135deg, #003366 0%, #002855 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 20px;
}

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

.user-name {
    font-weight: 600;
    font-size: 1rem;
}

.user-role {
    font-size: 0.85rem;
    opacity: 0.85;
}

.nav {
    background: white;
    border-bottom: 3px solid #003366;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.nav-list {
    list-style: none;
    display: flex;
    margin: 0;
    padding: 0;
}

.nav-item a {
    display: block;
    padding: 15px 25px;
    color: #475569;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.nav-item a:hover,
.nav-item a.active {
    color: #003366;
    background-color: #f0f4f9;
    border-bottom-color: #003366;
}

/* =========================================
   3. COMPONENTES (Cards, Forms, Buttons)
   ========================================= */
.card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.07);
    margin-bottom: 28px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.10);
}

.card-header {
    padding: 18px 28px 16px;
    border-bottom: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #f0f4f9 100%);
}

.card-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 600;
    color: #003366;
}

.card-body {
    padding: 28px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #334155;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #fff;
    color: #334155;
}

.form-control:focus {
    outline: none;
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 12px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 40px;
    appearance: none;
}

/* Botões */
.btn {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: all 0.2s ease;
    text-align: center;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background-color: #003366;
    color: white;
}

.btn-primary:hover {
    background-color: #002244;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 51, 102, 0.3);
}

.btn-secondary {
    background-color: #64748b;
    color: white;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-success {
    background-color: #28a745;
    color: white;
}

.btn-success:hover {
    background-color: #218838;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* Alertas */
.alert {
    padding: 15px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    font-weight: 500;
}

.alert-success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-error, .alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fee2e2;
}

/* =========================================
   4. DASHBOARD, GRÁFICOS E RELATÓRIOS
   ========================================= */

.chart-container {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    contain: layout;
    transform: translateZ(0);
}

.chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: #003366;
    margin-bottom: 20px;
    text-align: center;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 10px;
}

.chart-container canvas {
    max-height: 400px !important;
    height: 400px !important;
    display: block;
    margin: 0 auto;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #003366;
    transition: all 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: #003366;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 0.9rem;
    color: #64748b;
    font-weight: 500;
}

.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.recent-notifications {
    overflow-x: auto;
    margin-top: 20px;
}

/* =========================================
   5. AUTH & MODAIS
   ========================================= */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #f8fafc 35%, #ffffff 100%);
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 51, 102, 0.08);
    width: 100%;
    max-width: 420px;
    border: 1px solid #f1f5f9;
}

.auth-header { text-align: center; margin-bottom: 30px; }
.auth-title { font-size: 1.8rem; font-weight: 700; color: #003366; margin-bottom: 10px; }
.auth-subtitle { color: #64748b; font-size: 1rem; }
.auth-links { text-align: center; margin-top: 25px; }
.auth-links a { color: #0056b3; text-decoration: none; font-weight: 500; }
.auth-links a:hover { text-decoration: underline; }

/* Modais */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #f8fafc 0%, #f0f4f9 100%);
}

.modal-header h3 {
    color: #003366;
    font-weight: 600;
}

.modal-body { padding: 25px; }

.close {
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #64748b;
}
.close:hover { color: #003366; }

/* =========================================
   6. TABELAS E UTILITÁRIOS
   ========================================= */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f8fafc;
    font-weight: 600;
    color: #003366;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

tr:hover { background-color: #f8fafc; }

.notification-row { position: relative; }
.priority-indicator {
    width: 4px;
    height: 100%;
    position: absolute;
    left: 0;
    top: 0;
}

.action-buttons {
    display: flex;
    gap: 5px;
    justify-content: center;
}

/* Upload Preview */
.file-preview {
    background: #f8fafc;
    padding: 10px;
    border-radius: 5px;
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.file-preview.success { border-left: 3px solid #28a745; }
.file-preview.error   { border-left: 3px solid #dc3545; }

/* Utilities */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.mt-20       { margin-top: 20px; }
.hidden      { display: none; }

/* =========================================
   7. RESPONSIVIDADE E IMPRESSÃO
   ========================================= */
@media (max-width: 1024px) {
    .container { width: 96%; padding: 0 16px; }
}

@media (max-width: 768px) {
    .container { width: 100%; padding: 0 12px; }

    .header-content { flex-direction: column; gap: 15px; text-align: center; }
    .nav-list { flex-direction: column; }
    .nav-item a { border-bottom: none; border-left: 3px solid transparent; }
    .nav-item a:hover, .nav-item a.active { border-left-color: #003366; border-bottom-color: transparent; }
    .auth-card { margin: 20px; padding: 30px 25px; }

    .card-body   { padding: 18px; }
    .card-header { padding: 14px 18px; }

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

    .chart-container canvas {
        max-height: 300px !important;
        height: 300px !important;
    }

    table      { font-size: 0.9rem; }
    th, td     { padding: 10px; }
}

@media print {
    .header, .nav, .btn, .no-print { display: none !important; }
    .container { width: 100% !important; max-width: 100% !important; padding: 0 !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }

    .chart-container {
        page-break-inside: avoid;
        break-inside: avoid;
        margin-bottom: 20px;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .stats-grid {
        display: flex !important;
        flex-wrap: wrap;
        justify-content: space-between;
    }

    .stat-card {
        flex: 1;
        min-width: 150px;
        margin: 5px;
        border: 1px solid #ccc;
    }

    .charts-row { display: block !important; }
}

/* =========================================
   TOM SELECT — TEMA HR NOTIFICA
   ========================================= */
.ts-wrapper { width: 100%; }

.ts-wrapper.single .ts-control,
.ts-wrapper.multi .ts-control {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 36px 10px 16px;
    min-height: 46px;
    background: #fff;
    box-shadow: none;
    cursor: pointer;
    font-size: 1rem;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.ts-wrapper.single.input-active .ts-control,
.ts-wrapper.multi.input-active .ts-control,
.ts-wrapper.focus .ts-control {
    border-color: #0056b3;
    box-shadow: 0 0 0 3px rgba(0, 86, 179, 0.1);
    outline: none;
}

.ts-control .placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.ts-control input {
    font-size: 1rem !important;
    color: #334155 !important;
    line-height: 1.4;
    flex: 1;
    min-width: 40px;
    pointer-events: none;
}

.ts-wrapper.input-active .ts-control input,
.ts-wrapper.focus .ts-control input {
    pointer-events: auto;
}

.ts-wrapper.single .ts-control::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 6px 5px 0;
    border-color: #64748b transparent transparent;
    pointer-events: none;
}

.ts-wrapper.single.is-open .ts-control::after {
    border-width: 0 5px 6px;
    border-color: transparent transparent #003366;
}

.ts-dropdown,
.ts-dropdown.single,
.ts-dropdown.multi {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    margin-top: 4px;
    z-index: 10000;
    background: #fff;
    font-size: 0.95rem;
}

.ts-dropdown-content {
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0;
}

.ts-dropdown .option {
    padding: 10px 16px;
    color: #334155;
    cursor: pointer;
    transition: background 0.1s;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background: #003366;
    color: #fff;
}

.ts-dropdown .selected {
    background: #edf2f7;
    color: #003366;
    font-weight: 600;
}

.ts-dropdown .selected.active {
    background: #003366;
    color: #fff;
}

.ts-dropdown-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 8px 10px;
}

.ts-dropdown-header input,
.ts-wrapper .dropdown-input {
    border: 1px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 6px 10px !important;
    font-size: 0.9rem !important;
    width: 100%;
    outline: none;
    background: #fff;
}

.ts-dropdown-header input:focus,
.ts-wrapper .dropdown-input:focus {
    border-color: #0056b3 !important;
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1) !important;
}

.no-results {
    padding: 10px 16px;
    color: #94a3b8;
    font-style: italic;
    font-size: 0.9rem;
}
