/* =============================================
   CONVÊNIOS GUIA - ASMPF
   Design System
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Space+Mono:wght@400;700&display=swap');

:root {
    --primary: #1E3A5F;
    --primary-light: #2D5F8B;
    --primary-lighter: #E8F0FE;
    --accent: #E8913A;
    --accent-light: #FEF3E8;
    --success: #10B981;
    --success-light: #ECFDF5;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --danger: #EF4444;
    --danger-light: #FEF2F2;
    --info: #3B82F6;
    --info-light: #EFF6FF;
    --purple: #8B5CF6;
    --purple-light: #F5F3FF;
    --cyan: #06B6D4;
    --cyan-light: #ECFEFF;
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* =============================================
   HEADER
   ============================================= */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(30, 58, 95, 0.3);
}

.header-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-logo {
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    backdrop-filter: blur(4px);
}

.header-title {
    color: white;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.header-subtitle {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.btn-header {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.2);
    padding: 8px 18px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-header:hover {
    background: rgba(255,255,255,0.22);
    border-color: rgba(255,255,255,0.35);
}

.btn-header.active {
    background: var(--accent);
    border-color: var(--accent);
}

/* =============================================
   MAIN CONTAINER
   ============================================= */
.main-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* =============================================
   STATS BAR
   ============================================= */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .stat-number {
    font-size: 28px;
    font-weight: 700;
    font-family: 'Space Mono', monospace;
    color: var(--primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--gray-500);
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =============================================
   FILTERS
   ============================================= */
.filters-bar {
    background: white;
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    flex: 1;
    min-width: 160px;
}

.filter-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-700);
    background: var(--gray-50);
    transition: all 0.2s;
    outline: none;
}

.filter-input:focus,
.filter-select:focus {
    border-color: var(--primary-light);
    background: white;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    padding-top: 16px;
}

/* =============================================
   TABLE
   ============================================= */
.table-container {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
    margin-bottom: 24px;
}

.table-header {
    padding: 18px 22px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
}

.table-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

.table-header .count {
    font-size: 13px;
    color: var(--gray-500);
    font-weight: 400;
}

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

thead th {
    background: var(--gray-50);
    padding: 12px 18px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
    cursor: default;
}

tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child { border-bottom: none; }

tbody td {
    padding: 14px 18px;
    font-size: 14px;
    color: var(--gray-700);
    vertical-align: middle;
}

.td-nome {
    font-weight: 600;
    color: var(--gray-800);
}

.td-empresa {
    color: var(--gray-500);
    font-size: 13px;
}

/* =============================================
   STATUS BADGES
   ============================================= */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-Solicitado { background: var(--info-light); color: var(--info); }
.status-Aguardando { background: var(--purple-light); color: var(--purple); }
.status-Em-Estudo { background: var(--warning-light); color: var(--warning); }
.status-Em-Andamento { background: var(--accent-light); color: var(--accent); }
.status-Em-Negociação { background: #FFF7ED; color: #C2410C; }
.status-Aguardando-Assinatura { background: var(--cyan-light); color: var(--cyan); }
.status-Ativo { background: var(--success-light); color: var(--success); }
.status-Cancelado { background: var(--danger-light); color: var(--danger); }
.status-Recusado-pela-Empresa { background: #FEF2F2; color: #B91C1C; }
.status-Suspenso { background: var(--gray-100); color: var(--gray-500); }

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: currentColor;
}

/* =============================================
   BUTTONS
   ============================================= */
.btn {
    padding: 10px 22px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: white;
}
.btn-primary:hover {
    background: var(--primary-light);
    box-shadow: var(--shadow-md);
}

.btn-accent {
    background: var(--accent);
    color: white;
}
.btn-accent:hover {
    background: #D07E30;
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-success {
    background: var(--success);
    color: white;
}
.btn-success:hover { background: #059669; }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #DC2626; }

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

/* =============================================
   MODALS
   ============================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.25s ease;
    padding: 20px;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateY(20px) scale(0.97);
    transition: all 0.25s ease;
}

.modal-overlay.active .modal {
    transform: translateY(0) scale(1);
}

.modal-large { max-width: 780px; }

.modal-header {
    padding: 22px 26px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--gray-800);
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 18px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}

.modal-body {
    padding: 26px;
}

.modal-footer {
    padding: 18px 26px;
    border-top: 1px solid var(--gray-100);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    position: sticky;
    bottom: 0;
    background: white;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* =============================================
   FORMS
   ============================================= */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group label .required {
    color: var(--danger);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    color: var(--gray-800);
    background: white;
    transition: all 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-hint {
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

/* =============================================
   PAGINATION
   ============================================= */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 18px;
    border-top: 1px solid var(--gray-100);
}

.pagination button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--gray-200);
    background: white;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-600);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pagination button:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* =============================================
   FOOTER SECTION (CTA BUTTONS)
   ============================================= */
.footer-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.footer-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.2s;
}

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

.footer-card-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.footer-card h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
}

.footer-card p {
    font-size: 14px;
    color: var(--gray-500);
    line-height: 1.5;
}

/* =============================================
   DETAIL PANEL (ADMIN)
   ============================================= */
.detail-section {
    margin-bottom: 24px;
}

.detail-section h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.detail-item label {
    font-size: 11px;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    display: block;
}

.detail-item span {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-800);
}

