/* ==========================================================================
   HAMVAS PORTAL & DASHBOARD REDESIGN (Mobile-First Expert)
   ========================================================================== */

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --bottom-nav-height: 70px;
    
    /* Premium Glass Tokens */
    --glass-bg: rgba(0, 5, 0, 0.7);
    --glass-border: rgba(237, 247, 246, 0.1);
    --glass-blur: 20px;
    
    /* Animation Tokens */
    --ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --trans-premium: all 0.5s var(--ease-premium);
    
    /* Login Specific */
    --login-card-width: 440px;
    
    /* Brand Colors RGB (for transparency) */
    --color-primary-rgb: 247, 181, 56;
    --color-black-rgb: 0, 5, 0;
    --color-white-rgb: 237, 247, 246;
}

/* ─── Base Layout ───────────────────────────────────────────────────────── */
body {
    background-color: var(--color-black);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
}

.portal-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ─── Sidebar (Desktop Only) ─────────────────────────────────────────────── */
.sidebar {
    display: none; /* Mobile first: hidden */
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border-right: 1px solid var(--glass-border);
    padding: 2rem 1.5rem;
    flex-direction: column;
    z-index: 1000;
    transition: var(--trans-premium);
}

/* Sidebar Mobile State */
@media (max-width: 1023px) {
    .sidebar {
        display: flex;
        transform: translateX(-100%);
    }
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 60px rgba(0, 0, 0, 0.8);
    }
    
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        visibility: hidden;
        z-index: 950;
        transition: var(--trans-premium);
    }
    
    .sidebar-overlay.active {
        opacity: 1;
        visibility: visible;
    }
}

@media (min-width: 1024px) {
    .sidebar {
        display: flex;
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

.sidebar-logo {
    margin-bottom: 3.5rem;
    padding-left: 0.5rem;
    display: flex;
    align-items: center;
}

.sidebar-logo img {
    max-width: 180px;
    height: auto !important;
    filter: drop-shadow(0 0 12px rgba(var(--color-primary-rgb), 0.4));
    transition: var(--trans-premium);
}

.sidebar-logo img:hover {
    filter: drop-shadow(0 0 20px rgba(var(--color-primary-rgb), 0.6));
    transform: scale(1.02);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--trans-premium);
    position: relative;
}

.nav-link i {
    width: 20px;
    height: 20px;
}

.nav-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-link.active {
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    left: -1.5rem;
    top: 20%;
    bottom: 20%;
    width: 4px;
    background: var(--color-primary);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 15px var(--color-primary);
}

/* ─── Header (Mobile + Desktop) ─────────────────────────────────────────── */
.portal-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    background: rgba(var(--color-black-rgb), 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
    z-index: 900;
}

/* ─── Menu Toggle (Mobile) ──────────────────────────────────────────────── */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--trans-premium);
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (min-width: 1024px) {
    .menu-toggle {
        display: none;
    }
}

.header-title h1 {
    font-size: 1.25rem;
    margin: 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ─── Main Content ──────────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding: 1.5rem;
    padding-bottom: calc(var(--bottom-nav-height) + 2rem); /* Space for mobile nav */
    max-width: 100vw;
}

@media (min-width: 768px) {
    .main-content {
        padding: 2.5rem;
    }
}

/* ─── Bento Grid System ─────────────────────────────────────────────────── */
.bento-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .col-span-2 { grid-column: span 2; }
}

@media (min-width: 1280px) {
    .bento-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .xl-span-2 { grid-column: span 2; }
    .xl-span-3 { grid-column: span 3; }
    .xl-span-4 { grid-column: span 4; }
}

.bento-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-2xl);
    padding: 1.75rem;
    transition: var(--trans-premium);
    position: relative;
    overflow: hidden;
}

.bento-card:hover {
    border-color: rgba(var(--color-primary-rgb), 0.3);
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.bento-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top left, rgba(255, 255, 255, 0.03), transparent);
    pointer-events: none;
}

/* ─── Stats & Metrics ───────────────────────────────────────────────────── */
.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stat-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    font-weight: 600;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 900;
    line-height: 1;
    font-family: var(--font-heading);
}

/* ─── Tables (Mobile Responsive) ───────────────────────────────────────── */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.premium-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.5rem;
}

.premium-table th {
    text-align: left;
    padding: 1rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 700;
}

