/* ==========================================================================
   CUÁNDO TRABAJA TERESA - STYLES
   A fun, modern design for Teresa's work schedule
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS CUSTOM PROPERTIES (Design Tokens)
   -------------------------------------------------------------------------- */
:root {
    /* Color Palette */
    --color-bg-primary: #0a0a0f;
    --color-bg-secondary: #12121a;
    --color-bg-tertiary: #1a1a25;
    --color-bg-card: rgba(255, 255, 255, 0.03);
    --color-bg-card-hover: rgba(255, 255, 255, 0.06);

    /* Accent Colors */
    --color-accent-primary: #a855f7;
    --color-accent-secondary: #ec4899;
    --color-accent-tertiary: #06b6d4;
    --color-accent-success: #22c55e;
    --color-accent-warning: #f59e0b;
    --color-accent-danger: #ef4444;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
    --gradient-secondary: linear-gradient(135deg, var(--color-accent-tertiary), var(--color-accent-primary));
    --gradient-success: linear-gradient(135deg, #22c55e, #06b6d4);
    --gradient-danger: linear-gradient(135deg, #ef4444, #f59e0b);
    --gradient-bg: linear-gradient(180deg, var(--color-bg-primary) 0%, var(--color-bg-secondary) 100%);

    /* Text Colors */
    --color-text-primary: #ffffff;
    --color-text-secondary: rgba(255, 255, 255, 0.7);
    --color-text-muted: rgba(255, 255, 255, 0.4);

    /* Typography */
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(168, 85, 247, 0.3);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;

    /* Glass Effect */
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: blur(20px);
}

/* --------------------------------------------------------------------------
   RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    /* Ensure background covers full viewport including safe areas */
    background: var(--color-bg-primary);
    /* Prevent white flash on iOS overscroll */
    background-color: var(--color-bg-primary);
    min-height: 100%;
    min-height: -webkit-fill-available;
}

/* iOS overscroll background fix - pseudo-elements for top/bottom bounce */
html::before,
html::after {
    content: '';
    position: fixed;
    left: 0;
    right: 0;
    height: 100vh;
    background: var(--color-bg-primary);
    z-index: -1;
    pointer-events: none;
}

html::before {
    bottom: 100%;
}

html::after {
    top: 100%;
    background: var(--color-bg-secondary);
}

body {
    font-family: var(--font-body);
    background: var(--gradient-bg);
    background-attachment: fixed;
    color: var(--color-text-primary);
    min-height: 100vh;
    min-height: -webkit-fill-available;
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --------------------------------------------------------------------------
   STATUS SECTION - Hero Area
   -------------------------------------------------------------------------- */
.status-section {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: var(--space-xl);
    /* Account for iOS notch/status bar */
    padding-top: calc(var(--space-xl) + env(safe-area-inset-top));
    overflow: hidden;
}

.status-container {
    text-align: center;
    z-index: 1;
    max-width: 600px;
    width: 100%;
}

.status-question {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    letter-spacing: -0.02em;
}

.status-answer {
    font-family: var(--font-display);
    font-size: clamp(4rem, 15vw, 8rem);
    font-weight: 700;
    line-height: 1;
    margin-bottom: var(--space-md);
    letter-spacing: -0.04em;
    animation: pulse-glow 3s ease-in-out infinite;
}

.status-answer.working {
    background: var(--gradient-success);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(34, 197, 94, 0.5);
}

.status-answer.not-working {
    background: var(--gradient-danger);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 60px rgba(239, 68, 68, 0.5);
}

@keyframes pulse-glow {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.9; transform: scale(1.02); }
}

.status-detail {
    font-size: clamp(1.1rem, 3vw, 1.5rem);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xl);
    min-height: 2em;
}

.status-detail .highlight {
    color: var(--color-text-primary);
    font-weight: 600;
}

.today-schedule {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
}

