/* ==========================================================================
   DESIGN SYSTEM & VARIABLES
   ========================================================================== */
:root {
    /* Color Tokens (HSL values for better color-control and glows) */
    --bg-darkest: hsl(240, 10%, 4%);        /* Page backdrop */
    --bg-card: hsl(240, 6%, 10%);          /* Card container */
    --bg-card-hover: hsl(240, 6%, 12%);
    --border-subtle: hsl(240, 5%, 15%);    /* Gray border */
    
    /* Brand Accent Colors */
    --color-primary: #FFD100;              /* Smart Fit Yellow */
    --color-primary-rgb: 255, 209, 0;
    --color-primary-hover: #E6BC00;
    --color-success: #10B981;              /* Emerald Green */
    --color-danger: #EF4444;               /* Crimson Red */
    
    /* Typography Colors */
    --text-primary: hsl(0, 0%, 96%);       /* Main text */
    --text-secondary: hsl(240, 5%, 70%);   /* Secondary text */
    --text-muted: hsl(240, 5%, 45%);       /* Muted text */
    --text-on-primary: #0A0A0B;            /* Contrast text on buttons */
    
    /* Shadows & Glows */
    --glow-yellow: 0 0 20px rgba(255, 209, 0, 0.4);
    --glow-yellow-btn: 0 4px 15px rgba(255, 209, 0, 0.25);
    --shadow-card: 0 6px 24px rgba(0, 0, 0, 0.45);
}

/* ==========================================================================
   RESET & GLOBAL STYLES
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-darkest);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(255, 209, 0, 0.03) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(255, 209, 0, 0.02) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    line-height: 1.5;
}

/* ==========================================================================
   APP CONTAINER SHELL
   ========================================================================== */
.app-viewport {
    width: 100%;
    max-width: 960px; /* Centered layout for desktop */
    margin: 0 auto;
    padding: 2.5rem 1.5rem 6rem 1.5rem; /* bottom padding space for nav bar */
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 1.25rem;
}

.header-titles h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text-primary);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header-titles .subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
}

.btn-icon-header {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 0.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-card);
}

.btn-icon-header:hover {
    color: var(--color-primary);
    border-color: rgba(255, 209, 0, 0.4);
    transform: rotate(45deg);
}

.btn-icon-header:active {
    transform: scale(0.92) rotate(45deg);
}

/* ==========================================================================
   GRID LAYOUT (Acomodo Inteligente)
   ========================================================================== */
.app-grid {
    display: grid;
    grid-template-columns: 1.05fr 0.95fr; /* Split in 2 columns on desktop */
    gap: 1.5rem;
    align-items: start;
}

.grid-column {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* ==========================================================================
   CARD STYLES
   ========================================================================== */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    transition: transform 0.2s, border-color 0.2s;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.05);
}

/* Card: Info (Estandarizar antes de optimizar) */
.card-info {
    display: flex;
    flex-direction: row;
    gap: 1rem;
    align-items: flex-start;
    border-left: 4px solid var(--color-primary);
}

.info-icon {
    color: var(--color-primary);
    flex-shrink: 0;
    margin-top: 0.15rem;
    display: flex;
    filter: drop-shadow(0 0 4px rgba(255, 209, 0, 0.25));
}

.info-icon svg {
    width: 24px;
    height: 24px;
}

.info-content h2 {
    font-size: 1.15rem;
    font-weight: 800;
    margin-bottom: 0.4rem;
    letter-spacing: -0.01em;
}

.info-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