.premium-table td {
    padding: 1.25rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.premium-table td:first-child {
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.premium-table td:last-child {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

/* ─── Bottom Navigation (Mobile Only) ───────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 3rem);
    max-width: 400px;
    height: var(--bottom-nav-height);
    background: rgba(0, 5, 0, 0.6);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 100px;
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 0 0.75rem;
    z-index: 1000;
    box-shadow: 
        0 10px 30px rgba(0, 0, 0, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    animation: slideUpNav 0.8s var(--ease-premium);
}

@keyframes slideUpNav {
    from { transform: translateX(-50%) translateY(100px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@media (min-width: 1024px) {
    .bottom-nav {
        display: none;
    }
}

.bottom-nav-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    color: var(--text-secondary);
    transition: var(--trans-premium);
    position: relative;
}

.bottom-nav-link i {
    width: 24px;
    height: 24px;
}

.bottom-nav-link span {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.bottom-nav-link.active {
    color: var(--color-primary);
}

.bottom-nav-link.active i {
    transform: translateY(-2px);
    filter: drop-shadow(0 0 8px rgba(var(--color-primary-rgb), 0.5));
}

.bottom-nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    width: 4px;
    height: 4px;
    background: var(--color-primary);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--color-primary);
}

/* ─── Progress & Badges ─────────────────────────────────────────────────── */
.premium-progress {
    height: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.premium-progress-fill {
    height: 100%;
    background: var(--brand-gradient);
    box-shadow: 0 0 15px rgba(var(--color-primary-rgb), 0.5);
    transition: width 1s var(--ease-premium);
}

.badge {
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.badge-success {
    background: rgba(46, 204, 113, 0.1);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.2);
}

/* ─── Utilities ─────────────────────────────────────────────────────────── */
.text-gradient {
    background: var(--brand-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ambient-blob {
    position: fixed;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle, rgba(var(--color-primary-rgb), 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
    filter: blur(80px);
}

.blob-1 { top: -10%; right: -10%; }
.blob-2 { bottom: -10%; left: -10%; }

/* ─── Login Specific ────────────────────────────────────────────────────── */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: radial-gradient(circle at 50% 50%, var(--color-black), #000);
}

.login-card-premium {
    width: 100%;
    max-width: var(--login-card-width);
    position: relative;
    overflow: visible;
}

.login-card-premium::after {
    content: '';
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, rgba(255,255,255,0.1), transparent, rgba(255,255,255,0.05));
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
}

.login-title {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: var(--type-body-sm);
    color: var(--text-tertiary);
    margin-bottom: 2.5rem;
}

.form-group-premium {
    margin-bottom: 1.25rem;
    text-align: left;
}

.form-group-premium label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}

.input-wrapper-premium {
    position: relative;
}

.input-wrapper-premium i,
.input-wrapper-premium svg {
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-primary);
    pointer-events: none;
    z-index: 10;
    transition: var(--trans-premium);
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-wrapper-premium i + textarea,
.input-wrapper-premium svg + textarea {
    padding-top: 1.25rem;
}

.input-wrapper-premium:has(textarea) i,
.input-wrapper-premium:has(textarea) svg {
    top: 1.25rem;
    transform: none;
}

.form-input-premium {
    display: block;
    width: 100%;
    margin: 0;
    background: rgba(10, 10, 10, 0.9) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: var(--radius-lg);
    padding: 0.875rem 1.25rem 0.875rem 3.5rem;
    color: #FFFFFF !important;
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.5;
    transition: var(--trans-premium);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
    box-sizing: border-box;
}

textarea.form-input-premium {
    min-height: 120px;
    padding-top: 1.1rem;
    padding-left: 3.5rem;
    resize: vertical;
}

select.form-input-premium {
    color-scheme: dark !important;
    appearance: none;
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23F7B538' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.25rem center;
    background-size: 1em;
    padding-right: 3.5rem;
}

select.form-input-premium option {
    background-color: #0a0a0a !important;
    color: #FFFFFF !important;
    padding: 1.25rem;
    font-family: inherit;
}

/* Fix para navegadores que ignoran background-color en option */
select.form-input-premium:focus,
select.form-input-premium:active {
    background-color: #0a0a0a !important;
}

.form-input-premium:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.07) !important;
    border-color: var(--color-primary) !important;
    box-shadow: 
        0 0 0 4px rgba(var(--color-primary-rgb), 0.15),
        0 20px 40px -10px rgba(0, 0, 0, 0.6);
    transform: translateY(-2px);
}

.form-input-premium::placeholder {
    color: rgba(255, 255, 255, 0.3);
    font-weight: 400;
}

/* Fix Chrome Autofill Background and Text Color */
.form-input-premium:-webkit-autofill,
.form-input-premium:-webkit-autofill:hover, 
.form-input-premium:-webkit-autofill:focus, 
.form-input-premium:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 100px #0a0a0a inset !important;
    -webkit-text-fill-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}

.btn-premium {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-width: 200px;
    height: 3.5rem;
    background: var(--brand-gradient);
    color: #FFFFFF !important;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0 2rem;
    font-size: 0.85rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: var(--trans-premium);
    box-shadow: 0 10px 30px -5px rgba(var(--color-primary-rgb), 0.3);
    position: relative;
    overflow: hidden;
}

.btn-premium::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.btn-premium i, 
.btn-premium svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-premium:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 40px rgba(var(--color-primary-rgb), 0.4);
    filter: brightness(1.1);
}

.btn-premium:hover::after {
    transform: translateX(100%);
}

.btn-premium:active {
    transform: translateY(0);
}

.btn-secondary-premium {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
    min-width: 140px;
}

.btn-secondary-premium:hover, .btn-secondary-premium:focus {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255, 255, 255, 0.2) !important;
    transform: translateY(-2px);
    color: var(--text-primary) !important;
}

