@import url('https://fonts.googleapis.com/css2?family=Figtree:ital,wght@0,300..900;1,300..900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:wght,FILL@100..700,0..1&display=swap');

html { scrollbar-gutter: stable; }

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

:root {
    --bg-main: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.6);
    --primary: #38bdf8;
    --primary-dim: #0284c7;
    --primary-glow: rgba(56, 189, 248, 0.3);
    --secondary: #10b981;
    --accent: #f472b6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(16px);
    
    /* Utilities for old compatibility */
    --surface-container: rgba(15, 23, 42, 0.5);
    --surface-container-low: rgba(30, 41, 59, 0.4);
    --surface-container-high: rgba(51, 65, 85, 0.5);
    --surface-container-lowest: var(--bg-card);
    --on-surface: var(--text-primary);
    --on-surface-variant: var(--text-secondary);
    --outline-variant: var(--border);
    --on-primary: #fff;
}

.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    display: inline-block; line-height: 1; text-transform: none;
    letter-spacing: normal; word-wrap: normal; white-space: nowrap; direction: ltr;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Figtree', sans-serif;
    margin: 0;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* Glassmorphism Classes (Global) */
.glass-card, .card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5);
}

/* Base Headings & Gradients */
h1, h2, h3 { letter-spacing: -0.025em; font-weight: 700; color: var(--text-primary); }

.text-gradient {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Layout Utilities (Header) */
header.auth-header { padding: 24px 40px; display: flex; justify-content: space-between; align-items: center; z-index: 50; width: 100%; position: absolute;}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: var(--text-primary); text-decoration: none; }
.brand-icon { width: 34px; height: 34px; background: var(--primary); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--on-primary); }
.header-action { display: flex; align-items: center; gap: 12px; }
.header-action span { color: var(--text-secondary); font-size: 14px; font-weight: 500; }
.header-action a { font-size: 14px; font-weight: 700; color: var(--primary); text-decoration: none; padding: 8px 18px; border-radius: 10px; transition: background 0.2s; }
.header-action a:hover { background: var(--primary-glow); }

/* Layout Utilities (Main & Card Grid) */
main.auth-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 100px 16px 60px; }
.card { width: 100%; max-width: 900px; display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; }

.panel-left {
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.8), rgba(30, 41, 59, 0.9));
    padding: 48px; border-right: 1px solid var(--border); display: flex; flex-direction: column; justify-content: space-between;
}
.panel-left h1 span { color: var(--primary); }
.panel-left p { color: var(--text-secondary); font-size: 15px; line-height: 1.7; max-width: 280px; }
.panel-right { padding: 48px 52px; display: flex; flex-direction: column; justify-content: center; }

/* Form Elements mapped for compatibility */
.form-header h2 { font-size: 28px; margin-bottom: 6px; }
.form-header p { font-size: 14px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 36px; }
.field { margin-bottom: 20px; }
.field-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 8px; }
.field-label-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.forgot-link { font-size: 12px; font-weight: 700; color: var(--primary); text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

.input-wrap { position: relative; }
.input-wrap .icon-left { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 20px; pointer-events: none; }
.input-wrap .icon-right { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-secondary); font-size: 20px; cursor: pointer; background: none; border: none; padding: 0; }
.input-wrap .icon-right:hover { color: var(--text-primary); }

.input-wrap input, .input-premium {
    width: 100%; padding: 14px 44px;
    background: var(--surface-container);
    border: 1px solid var(--border); border-radius: 12px;
    font-size: 14px; font-family: 'Figtree', sans-serif; color: var(--text-primary);
    transition: all 0.2s ease; outline: none;
}
.input-wrap input::placeholder, .input-premium::placeholder { color: var(--border); }
.input-wrap input:focus, .input-premium:focus { background: var(--bg-main); border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-glow); }

.btn-primary, .btn-premium {
    width: 100%; padding: 15px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dim));
    color: #fff; border: none; border-radius: 12px;
    font-family: 'Figtree', sans-serif; font-size: 15px; font-weight: 800;
    cursor: pointer; transition: all 0.2s; box-shadow: 0 4px 15px var(--primary-glow); margin-top: 8px;
}
.btn-primary:hover, .btn-premium:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--primary-glow); }
.btn-primary:active, .btn-premium:active { transform: scale(0.98); }

.divider { display: flex; align-items: center; gap: 12px; margin: 24px 0; }
.divider-line { flex: 1; height: 1px; background: var(--border); }
.divider span { font-size: 10px; font-weight: 700; letter-spacing: 0.1em; color: var(--text-secondary); }

