/* ============================================
   ConsultaOK - CSS Moderno v2.0
   ============================================ */

:root {
    --primary: #1a56db;
    --primary-dark: #1342a8;
    --primary-light: #e8effc;
    --accent: #f59e0b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --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;
    --radius: 8px;
    --radius-lg: 12px;
    --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);
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- HEADER ---- */
.header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--gray-900);
    font-size: 20px;
    letter-spacing: -0.5px;
    flex-shrink: 0;
}

.logo-icon {
    color: var(--primary);
    font-size: 24px;
}

.logo-text strong {
    color: var(--primary);
}

.nav {
    display: flex;
    gap: 4px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--gray-600);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.nav-link.active {
    background: var(--primary-light);
    color: var(--primary);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.user-name {
    font-size: 13px;
    color: var(--gray-500);
}

.btn-logout {
    padding: 6px 12px;
    border-radius: var(--radius);
    text-decoration: none;
    font-size: 13px;
    color: var(--danger);
    border: 1px solid var(--gray-200);
    transition: all var(--transition);
}

.btn-logout:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

.mobile-toggle {
    display: none;
    background: none;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 6px 10px;
    font-size: 20px;
    cursor: pointer;
    color: var(--gray-600);
}

/* ---- MAIN ---- */
.main-content {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ---- FOOTER ---- */
.footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    margin-top: auto;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray-400);
}

/* ---- LOGIN ---- */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
}

.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 48px;
    width: 100%;
    max-width: 420px;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.login-card .subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 32px;
}

/* ---- FORMS ---- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--gray-800);
    background: white;
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.form-control::placeholder {
    color: var(--gray-400);
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    border: 1px solid transparent;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: var(--shadow-md);
}

.btn-primary:disabled {
    background: var(--gray-300);
    cursor: not-allowed;
}

.btn-full {
    width: 100%;
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-secondary:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

/* ---- ALERTS ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ---- DASHBOARD CARDS ---- */
.page-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--gray-900);
}

.page-subtitle {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 32px;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-400);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-200);
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition);
    text-decoration: none;
    color: inherit;
    display: block;
}

.card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.card-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.card-icon.green  { background: #d1fae5; color: #059669; }
.card-icon.orange { background: #ffedd5; color: #ea580c; }
.card-icon.purple { background: #ede9fe; color: #7c3aed; }
.card-icon.red    { background: #fee2e2; color: #dc2626; }

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 4px;
}

.card-desc {
    font-size: 13px;
    color: var(--gray-500);
    line-height: 1.5;
}

/* ---- STATS BAR ---- */
.stats-bar {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    flex: 1;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 4px;
}

.stat-value.credito { color: var(--success); }

/* ---- CONSULTATION FORM ---- */
.consulta-container {
    max-width: 700px;
}

.consulta-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 32px;
    box-shadow: var(--shadow-sm);
}

.consulta-card h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--gray-900);
}

.result-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 24px;
}

.result-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

/* Resultado HTML de consultas externas (RedeCheck) */
.result-html-wrap {
    overflow-x: auto;
    max-width: 100%;
    font-size: 13px;
    line-height: 1.5;
}
.result-html-wrap table {
    max-width: 100%;
    font-size: 13px;
}
.result-html-wrap td, .result-html-wrap th {
    padding: 4px 8px;
    word-break: break-word;
}

/* ---- TABLE ---- */
.table-container {
    overflow-x: auto;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    background: var(--gray-50);
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

tbody td {
    padding: 12px 16px;
    font-size: 14px;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
}

tbody tr:hover {
    background: var(--gray-50);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ---- BADGES ---- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger  { background: #fee2e2; color: #991b1b; }

/* ---- LOADING SPINNER ---- */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    display: none;
}

.loading-overlay.active { display: flex; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .header-inner { padding: 0 16px; }

    .nav {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: white;
        border-bottom: 1px solid var(--gray-200);
        flex-direction: column;
        padding: 8px;
        box-shadow: var(--shadow-md);
    }

    .nav.open { display: flex; }

    .mobile-toggle { display: block; }

    .user-info .user-name { display: none; }

    .main-content { padding: 20px 16px; }

    .login-card { padding: 32px 24px; }

    .cards-grid { grid-template-columns: 1fr; }

    .stats-bar { flex-direction: column; }

    .stat-card { text-align: center; }
}
