/* ==========================================================================
   1. VARIABLES GLOBALES Y TOKENS (UI KIT)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Manrope:wght@600;700&display=swap');

:root {
    /* Fondos y Superficies (Light Theme) */
    --cheisca-white: #FFFFFF;
    --cheisca-smoke: #F7F7F5;
    
    /* Tipografía Base */
    --cheisca-black: #151515;
    
    /* Colores de Acento de Marca */
    --cheisca-gold: #D4AF37;
    --cheisca-orange: #F28C28;
    --cheisca-blue: #3B82F6;
    --cheisca-purple: #7C4DFF;
    
    /* UI Elements */
    --cheisca-border: #E5E5E5;
    
    /* Tipografía */
    --font-heading: 'Manrope', sans-serif;
    --font-body: 'Inter', sans-serif;
    
    /* Bordes */
    --radius-btn: 12px;
    --radius-input: 14px;
    --radius-card: 20px;
    --radius-dialog: 24px;
    --radius-avatar: 50%;
    
    /* Elevaciones */
    --shadow-soft: 0 4px 12px rgba(21, 21, 21, 0.03), 0 1px 2px rgba(21, 21, 21, 0.04);
    --shadow-hover: 0 12px 24px rgba(21, 21, 21, 0.06), 0 4px 8px rgba(21, 21, 21, 0.04);
    
    /* Transiciones (Asignada dinámicamente según tu base original) */
    --trans-fast: 0.2s ease;
}

/* ==========================================================================
   2. RESETEO Y BASE
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--cheisca-smoke);
    color: var(--cheisca-black);
    font-family: var(--font-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

a { 
    text-decoration: none; 
    color: inherit; 
    transition: var(--trans-fast); 
}

.hidden { display: none !important; }

/* ==========================================================================
   3. ANIMACIONES GLOBALES
   ========================================================================== */
@keyframes fadeIn { 
    from { opacity: 0; transform: translateY(10px); } 
    to { opacity: 1; transform: translateY(0); } 
}

@keyframes skeletonLoading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

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

/* ==========================================================================
   4. LAYOUTS Y CONTENEDORES ADAPTATIVOS
   ========================================================================== */
.main-content-wrapper {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.iam-auth-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.iam-container { 
    width: 100%; 
    max-width: 100%; 
    text-align: center; 
}

.wide-box {
    width: 100%;
    max-width: 520px;
    margin: 0 auto;
    animation: fadeIn 0.5s ease-out;
    padding: 16px;
    transition: all 0.3s ease;
}

/* ==========================================================================
   5. COMPONENTES DE UI (JOINS Y AGRUPACIONES)
   ========================================================================== */

/* --- 5.1 Tarjetas (Cards) --- */
.auth-box {
    background: var(--cheisca-white);
    padding: 24px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--cheisca-border);
    text-align: left;
    transition: box-shadow 0.3s ease;
}

/* --- 5.2 Tipografía de Encabezados --- */
.brand-logo { 
    display: flex; align-items: center; gap: 12px; 
    font-family: var(--font-heading); font-size: 22px; font-weight: 800; 
}
.iam-header { margin-bottom: 24px; text-align: center; }
.iam-title {
    font-family: var(--font-heading); font-size: 1.75rem; font-weight: 700;
    margin-bottom: 8px; color: var(--cheisca-black); letter-spacing: -0.02em;
}
.iam-subtitle { font-size: 0.95rem; color: var(--cheisca-black); opacity: 0.6; line-height: 1.6; }

.text-glow-blue { color: var(--cheisca-blue); text-decoration: none; font-weight: 600; transition: opacity 0.2s ease; }
.text-glow-blue:hover { opacity: 0.8; }

/* --- 5.3 Elementos de Formulario Base --- */
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.input-group { display: flex; flex-direction: column; gap: 8px; }
.input-group label { font-size: 0.875rem; color: var(--cheisca-black); font-weight: 500; opacity: 0.8; }