.schedule-chip {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    backdrop-filter: var(--glass-blur);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.schedule-chip.active {
    background: var(--gradient-primary);
    border-color: transparent;
    font-weight: 500;
}

/* Background Decoration */
.status-bg-decoration {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(circle at 30% 20%, rgba(168, 85, 247, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.1) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(6, 182, 212, 0.08) 0%, transparent 50%);
    animation: float-bg 20s ease-in-out infinite;
    pointer-events: none;
}

@keyframes float-bg {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    33% { transform: translate(-2%, 2%) rotate(1deg); }
    66% { transform: translate(2%, -1%) rotate(-1deg); }
}

/* --------------------------------------------------------------------------
   BECA COUNTDOWN SECTION
   -------------------------------------------------------------------------- */
.beca-section {
    padding: var(--space-2xl) var(--space-xl);
    background: var(--color-bg-secondary);
    border-top: 1px solid var(--glass-border);
    border-bottom: 1px solid var(--glass-border);
}

.beca-container {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.beca-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    animation: sad-bounce 2s ease-in-out infinite;
}

@keyframes sad-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

.beca-label {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-lg);
    font-style: italic;
}

.beca-countdown {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: var(--space-lg);
}

.countdown-unit {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    min-width: 80px;
    backdrop-filter: var(--glass-blur);
}

.countdown-value {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 700;
    background: var(--gradient-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.countdown-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.beca-end-date {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   CALENDAR SECTION
   -------------------------------------------------------------------------- */
.calendar-section {
    padding: var(--space-2xl) var(--space-xl);
    max-width: 800px;
    margin: 0 auto;
}

.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.calendar-header h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
}

.exceptions-btn {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--color-text-primary);
    padding: var(--space-sm) var(--space-lg);
    border-radius: var(--radius-full);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9rem;
    transition: all var(--transition-normal);
    backdrop-filter: var(--glass-blur);
}

.exceptions-btn:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent-primary);
}

/* Calendar Grid */
.calendar-month {
    margin-bottom: var(--space-2xl);
}

.calendar-month-title {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-md);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: var(--space-xs);
}

.calendar-weekday {
    text-align: center;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    position: relative;
    background: var(--color-bg-tertiary);
    border: 1px solid transparent;
}

.calendar-day:hover {
    transform: scale(1.1);
    z-index: 1;
}

.calendar-day.empty {
    background: transparent;
    cursor: default;
}

.calendar-day.empty:hover {
    transform: none;
}

.calendar-day.working {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(6, 182, 212, 0.2));
    border-color: rgba(34, 197, 94, 0.3);
}

.calendar-day.working:hover {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.4), rgba(6, 182, 212, 0.4));
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.calendar-day.not-working {
    background: var(--color-bg-tertiary);
    color: var(--color-text-muted);
}

.calendar-day.today {
    border: 2px solid var(--color-accent-primary);
    font-weight: 700;
}

.calendar-day.past {
    opacity: 0.5;
}

.calendar-day.exception {
    position: relative;
    border: 2px solid var(--color-accent-warning) !important;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

.calendar-day.exception::after {
    content: '!';
    position: absolute;
    top: -6px;
    right: -6px;
    font-size: 0.65rem;
    color: var(--color-bg-primary);
    font-weight: 700;
    background: var(--color-accent-warning);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* --------------------------------------------------------------------------
   MODALS
   -------------------------------------------------------------------------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
    /* Respect iOS safe areas */
    padding-top: calc(var(--space-md) + env(safe-area-inset-top));
    padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
    padding-left: calc(var(--space-md) + env(safe-area-inset-left));
    padding-right: calc(var(--space-md) + env(safe-area-inset-right));
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--color-bg-secondary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modal-in 0.3s ease;
}

.modal-large {
    max-width: 500px;
}

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

.modal-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--color-text-primary);
}

.modal-content h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
    margin-bottom: var(--space-lg);
}

.modal-schedule {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.modal-schedule-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--glass-bg);
    border-radius: var(--radius-md);
}

.modal-schedule-icon {
    font-size: 1.5rem;
}

.modal-schedule-time {
    font-family: var(--font-display);
    font-weight: 600;
}

.modal-schedule-label {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.modal-no-work {
    text-align: center;
    padding: var(--space-xl);
    color: var(--color-text-muted);
}

.modal-no-work-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
}

/* --------------------------------------------------------------------------
   EXCEPTIONS MODAL
   -------------------------------------------------------------------------- */
.exceptions-list {
    margin-bottom: var(--space-lg);
    max-height: 200px;
    overflow-y: auto;
}

.exception-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--glass-bg);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
}

.exception-info {
    flex: 1;
}

.exception-date {
    font-weight: 600;
    font-size: 0.9rem;
}