.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--gray-200);
}

.timeline-item {
    position: relative;
    padding-bottom: 18px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid white;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item .tl-status {
    font-weight: 600;
    font-size: 14px;
    color: var(--gray-800);
}

.timeline-item .tl-date {
    font-size: 12px;
    color: var(--gray-400);
}

.timeline-item .tl-obs {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 2px;
}

.file-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

.file-item .file-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    display: flex;
    align-items: center;
    gap: 8px;
}

.file-item .file-actions {
    display: flex;
    gap: 6px;
}

/* =============================================
   TOAST NOTIFICATIONS
   ============================================= */
.toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: white;
    border-radius: var(--radius);
    padding: 14px 20px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--success);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideInRight 0.3s ease;
    font-size: 14px;
    font-weight: 500;
}

.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =============================================
   LOADING SPINNER
   ============================================= */
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.loading-overlay {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
    color: var(--gray-400);
    gap: 12px;
}

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 15px;
}

/* =============================================
   ADMIN BAR
   ============================================= */
.admin-bar {
    background: var(--accent-light);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 12px 18px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
}

/* =============================================
   SITE FOOTER
   ============================================= */
.site-footer {
    text-align: center;
    padding: 24px;
    color: var(--gray-400);
    font-size: 13px;
    border-top: 1px solid var(--gray-200);
    margin-top: 20px;
}

.site-footer a {
    color: var(--primary-light);
    text-decoration: none;
}

/* =============================================
   UF SELECTOR GRID
   ============================================= */
.uf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
}

.uf-check {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.15s;
    background: white;
}

.uf-check:hover {
    border-color: var(--primary-light);
    background: var(--primary-lighter);
}

.uf-check.checked {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.uf-check input[type=checkbox] {
    display: none;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .header-actions {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .filters-bar {
        flex-direction: column;
    }
    
    .filter-group {
        min-width: 100%;
    }
    
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .footer-actions {
        grid-template-columns: 1fr;
    }
    
    table {
        font-size: 13px;
    }
    
    tbody td, thead th {
        padding: 10px 12px;
    }
    
    .modal {
        margin: 10px;
        max-height: 95vh;
    }
    
    .td-hide-mobile { display: none; }
}

@media (max-width: 480px) {
    .main-container { padding: 14px; }
    .stats-bar { grid-template-columns: 1fr 1fr; gap: 8px; }
    .stat-card { padding: 12px; }
    .stat-card .stat-number { font-size: 22px; }
}