/* Unificación de Inputs, Selects y Textareas */
.input-group input, 
select, .select-premium, 
textarea, .textarea-premium {
    background-color: var(--cheisca-white);
    border: 1px solid var(--cheisca-border);
    color: var(--cheisca-black);
    padding: 14px 16px;
    border-radius: var(--radius-input);
    font-family: var(--font-body);
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input:focus, 
select:focus, .select-premium:focus, 
textarea:focus, .textarea-premium:focus {
    border-color: var(--cheisca-blue) !important;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1) !important;
}

/* Modificadores Específicos */
select, .select-premium {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23151515' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 40px !important;
    cursor: pointer;
}

textarea, .textarea-premium {
    resize: vertical;
    min-height: 100px;
}

/* Buscador Premium */
.search-container-premium {
    display: flex; align-items: center; gap: 12px;
    background-color: var(--cheisca-white);
    border: 1.5px solid var(--cheisca-border);
    border-radius: var(--radius-input, 14px);
    padding: 0 16px; height: 52px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-soft);
}
.search-container-premium:focus-within {
    border-color: var(--cheisca-blue);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    background-color: #FFFFFF;
}
.search-container-premium .material-symbols-outlined { color: var(--cheisca-black); opacity: 0.4; font-size: 20px; }
.search-container-premium input {
    border: none !important; background: transparent !important;
    width: 100%; height: 100%; font-family: var(--font-body);
    font-size: 1rem; color: var(--cheisca-black); outline: none;
}
.search-container-premium input::placeholder { color: var(--cheisca-black); opacity: 0.4; }

/* --- 5.4 Sistema de Botones --- */
.btn-primary, .btn-secondary, .btn-tertiary {
    border-radius: var(--radius-btn);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary, .btn-secondary {
    padding: 14px 24px;
    font-family: var(--font-heading);
    font-size: 1rem;
    width: 100%;
}

.btn-primary { background-color: var(--cheisca-orange); color: var(--cheisca-white); border: none; }
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow-soft); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary { background-color: var(--cheisca-white); color: var(--cheisca-black); border: 1px solid var(--cheisca-black); }
.btn-secondary:hover:not(:disabled) { background-color: var(--cheisca-smoke); transform: translateY(-2px); }

.btn-tertiary { background: transparent; color: var(--cheisca-blue); border: none; font-family: var(--font-body); font-size: 0.95rem; }
.btn-tertiary:hover { opacity: 0.8; }

.btn-gold { background-color: var(--cheisca-gold); color: var(--cheisca-white); }