.exception-type {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.exception-delete {
    background: none;
    border: none;
    color: var(--color-accent-danger);
    cursor: pointer;
    padding: var(--space-sm);
    font-size: 1rem;
    opacity: 0.7;
    transition: opacity var(--transition-fast);
}

.exception-delete:hover {
    opacity: 1;
}

.no-exceptions {
    text-align: center;
    color: var(--color-text-muted);
    padding: var(--space-lg);
    font-style: italic;
}

.add-exception-btn {
    width: 100%;
    padding: var(--space-md);
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.add-exception-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* Exception Form */
.exception-form {
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--glass-border);
}

.exception-form h4 {
    font-family: var(--font-display);
    margin-bottom: var(--space-lg);
}

.form-step {
    margin-bottom: var(--space-lg);
}

.form-step label {
    display: block;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

/* Mini Calendar for Exception Selection */
.exception-calendar {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
    font-size: 0.8rem;
}

.exception-calendar .calendar-day {
    padding: var(--space-sm);
    font-size: 0.75rem;
}

.exception-calendar .calendar-weekday {
    font-size: 0.65rem;
    padding: var(--space-xs);
}

.exception-calendar .calendar-day.selectable {
    cursor: pointer;
}

.exception-calendar .calendar-day.selectable:hover {
    background: var(--color-accent-primary);
}

.exception-calendar .calendar-day.selected {
    background: var(--gradient-primary);
    font-weight: 700;
}

.exception-calendar .month-separator {
    grid-column: 1 / -1;
    text-align: center;
    padding: var(--space-sm);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: var(--space-sm);
}

/* Exception Type Buttons */
.exception-type-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.type-btn {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: left;
}

.type-btn:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-accent-primary);
}

.type-btn.selected {
    background: var(--gradient-primary);
    border-color: transparent;
}

.type-icon {
    font-size: 1.5rem;
}

.type-label {
    font-size: 0.9rem;
}

/* Custom Hours Form */
.custom-hours-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.time-group {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.time-label {
    min-width: 80px;
    font-size: 0.9rem;
}

.time-group input[type="time"] {
    background: var(--color-bg-tertiary);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-primary);
    padding: var(--space-sm);
    font-size: 0.9rem;
}

.time-group input[type="time"]:focus {
    outline: none;
    border-color: var(--color-accent-primary);
}

.clear-time-btn {
    background: none;
    border: none;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: var(--space-xs);
    font-size: 0.8rem;
}

.clear-time-btn:hover {
    color: var(--color-accent-danger);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-lg);
}

.btn-primary, .btn-secondary {
    flex: 1;
    padding: var(--space-md);
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--gradient-primary);
    border: none;
    color: var(--color-text-primary);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--color-text-secondary);
}

.btn-secondary:hover {
    background: var(--glass-bg);
}

/* --------------------------------------------------------------------------
   FOOTER
   -------------------------------------------------------------------------- */
.footer {
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    /* Extra padding for iOS home indicator */
    padding-bottom: calc(var(--space-2xl) + env(safe-area-inset-bottom));
    color: var(--color-text-muted);
    font-size: 0.85rem;
    background: var(--color-bg-primary);
}

.footer-small {
    font-size: 0.75rem;
    margin-top: var(--space-sm);
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.toast {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: var(--space-md) var(--space-xl);
    border-radius: var(--radius-full);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all var(--transition-normal);
    backdrop-filter: var(--glass-blur);
    box-shadow: var(--shadow-lg);
    max-width: calc(100vw - 40px);
    text-align: center;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast-success {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.9), rgba(6, 182, 212, 0.9));
    color: white;
}

.toast-error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.9), rgba(245, 158, 11, 0.9));
    color: white;
}

.toast-info {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--color-text-primary);
}

/* --------------------------------------------------------------------------
   UTILITIES
   -------------------------------------------------------------------------- */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */
@media (max-width: 480px) {
    .status-section {
        min-height: 50vh;
        padding: var(--space-lg);
    }

    .beca-countdown {
        gap: var(--space-sm);
    }

    .countdown-unit {
        min-width: 65px;
        padding: var(--space-sm) var(--space-md);
    }

    .countdown-value {
        font-size: 1.5rem;
    }

    .calendar-section {
        padding: var(--space-lg);
    }

    .calendar-day {
        font-size: 0.8rem;
    }

    .modal-content {
        padding: var(--space-lg);
    }

    .time-group {
        font-size: 0.85rem;
    }

    .time-label {
        min-width: 70px;
    }
}