.back-link-premium {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    color: var(--text-tertiary);
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--trans-premium);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-full);
}

.back-link-premium:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    transform: translateX(-4px);
}

/* Helper Utilities */
.text-gold { color: var(--color-primary); }
.accent-gold { accent-color: var(--color-primary); }
.w-100 { width: 100%; }
.mt-8 { margin-top: 2rem; }
.text-center { text-align: center; }
.mb-6 { margin-bottom: 1.5rem; }
.items-center { align-items: center; }
.flex { display: flex; }
.gap-2 { gap: 0.5rem; }
.cursor-pointer { cursor: pointer; }

/* ─── Mobile Form & Modal Optimizations ─────────────────────────────────────── */

/* Disable hover transformations for specific panels (e.g. registration form) */
.no-hover:hover {
    transform: none !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
    background: var(--color-black) !important;
}

/* Also disable hover effects on internal cards if parent is no-hover */
.no-hover .form-section-card:hover {
    transform: none !important;
    background: rgba(255, 255, 255, 0.02) !important;
    border-color: rgba(255, 255, 255, 0.05) !important;
    box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.2) !important;
}

/* Mobile-first approach for the registration grid */
.registration-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .registration-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 2rem;
    }
}


.form-section-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.25rem; /* Reducido para mejor flujo */
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 24px -1px rgba(0, 0, 0, 0.3);
}

/* No hover effects on mobile, subtle lift on desktop */
@media (min-width: 1024px) {
    .form-section-card:hover {
        background: rgba(255, 255, 255, 0.04);
        border-color: rgba(255, 255, 255, 0.1);
        transform: translateY(-2px);
        box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.4);
    }
}

.form-section-card:focus-within {
    border-color: rgba(var(--color-primary-rgb), 0.4);
    background: rgba(255, 255, 255, 0.04);
    box-shadow: 0 0 0 4px rgba(var(--color-primary-rgb), 0.05);
}

.section-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-primary);
    background: rgba(var(--color-primary-rgb), 0.1);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    width: fit-content;
    margin-bottom: 0.25rem;
}

.section-badge i {
    width: 14px;
    height: 14px;
}