.social-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-social { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 12px; background: var(--surface-container-low); border: 1px solid var(--border); border-radius: 12px; font-size: 14px; color: var(--text-primary); cursor: pointer; transition: background 0.2s; }
.btn-social:hover { background: var(--surface-container-high); }

.remember-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.remember-row input[type="checkbox"] { width: 18px; height: 18px; border-radius: 4px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.remember-row label { font-size: 14px; color: var(--text-secondary); cursor: pointer; user-select: none; }

/* -----------------------------
   MODERN ALERTS (Glassmorphism)
   ----------------------------- */
.alert {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: 14px;
    margin-bottom: 28px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    animation: alertSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    backdrop-filter: blur(10px);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.1);
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.1);
}

.alert-icon {
    font-size: 22px !important;
    flex-shrink: 0;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateY(-12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

footer { padding: 24px 40px; display: flex; justify-content: space-between; align-items: center; gap: 16px; width: 100%; margin-top: auto; }
footer p, .footer-links a { font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-secondary); text-decoration: none; transition: color 0.2s; }
.footer-links { display: flex; gap: 20px; }
.footer-links a:hover { color: var(--primary); }

@media (max-width: 720px) {
    header.auth-header { padding: 16px 20px; position: relative; }
    footer { padding: 16px 20px; position: relative; flex-direction: column; text-align: center; }
    main.auth-main { padding: 40px 16px; }
    .header-action span, .header-action a, .panel-left { display: none; }
    .card { grid-template-columns: 1fr; border-radius: 24px; }
    .panel-right { padding: 36px 24px; }
}

/* -------------------------------------------------------------
   UPLOAD / DOCUMENT COMPONENTS 
   ------------------------------------------------------------- */
.progress-card {
    background: var(--bg-card); backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border); border-radius: 24px; padding: 32px; box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.5); margin-bottom: 40px;
}
.progress-title { font-weight: 600; font-size: 16px; margin-bottom: 8px; display: flex; justify-content: space-between; color: var(--text-primary); }
.progress-text { color: var(--primary); font-weight: 700; }
.progress-bar-bg { background: var(--surface-container); height: 12px; border-radius: 6px; overflow: hidden; margin-top: 16px; }
.progress-bar-fill { background: linear-gradient(135deg, var(--primary), var(--secondary)); height: 100%; border-radius: 6px; transition: width 0.5s ease; }

.documents-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; }