/* --- 5.5 Skeletons (PWA Loaders) --- */
.skeleton-loader {
    background: linear-gradient(90deg, var(--cheisca-smoke) 25%, #E5E5E5 50%, var(--cheisca-smoke) 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite linear;
    width: 100%;
}

/* ==========================================================================
   6. MASTER TEST HUB (DEV MENU)
   ========================================================================== */
.dev-fab-btn {
    position: fixed; bottom: 32px; left: 32px; width: 60px; height: 60px;
    background: var(--cheisca-white); border: 1.5px solid var(--cheisca-border); color: var(--cheisca-blue);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 99999; box-shadow: var(--shadow-hover);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.dev-fab-btn:hover { transform: scale(1.1) rotate(10deg); border-color: var(--cheisca-blue); }

.dev-drawer {
    position: fixed; top: 0; left: 0; bottom: 0; width: 320px;
    background: rgba(255, 255, 255, 0.98); backdrop-filter: blur(15px);
    border-right: 1px solid var(--cheisca-border); z-index: 100000;
    display: flex; flex-direction: column; box-shadow: 15px 0 50px rgba(0,0,0,0.05);
    transform: translateX(-100%); transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
}
.dev-drawer:not(.hidden) { transform: translateX(0); }

.dev-drawer-header { padding: 24px; border-bottom: 1px solid var(--cheisca-smoke); display: flex; justify-content: space-between; align-items: center; }
.dev-drawer-header h2 { color: var(--cheisca-black); font-size: 1.25rem; font-weight: 700; }
#dev-menu-close { background: var(--cheisca-smoke); border: none; width: 32px; height: 32px; border-radius: 50%; color: var(--cheisca-black); cursor: pointer; font-size: 1.5rem; font-weight: bold; transition: opacity 0.2s ease; display: flex; align-items: center; justify-content: center;}
#dev-menu-close:hover { opacity: 0.5; }

.dev-drawer-content { padding: 24px; overflow-y: auto; flex: 1; }
.dev-drawer-content::-webkit-scrollbar { width: 4px; }
.dev-drawer-content::-webkit-scrollbar-track { background: transparent; }
.dev-drawer-content::-webkit-scrollbar-thumb { background: var(--cheisca-border); border-radius: 8px; }

.dev-nav-group { margin-bottom: 28px; }
.dev-nav-group h3 {
    font-size: 0.75rem; text-transform: uppercase; color: var(--cheisca-black); opacity: 0.4;
    letter-spacing: 0.1em; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; font-weight: 700;
}
.dev-nav-group h3 span { font-size: 1rem; }
.dev-nav-group a {
    display: block; color: var(--cheisca-black); text-decoration: none; font-size: 0.92rem;
    padding: 10px 14px; border-radius: 10px; margin-bottom: 4px; font-weight: 500; transition: all 0.2s ease;
}
.dev-nav-group a:hover { background: var(--cheisca-smoke); color: var(--cheisca-blue); padding-left: 18px; }

.mt-20 { margin-top: 24px; } 

/* ==========================================================================
   7. MEDIA QUERIES (RESPONSIVE & PWA ADAPTATION)
   ========================================================================== */

/* --- Adaptación Tablet (769px a 900px) --- */
@media (min-width: 769px) and (max-width: 900px) {
    .iam-auth-view { padding: 32px; }
    .iam-container { max-width: 480px; }
    .auth-box { padding: 32px; }
    .iam-title { font-size: 2.25rem; }
}

/* --- Adaptación Desktop (901px en adelante) --- */
@media (min-width: 901px) {
    .iam-auth-view { padding: 48px; }
    .iam-container { max-width: 520px; }
    
    .auth-box { 
        padding: 48px; 
        border-radius: var(--radius-dialog); 
        /* max-width: 100% !important;  */
        margin-left: 0;
    }
    
    .iam-title { font-size: 2.5rem; letter-spacing: -0.03em; }
    .iam-subtitle { font-size: 1.125rem; }
    .input-group label { font-size: 0.95rem; }
    .input-group input { padding: 16px 20px; font-size: 1.05rem; }
    .btn-primary, .btn-secondary { padding: 16px 32px; font-size: 1.125rem; }
    
    .wide-box { max-width: 1200px; padding: 0 40px; }
    
    .dev-fab-btn { bottom: 48px; left: 48px; width: 64px; height: 64px; }
    .dev-drawer { width: 380px; }
}

/* Archivo: public/assets/css/global.css */
/* Punto de integración: Añadir al final del archivo */

/* ==================================================
   DEV MONITOR TOASTER (Solo visible en Development)
   ================================================== */
#dev-monitor-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 380px;
    max-width: 90vw;
    pointer-events: none; /* Permite hacer clic a través del contenedor vacío */
}

.dev-error-toast {
    background: var(--cheisca-white);
    border-left: 4px solid var(--cheisca-danger, #EF4444);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.15);
    border-top: 1px solid var(--cheisca-border);
    border-right: 1px solid var(--cheisca-border);
    border-bottom: 1px solid var(--cheisca-border);
    pointer-events: auto; /* Restaura el clic para esta tarjeta */
    animation: slideInRightDev 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    overflow: hidden;
}

.dev-error-toast-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.dev-error-toast-title {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 800;
    color: var(--cheisca-danger, #EF4444);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dev-error-toast-close {
    background: transparent;
    border: none;
    color: var(--cheisca-black);
    opacity: 0.4;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.dev-error-toast-close:hover {
    opacity: 1;
}

.dev-error-toast-body {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--cheisca-black);
    opacity: 0.8;
    word-break: break-all;
    max-height: 150px;
    overflow-y: auto;
}

/* Scrollbar sutil para el toast */
.dev-error-toast-body::-webkit-scrollbar { width: 4px; }
.dev-error-toast-body::-webkit-scrollbar-thumb { background: rgba(239, 68, 68, 0.3); border-radius: 4px; }

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

@keyframes fadeOutDev {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}