.form-grid-inner {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 480px) {
    .form-grid-inner {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-group-premium {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0; /* Let gap of parent handle it */
}

.context-alert {
    background: rgba(var(--color-primary-rgb), 0.05);
    border-left: 3px solid var(--color-primary);
    padding: 0.875rem 1rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}

.context-alert i {
    width: 18px;
    color: var(--color-primary);
    flex-shrink: 0;
    margin-top: 0.2rem;
}

.context-alert p {
    font-size: 0.8rem;
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.4;
}

.modal-actions {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.level-indicator {
    display: flex;
    flex-direction: column;
}

.level-value {
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--color-primary);
    line-height: 1;
}

/* ─── Info Modal Display Items ────────────────────────────────────────── */
.info-item-premium {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-item-premium label {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
}

.info-item-premium span {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.info-item-premium p {
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ─── Premium UI Elements ────────────────────────────────────────────── */
.badge-premium {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.btn-close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s var(--ease-premium);
}

.btn-close-modal:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

/* ─── Modals (Bento Styled) ─────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    opacity: 0;
    transition: opacity 0.4s var(--ease-premium);
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    box-shadow: 0 40px 100px rgba(0, 0, 0, 0.9);
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    flex-direction: column;
    color-scheme: dark; /* Force dark context for all children including dropdowns */
}

.modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0; /* Critical for inner scrolling */
    overflow: hidden; 
}

.modal-body {
    padding: 2.5rem;
    flex: 1;
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: var(--color-primary) transparent;
    padding-bottom: 3rem; /* Extra space at bottom */
    -webkit-overflow-scrolling: touch;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 10px;
}

.modal-footer-premium {
    background: #0a0a0a;
    padding: 1.25rem 2.5rem;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    position: sticky;
    bottom: 0;
    z-index: 110;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    margin-top: auto;
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--color-primary);
    border-radius: 10px;
}

.modal-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Modal and Form Refinements for Mobile */
@media (max-width: 768px) {
    .modal-overlay {
        padding: 0;
        align-items: flex-end; 
    }
    
    .modal-content {
        max-height: 94vh; 
        height: auto;
        border-radius: 2rem 2rem 0 0;
        border: none;
    }

    .modal-body {
        padding: 1.5rem;
        padding-bottom: 2rem; 
    }

    .modal-footer-premium {
        flex-direction: column-reverse;
        align-items: stretch !important;
        padding: 1.25rem 1.5rem 2.5rem !important; 
        gap: 0.75rem;
    }
    
    .btn-premium {
        width: 100% !important;
        min-width: 0 !important;
        justify-content: center !important;
    }
    
    .level-indicator {
        text-align: center;
        background: rgba(255,255,255,0.03);
        padding: 0.75rem;
        border-radius: var(--radius-lg);
    }
}

.btn-full-mobile {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    min-width: 220px;
}

/* ─── UI-UX PRO MAX: Advanced Mobile Responsive Optimizations ─── */
@media (max-width: 768px) {
    /* 1. Transform tables into premium stacked card components on mobile */
    .premium-table, 
    .premium-table thead, 
    .premium-table tbody, 
    .premium-table th, 
    .premium-table td, 
    .premium-table tr {
        display: block !important;
    }
    
    .premium-table thead {
        display: none !important;
    }
    
    .premium-table tr {
        background: rgba(255, 255, 255, 0.02) !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        border-radius: var(--radius-xl) !important;
        padding: 1.25rem !important;
        margin-bottom: 1.25rem !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2) !important;
        transition: var(--trans-premium) !important;
        position: relative !important;
        
        /* Layout Grid for internal fields */
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    .premium-table tr:hover {
        border-color: rgba(var(--color-primary-rgb), 0.2) !important;
        transform: translateY(-2px) !important;
    }
    
    .premium-table td {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        border: none !important;
        border-radius: 0 !important;
        background: transparent !important;
        font-size: 0.9rem !important;
        text-align: left !important;
        gap: 0.25rem !important;
    }
    
    /* Remove borders between cells since we use grid layout now */
    .premium-table td:not(:last-child) {
        border-bottom: none !important;
    }
    
    /* Auto generate labels above cells */
    .premium-table td::before {
        content: attr(data-label) !important;
        font-size: 0.65rem !important;
        text-transform: uppercase !important;
        font-weight: 700 !important;
        color: var(--text-tertiary) !important;
        letter-spacing: 0.05em !important;
        opacity: 0.7 !important;
        display: block !important;
        margin-bottom: 0px !important;
    }
    
    /* Primary header fields in the card: make them full width and distinct */
    .premium-table td[data-label="Alumno"],
    .premium-table td[data-label="Nombre"] {
        grid-column: span 2 !important;
        font-size: 1.05rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
        padding-bottom: 0.5rem !important;
        margin-bottom: 0.25rem !important;
    }
    
    /* Hide label for Name/Alumno since it's visually obvious */
    .premium-table td[data-label="Alumno"]::before,
    .premium-table td[data-label="Nombre"]::before {
        display: none !important;
    }
    
    /* Date fields: position nicely in top-right corner of the card */
    .premium-table td[data-label="Fecha"],
    .premium-table td[data-label="Registro"] {
        position: absolute !important;
        top: 1.25rem !important;
        right: 1.25rem !important;
        width: auto !important;
        font-size: 0.75rem !important;
        align-items: flex-end !important;
    }
    .premium-table td[data-label="Fecha"]::before,
    .premium-table td[data-label="Registro"]::before {
        display: none !important; /* hide label to keep it clean */
    }
    
    /* Long multi-line contact fields should span full width */
    .premium-table td[data-label="Contacto"],
    .premium-table td[data-label="Credenciales"] {
        grid-column: span 2 !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* Status, Level and numbers: side-by-side columns */
    .premium-table td[data-label="Interés"],
    .premium-table td[data-label="Nivel"],
    .premium-table td[data-label="Asistencia"] {
        grid-column: span 1 !important;
    }
    
    /* Action buttons block at bottom: full width */
    .premium-table td[data-label="Acciones"] {
        grid-column: span 2 !important;
        margin-top: 0.5rem !important;
        padding-top: 0.75rem !important;
        border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
        flex-direction: row !important;
        justify-content: stretch !important;
        align-items: center !important;
    }
    
    .premium-table td[data-label="Acciones"]::before {
        display: none !important; /* hide actions label */
    }
    
    .premium-table td[data-label="Acciones"] .liquid-glass-rounded {
        display: flex !important;
        width: 100% !important;
        gap: 0.5rem !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
    }
    
    .premium-table td[data-label="Acciones"] .btn,
    .premium-table td[data-label="Acciones"] a {
        flex: 1 !important;
        width: 100% !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
        padding: 0.5rem 1rem !important;
        height: auto !important;
    }
    
    /* Fix for converted students read-only actions badge alignment */
    .premium-table td[data-label="Acciones"] span {
        margin: 0 auto !important;
    }
    
    /* Divider row for converted leads */
    .premium-table tr:has(td[colspan="5"]) {
        display: block !important;
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        padding: 0.5rem 0 !important;
        margin-bottom: 0.5rem !important;
    }
    
    .premium-table td[colspan="5"] {
        display: block !important;
        text-align: center !important;
        color: var(--color-primary) !important;
        font-weight: 700 !important;
        font-size: 0.75rem !important;
    }

    /* 2. Compact header and section spacing */
    .portal-header {
        padding: 0 1rem !important;
        height: 60px !important;
    }
    
    .header-title h1 {
        font-size: 1.1rem !important;
    }
    
    .section-header {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 1rem !important;
        margin-bottom: 1.5rem !important;
    }
    
    .section-header > button,
    .section-header > a,
    .section-header .btn {
        width: 100% !important;
        justify-content: center !important;
        display: inline-flex !important;
    }
    
    .bento-card {
        padding: 1.25rem !important;
        border-radius: var(--radius-xl) !important;
    }
    
    .bento-grid {
        gap: 1rem !important;
    }
    
    /* Scale down the charts vertical space on mobile */
    .bento-card[style*="min-height: 400px"] {
        min-height: 320px !important;
    }
    .bento-card[style*="min-height: 400px"] > div[style*="height: 300px"] {
        height: 220px !important;
    }
    
    /* 3. Drag handle indicator at top of mobile modals */
    .modal-content::before {
        content: '' !important;
        display: block !important;
        width: 40px !important;
        height: 4px !important;
        background: rgba(255, 255, 255, 0.2) !important;
        border-radius: 2px !important;
        margin: 0.75rem auto 0 !important;
        z-index: 1000 !important;
        position: absolute !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
    }
    
    .modal-content header {
        padding: 1.25rem !important;
        padding-top: 2.25rem !important; /* leaves space for the drag handle */
        gap: 1rem !important;
    }
    
    .modal-content header div[style*="width: 60px"] {
        width: 45px !important;
        height: 45px !important;
        border-radius: var(--radius-md) !important;
    }
    
    .modal-content header h2 {
        font-size: 1.35rem !important;
    }
    
    .modal-content header p {
        font-size: 0.75rem !important;
    }

    .modal-body {
        padding: 1.15rem !important;
        padding-bottom: 2rem !important;
    }

    .modal-footer-premium {
        flex-direction: column-reverse !important;
        align-items: stretch !important;
        padding: 1.25rem 1.15rem 2.5rem !important; 
        gap: 0.75rem !important;
    }
    
    /* Form input layout and icon size adjustments */
    .form-input-premium {
        padding: 0.75rem 1rem 0.75rem 2.75rem !important;
        font-size: 0.9rem !important;
    }
    .input-wrapper-premium i,
    .input-wrapper-premium svg {
        left: 1rem !important;
        width: 16px !important;
        height: 16px !important;
    }
    
    .form-section-card {
        padding: 1.15rem !important;
        gap: 1rem !important;
        border-radius: var(--radius-lg) !important;
    }
    
    .registration-grid {
        gap: 1rem !important;
    }

    .main-content {
        padding: 1rem !important;
        padding-bottom: calc(var(--bottom-nav-height) + 1rem) !important;
    }
    
    .crm-section {
        margin-top: 0.5rem !important;
    }
}