/* Card: Identity (Mi Identidad) */
.card-identity {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.card-identity .label {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 0.08em;
}

.card-identity .quote {
    font-size: 1.1rem;
    font-weight: 700;
    font-style: italic;
    color: var(--text-primary);
    border: none;
    padding: 0;
}

/* Card: Timer Module (Simulador de Presencia Mínima) */
.card-timer-module {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.card-timer-module h3 {
    font-size: 1.05rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    width: 100%;
}

/* Circle Timer Display */
.timer-display-container {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.timer-outer-ring {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.progress-ring-svg {
    position: absolute;
    top: 0;
    left: 0;
    transform: rotate(-90deg); /* Start progress at the top */
}

.progress-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.03);
}

.progress-ring-fill {
    fill: none;
    stroke: var(--color-primary);
    stroke-linecap: round;
    transition: stroke-dashoffset 0.1s linear, stroke 0.3s;
}

.timer-text-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.timer-numbers {
    font-size: 2.75rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.timer-status {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    padding: 0.25rem 0.6rem;
    border-radius: 5px;
    margin-top: 0.2rem;
    transition: all 0.3s ease;
}

/* Timer status styling states */
.status-locked {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.status-ready {
    background-color: rgba(255, 209, 0, 0.1);
    color: var(--color-primary);
    animation: pulse-border 1.5s infinite alternate;
}

.status-running {
    background-color: rgba(255, 209, 0, 0.15);
    color: var(--color-primary);
    box-shadow: 0 0 12px rgba(255, 209, 0, 0.2);
}

.status-completed {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--color-success);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.2);
}

/* App Action Button */
.btn-app-action {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    width: 100%;
    padding: 1rem;
    border-radius: 14px;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-on-primary);
    background-color: var(--color-primary);
    box-shadow: var(--glow-yellow-btn);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    cursor: pointer;
}

.btn-app-action:hover:not(:disabled) {
    background-color: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 209, 0, 0.35);
}

.btn-app-action:active:not(:disabled) {
    transform: translateY(0);
}

.btn-app-action.btn-locked-state {
    background-color: rgba(255, 209, 0, 0.1);
    color: var(--color-primary);
    border: 1px solid rgba(255, 209, 0, 0.3);
    box-shadow: none;
}

.btn-app-action.btn-locked-state:hover {
    background-color: rgba(255, 209, 0, 0.15);
    border-color: var(--color-primary);
}