.doc-card {
    background: var(--surface-container); border-radius: 20px; padding: 24px; display: flex; flex-direction: column; height: 100%; min-height: 400px; position: relative; transition: all 0.3s ease; border: 1px solid var(--border);
}
.doc-card.pending { border: 2px dashed var(--text-secondary); opacity: 0.8; }
.doc-card.pending:hover { border-color: var(--primary); opacity: 1; background: var(--surface-container-low); }
.doc-card.uploaded { background: rgba(16, 185, 129, 0.05); border: 2px solid var(--secondary); }
.doc-card.rejected { background: rgba(239, 68, 68, 0.05); border: 2px solid #ef4444; }

.card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.icon-box { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; margin-bottom: 16px; background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.doc-card.uploaded .icon-box { background: rgba(16, 185, 129, 0.15); color: var(--secondary); }
.doc-card.rejected .icon-box { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.check-icon { color: var(--secondary); font-size: 24px; display: none; }
.doc-card.uploaded .check-icon { display: block; }
.doc-title { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 8px; }
.doc-desc { font-size: 14px; color: var(--text-secondary); line-height: 1.4; flex-grow: 1; }

.upload-zone { margin-top: 24px; border-radius: 12px; flex-grow: 0; }
.drop-area { background: var(--bg-main); border: 1px dashed var(--text-secondary); border-radius: 12px; padding: 32px 20px; text-align: center; margin-bottom: 16px; cursor: pointer; transition: all 0.2s; }
.drop-area:hover { border-color: var(--primary); background: rgba(56, 189, 248, 0.05); }

.btn-select { width: 100%; background: var(--surface-container-high); color: var(--primary); font-weight: 600; font-family: 'Figtree', sans-serif; padding: 14px; border-radius: 10px; border: none; cursor: pointer; font-size: 15px; transition: background 0.2s; }
.btn-select:hover { background: rgba(56, 189, 248, 0.15); }

.file-preview { background: var(--bg-main); border-radius: 10px; padding: 16px; display: flex; align-items: center; gap: 12px; margin-top: auto; border: 1px solid var(--secondary); }
.file-icon-small { color: var(--text-secondary); font-size: 20px; }
.file-name { font-size: 14px; font-weight: 500; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.upload-status { font-size: 12px; font-weight: 700; color: var(--secondary); margin-left: auto; text-transform: uppercase; }

.btn-remove { width: 100%; font-family: 'Figtree', sans-serif; background: transparent; color: #ef4444; font-weight: 600; padding: 12px; border: none; cursor: pointer; margin-top: 12px; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-remove:hover { background: rgba(239, 68, 68, 0.1); border-radius: 8px; }

.doc-card::after { content: 'Soltar aquí'; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15, 23, 42, 0.9); color: var(--text-primary); display: flex; align-items: center; justify-content: center; font-size: 24px; font-weight: 700; border-radius: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s; z-index: 10; }
.doc-card.dragging::after { opacity: 1; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 28px; font-weight: 700; margin-bottom: 8px; color: var(--text-primary); }
.page-header p { color: var(--text-secondary); font-size: 14px; max-width: 600px; line-height: 1.4; }
.container { max-width: 1200px; margin: 0 auto; }
/* -------------------------------------------------------------
   MOBILE OPTIMIZATIONS & UTILITIES
   ------------------------------------------------------------- */
.hide-mobile { display: block; }
.show-mobile { display: none; }

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
    
    .page-header { margin-bottom: 16px !important; }
    .page-header h1 { font-size: 24px !important; }
    
    .filters-section { margin-bottom: 16px !important; }
    .filter-trigger { padding: 10px 16px !important; }
    .btn-new { padding: 10px 16px !important; font-size: 14px !important; }
    
    /* SSM-Style Premium Cards */
    .modern-card {
        background: var(--bg-card);
        backdrop-filter: var(--glass-blur);
        -webkit-backdrop-filter: var(--glass-blur);
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 12px 16px;
        position: relative;
        overflow: hidden;
        transition: transform 0.2s, box-shadow 0.2s;
        display: flex;
        flex-direction: column;
    }
    .modern-card::before {
        content: '';
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 6px;
        background: var(--primary);
    }
    .modern-card.card-physical::before { background: #38bdf8; } /* Azul Celeste */
    .modern-card.card-moral::before { background: #10b981; }    /* Esmeralda */
    .modern-card.card-company::before { background: #a855f7; }  /* Púrpura */
    
    /* Status-based Accents for Expedientes */
    .modern-card.card-reviewing::before { background: #38bdf8; }
    .modern-card.card-pending::before { background: #fbbf24; }
    .modern-card.card-completed::before { background: #10b981; }
    .modern-card.card-stalled::before { background: #f87171; }

    .card-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 8px;
        gap: 12px;
    }
    .card-title-group {
        display: flex;
        flex-direction: column;
        gap: 2px;
    }
    .card-title {
        font-size: 16px;
        font-weight: 700;
        color: white;
        text-decoration: none;
    }
    .card-subtitle {
        font-size: 12px;
        color: var(--text-secondary);
        font-weight: 500;
    }
    .card-right-value {
        text-align: right;
        flex-shrink: 0;
        white-space: nowrap;
    }
    .value-main {
        font-size: 18px;
        font-weight: 800;
        color: white;
        display: block;
    }
    .value-sub {
        font-size: 10px;
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }
    .card-body {
        margin-bottom: 12px;
    }
    .card-tags {
        display: flex;
        gap: 8px;
        margin-bottom: 10px;
    }
    .card-tag {
        font-size: 10px;
        font-weight: 700;
        padding: 4px 8px;
        border-radius: 6px;
        background: rgba(255, 255, 255, 0.05);
        color: var(--text-secondary);
        text-transform: uppercase;
    }
    .card-info-item {
        font-size: 12px;
        color: var(--text-secondary);
        margin-top: 2px;
    }
    .card-footer {
        display: flex;
        justify-content: flex-end;
        gap: 20px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, 0.05);
        margin-top: 4px;
    }
    .card-footer-action {
        font-size: 12px;
        font-weight: 800;
        color: var(--primary);
        text-decoration: none;
        letter-spacing: 0.05em;
        background: none;
        border: none;
        padding: 0;
        cursor: pointer;
    }
    .card-footer-action.danger { color: #ef4444; }

    /* Hide table on mobile if needed, but we replace render logic */
    .responsive-card-table { width: 100%; border-collapse: collapse; }

    /* Circular Icon Buttons */
    .btn-icon-mobile {
        padding: 10px 16px !important;
        border-radius: 12px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: auto !important;
        height: auto !important;
        min-width: 44px !important;
    }
    .btn-icon-mobile span:not(.material-symbols-outlined) {
        display: none;
    }
    .btn-icon-mobile .material-symbols-outlined {
        margin: 0 !important;
        font-size: 22px !important;
    }
}