.btn-app-action:disabled {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-app-action.success-btn {
    background-color: var(--color-success);
    color: white;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.hidden {
    display: none !important;
}

.icon-spinner {
    animation: rotate 1s linear infinite;
}

/* Card: Weekly Chain (Mi Cadena Semanal) */
.card-weekly-chain {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.chain-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chain-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.streak-badge {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-primary);
}

.icon-flame {
    width: 16px;
    height: 16px;
    fill: var(--color-primary);
    color: var(--color-primary);
    filter: drop-shadow(0 0 2px rgba(255, 209, 0, 0.4));
}

.chain-days-container {
    display: flex;
    justify-content: space-between;
    gap: 0.35rem;
}

/* Daily Items */
.chain-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.day-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.day-name {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.day-status, .day-status-label {
    font-size: 0.65rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

/* Day states */
/* 1. Micro active */
.chain-day.active-micro .day-circle {
    background-color: var(--color-primary);
    color: var(--text-on-primary);
    box-shadow: 0 4px 12px rgba(255, 209, 0, 0.25);
}
.chain-day.active-micro .day-status {
    color: var(--color-primary);
}

/* 2. Full active */
.chain-day.active-full .day-circle {
    background-color: #242420;
    border: 2px solid var(--color-primary);
    color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(255, 209, 0, 0.15);
}
.chain-day.active-full .day-status {
    color: var(--color-primary);
}

/* 3. Pending */
.chain-day.pending .day-circle {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    background-color: transparent;
    color: var(--text-muted);
}
.chain-day.pending .day-status-label {
    color: var(--text-muted);
}

/* 3b. Pending-Today (Active checking) */
.chain-day.pending-today .day-circle {
    border: 2px dashed var(--color-primary);
    color: var(--color-primary);
    animation: pulse-border 1.5s infinite alternate;
}
.chain-day.pending-today .day-status-label {
    color: var(--color-primary);
}

/* 4. Future */
.chain-day.future .day-circle {
    border: 2px solid rgba(255, 255, 255, 0.05);
    background-color: rgba(255, 255, 255, 0.01);
    color: var(--text-muted);
}
.chain-day.future .day-status-label {
    color: var(--text-muted);
}

.placeholder-char {
    opacity: 0.4;
}

/* ==========================================================================
   APP NAVIGATION BAR (Fixed on container viewport bottom)
   ========================================================================== */
.app-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: rgba(18, 18, 20, 0.95);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 1rem;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    width: 25%;
    transition: color 0.2s;
}

.nav-item svg {
    stroke-width: 2px;
    transition: transform 0.2s;
}

.nav-item:hover {
    color: var(--text-secondary);
}

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

.nav-item.active svg {
    transform: scale(1.08);
}

/* Adjust navigation placement inside center column on huge desktop */
@media (min-width: 960px) {
    .app-nav {
        position: sticky;
        margin-top: 2rem;
        border-radius: 16px;
        bottom: 1.5rem;
        width: 100%;
        max-width: 960px;
        box-shadow: var(--shadow-card);
        background-color: var(--bg-card);
        border: 1px solid var(--border-subtle);
    }
    .app-viewport {
        padding-bottom: 2.5rem;
    }
}

/* ==========================================================================
   DEBUG MODAL & ADJUSTMENTS DIALOG
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 1rem;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: #121214;
    border: 1px solid var(--border-subtle);
    border-radius: 24px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
    transform: translateY(30px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.modal-overlay.open .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-close {
    background: none;
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

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

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.debug-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.btn-debug {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    transition: all 0.2s;
    cursor: pointer;
}

.btn-debug:hover:not(:disabled) {
    background-color: rgba(255, 255, 255, 0.06);
    border-color: var(--text-secondary);
    transform: translateY(-1px);
}

.btn-debug:active:not(:disabled) {
    transform: translateY(0);
}

.btn-debug:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.btn-debug.btn-danger {
    color: var(--color-danger);
    border-color: rgba(239, 68, 68, 0.2);
    background-color: rgba(239, 68, 68, 0.03);
}

.btn-debug.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: var(--color-danger);
}

/* Console details in modal */
.mini-console {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.console-head {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.console-box {
    background-color: #020203;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.75rem;
    height: 110px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.log-line {
    line-height: 1.35;
    word-break: break-all;
}

.log-line.network { color: #60A5FA; }
.log-line.success { color: var(--color-success); }
.log-line.warn { color: var(--color-primary); }

/* ==========================================================================
   TOAST SYSTEM
   ========================================================================== */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    max-width: 320px;
    width: calc(100% - 3rem);
    pointer-events: none;
}

.toast {
    background-color: #1a1a1c;
    border-left: 3px solid var(--color-primary);
    border-top: 1px solid var(--border-subtle);
    border-bottom: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    color: var(--text-primary);
    padding: 0.85rem 1.15rem;
    border-radius: 12px;
    font-size: 0.82rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    pointer-events: auto;
    animation: toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    display: flex;
    align-items: center;
}

.toast.toast-success {
    border-left-color: var(--color-success);
}

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

/* ==========================================================================
   KEYFRAMES & TRANSITIONS
   ========================================================================== */
@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse-border {
    0% {
        border-color: rgba(255, 209, 0, 0.2);
        box-shadow: 0 0 0 0px rgba(255, 209, 0, 0.15);
    }
    100% {
        border-color: rgba(255, 209, 0, 0.95);
        box-shadow: 0 0 10px 3px rgba(255, 209, 0, 0.25);
    }
}

@keyframes toast-in {
    from {
        transform: translateY(-20px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
@media (max-width: 768px) {
    .app-viewport {
        padding: 1.25rem 1rem 5.5rem 1rem;
        gap: 1.25rem;
    }

    .app-header {
        padding-bottom: 0.85rem;
    }

    .header-titles h1 {
        font-size: 1.65rem;
    }

    .header-titles .subtitle {
        font-size: 0.8rem;
    }

    .app-grid {
        grid-template-columns: 1fr; /* Stack into single column */
        gap: 1.15rem;
    }

    .card {
        padding: 1.15rem;
        border-radius: 16px;
    }

    .card-info {
        gap: 0.75rem;
    }

    .info-content h2 {
        font-size: 1.05rem;
    }

    .info-content p {
        font-size: 0.82rem;
    }

    .card-identity .quote {
        font-size: 0.95rem;
    }

    /* Fixed Nav Bar on Mobile viewport */
    .app-nav {
        position: fixed;
        border-radius: 0;
        bottom: 0;
        left: 0;
        right: 0;
        box-shadow: 0 -2px 15px rgba(0, 0, 0, 0.45);
    }
    
    .day-circle {
        width: 44px;
        height: 44px;
        font-size: 0.85rem;
    }
    
    .day-name {
        font-size: 0.65rem;
    }
    
    .day-status, .day-status-label {
        font-size: 0.6rem;
    }
    
    .toast-container {
        top: auto;
        bottom: 75px; /* Above the bottom nav bar */
        right: 1.5rem;
    }
}
