/* styles.css -- MyBest24 app */

:root {
    --bg-dark: #0a0a0a;
    --bg-panel: #121212;      /* panel color */
    --bg-button: #2a2a2a;     /* secondary button color */
    --box-border: #333333;
    --box-past: #252525;
    --box-future: #ffffff;
    --accent-color: #46a5ce;
    --accent-glow: rgba(70, 165, 206, 0.4);
    --text-main: #ffffff;
    --text-muted: #999999;
    --icon-size: 64px;
}

html, body {
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto; /* Enable vertical scrolling */
}

/* safari start */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    -webkit-text-size-adjust: 100%;
}
/* safari end */

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh; 
    display: flex;
    flex-direction: column;
    font-family: 'Inter', system-ui, sans-serif;
}

/* --- PRIMARY ACTION BUTTONS --- */
.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 160px;
    transition: transform 0.1s, filter 0.2s;
    white-space: nowrap;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* -------- HEADER ------------*/

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--box-border); /* Subtle separation */
}

/* Ensure the center section is truly centered */
.header-section {
    flex: 1;
    display: flex;
}

.header-section.center {
    justify-content: center;
}

.header-section.right {
    justify-content: flex-end;
}

/* Branding Styles */
.brand-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    cursor: pointer; /* Shows it's clickable */
}

.logo-text {
    color: #ffffff; /* Sets "Day" to white */
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.text-accent {
    color: var(--accent-color); /* Updating branding blue */
}

/* Buttons */
/* header-section left button */
.action-button {
    background: #2a2a2a;
    color: var(--accent-color);
    border: 1px solid #444;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background: #333;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

/* --- SLEEP COLUMN 3 ----- */
.sleep-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

#sleep-text-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* START MINI-GRID HOURS UNTIL SLEEP LAYOUT (Desktop First: 6 across) */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); 
    gap: 4px;
}

.mini-sleep-box {
    width: 8px;
    height: 8px;
    background-color: var(--box-future);
    border-radius: 1px;
}
/* END MINI-GRID HOURS UNTIL SLEEP */

/* start INFO BAR area */
/* tells user 24 boxes = 24 hours */

.info-bar, #app-info-modal h2, #app-wizard-modal h2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 14px 0;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid #222;
    font-size: 1.1rem; /* Bold, readable desktop size */
    letter-spacing: 1px;
    color: #999;
    text-transform: uppercase;
}

.info-bar .text-accent {
    color: var(--accent-color);
    font-weight: bold;
}

.info-divider {
    color: #333;
}

/* end INFO BAR area */

/* Main Grid Area */
.workspace {
    flex: 1; 
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Changed from center so it scrolls from the top */
    padding: 20px;
    width: 100%;
    box-sizing: border-box;
}

.allocation-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); 
    gap: 16px;
    width: 100%;
    max-width: 1000px;
    margin: 40px auto; /* Centered with breathing room */
}

.status-upcoming { 
    background-color: transparent; 
    border-color: var(--box-border); 
}

/* HOURS STYLING ON MAIN GRID BOXES */
/* handle PNGs */
.hour-block {
    position: relative; /* Ensure children can be pinned to corners */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px; 
    padding: 20px 10px;
}

.time-label {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.75rem;
    opacity: 0.6;
}

.category-label {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slot-icon {
    width: var(--icon-size);
    height: var(--icon-size);
    image-rendering: pixelated;
    object-fit: contain;
}

/* New Animated Class - No duplication of size! */
.slot-icon.animated {
    background-size: auto var(--icon-size);
    background-repeat: no-repeat;
    display: block;
    margin: 0 auto;
}

.sprite-animation {
    background-size: auto 100%; /* Height is 100%, width scales based on frames */
    image-rendering: pixelated; /* Keeps the 16x16 assets sharp at 48x48 */
    display: block;
    margin: 0 auto;
}

@keyframes play-sprite {
    from { background-position: 0px; }
    to { background-position: -100%; } /* This is adjusted dynamically via JS */
}
/* end Sprite Animation logic */

/* Highlight the current hour professionally */
.status-current {
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: scale(1.05);
    z-index: 5;
}

/* Make label brighter for the current hour */
.status-current .time-label {
    color: rgba(255, 255, 255, 0.9);
}

.status-past {
    filter: grayscale(1) brightness(0.3);
}

/* clear all button */
/* bottom of page */
.clear-link {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3); /* Very subtle until hover */
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.clear-link:hover {
    color: #ff4444; /* Turns red to warn user */
}

/* START MODAL POP-UP CSS */

.hidden, .modal-hidden { 
    display: none !important; 
}

/* Unified Modal Overlay */
.modal-overlay,
#anchor-modal,
#box-modal,
#app-info-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Wizard modal - SCROLLING FIX */
#app-wizard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    display: flex; /* Change from block to flex like info modal */
    align-items: flex-start; /* Not center, so it can scroll */
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0; /* Add padding for scroll breathing room */
}

/* Remove the margin override, let it inherit from .modal-content-info */
#app-wizard-modal .modal-content {
    width: 500px; /* Match info modal width */
    max-width: 95vw;
    margin: auto 0; /* Vertical auto centering within flex */
}

/* Base Modal Container */
.modal-content,
.modal-content-info {
    background: var(--bg-panel);
    border: 1px solid var(--box-border);
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
}

.modal-content-small {
    width: 320px;
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 0 2rem;
}

.modal-header h3 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-main);
}

#app-wizard-modal h4 {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

.close-button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-button:hover {
    color: var(--text-main);
}

/* Modal Body */
.modal-body {
    padding: 1rem 2rem 2rem 2rem;
}

/* Anchor Saved Notification */
.anchor-saved-notice {
    color: var(--accent-color);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
    min-height: 1.2rem;
    display: block;
    text-align: center;
}

/* Anchor Rows */
.anchor-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.anchor-label {
    min-width: 70px;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Anchor icons inline with labels */
.anchor-icon {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

.input-subgroup {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    flex: 1;
}

.input-subgroup select {
    font-size: 1rem;
    padding: 8px;
    background: #1a1a1a;
    color: white;
    border: 1px solid var(--box-border);
    border-radius: 4px;
    outline: none;
    flex: 1;
}

.input-subgroup select:focus {
    border-color: var(--accent-color);
}

.input-subgroup span {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

/* Remove Anchor Button */
.remove-anchor {
    background: transparent;
    border: 1px solid #ff4444;
    color: #ff4444;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
}

.remove-anchor:hover {
    background: #ff4444;
    color: white;
}

/* Add Anchor Controls */
.add-anchor-controls {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--box-border);
}

#anchor-selector {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    color: var(--text-main);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 0.5rem;
    outline: none;
}

#anchor-selector option {
    padding: 6px;
}

#anchor-selector:focus {
    border-color: var(--accent-color);
}

#anchor-selector-container {
    margin-top: 0.5rem;
}

#show-anchor-selector {
    margin-bottom: 0;
}

#additional-anchors .anchor-row {
    margin-top: 1rem;
}

/* Box Modal - Icon Display */
.box-icon-display {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

#box-icon {
    width: 100px;
    height: 100px;
    image-rendering: pixelated;
}

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

.form-group select {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.1rem;
    padding: 8px 12px;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    color: var(--text-main);
    border-radius: 6px;
    outline: none;
}

.form-group select:focus {
    border-color: var(--accent-color);
}

/* Modal Actions (Buttons) */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 1rem;
}

/* anchor modal buttons */

.btn-primary {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    white-space: nowrap;  /* Forces text to stay on one line */
    width: 100%;
    background: transparent;
    border: 1px solid var(--box-border);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-secondary:hover {
    background: #333;
}

.modal-body .button-row, 
.modal-body .centered-container {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-top: 15px;
}

/* anchor modal -- two buttons in a row */
.button-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
}

/* Ensure hidden works on flex containers */
.button-row.hidden {
    display: none !important;
}



/* Never show the remove button for the Sleep row */
#anchor-row-sleep .remove-anchor { display: none !important; }

/* Keep the selector container hidden by default */
#anchor-selector-container.hidden { display: none; }

/* -- END ANCHOR MODAL -- */


/* --- APP INFO MODAL & WIZARD MODAL (SHARED BRANDING) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95); /* Nearly solid black for focus */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Ensure it sits on top of everything */
}

.modal-content-info {
    width: 500px;
    max-width: 95vw;
}

/* Center Branding in Header - SHARED by both info modal and wizard */
#app-info-modal .modal-header,
#app-wizard-modal .modal-header {
    position: relative;
    display: flex;
    justify-content: center; 
    padding: 2.5rem 2rem 0.5rem;
}

/* Correct class from your HTML - SHARED */
#app-info-modal .brand-logo-centered,
#app-wizard-modal .brand-logo-centered {
    display: flex;
    flex-direction: row; 
    align-items: center; 
    justify-content: center;
    gap: 12px;
    cursor: default;
}

/* Wizard gets smaller logo */
#app-info-modal .logo-icon { 
    height: 48px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

#app-wizard-modal .logo-icon { 
    height: 32px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

/* Wizard gets smaller app name text */
#app-info-modal h1.logo-text { 
    font-size: 2.5rem; 
    margin: 0;
    line-height: 1;
    display: block; 
    white-space: nowrap;
}

#app-wizard-modal h1.logo-text { 
    font-size: 1.8rem; 
    margin: 0;
    line-height: 1;
    display: block; 
    white-space: nowrap;
}

/* Pin Close Button to Corner */
#app-info-modal .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Tagline styling - Info modal keeps original size */
#app-info-modal h2 { 
    display: block;
    gap: 0;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    text-align: center;
    margin: 0 0 1.5rem;
    line-height: 1.6;
}

/* Wizard tagline - smaller size and tighter spacing */
#app-wizard-modal h2 { 
    display: block;
    gap: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    text-align: center;
    margin: -1rem 0 1rem;
    line-height: 1.4;
}


#app-info-modal h3 { 
    font-size: 1.5rem; 
    color: var(--accent-color); 
    margin: 1.5rem 0 0.8rem; /* Adjusted margin for better spacing */
    line-height: 1.0; 
    text-align: left; 
}

/* click the anchor text to open anchor modal */
.clickable-link { 
    color: var(--accent-color); 
    text-decoration: none; /* No underline */
}

/* Optional: Make the blue word slightly brighter when hovering anywhere on the line */
#trigger-anchor-modal:hover .clickable-link {
    filter: brightness(1.2);
}

/* List & Body Text */
#app-info-modal p, 
#app-info-modal ul { 
    color: rgba(255, 255, 255, 0.85); 
    line-height: 1.6; 
    text-align: left;
}

#app-info-modal ul li { 
    font-size: 1.1rem; 
    margin-bottom: 0.8rem; 
}

#app-info-modal strong { 
    color: var(--accent-color); 
}

/* Footer Distinction */
#app-info-modal .modal-footer-note {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--box-border);
    font-size: 1rem;
    opacity: 0.6;
}

/* END MODAL POP-UP CSS */

/* WIZARD CODE */

#app-wizard-modal h3 {
    font-size: 2rem;
    color: #aaa;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

/* Wizard icons inline with titles */
.wizard-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 10px;
}

.wizard-label {
    display: block;
    font-size: 1.5rem;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.wizard-content {
    text-align: center;
}

.wizard-nav {
    display: flex;
    justify-content: space-between; /* Puts Back on left, Next on right */
    gap: 12px;
    align-items: center;
    padding: 20px 30px;
    margin-top: auto; 
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* If ONLY the "Start My Journey" button exists, center it */
.wizard-nav:has(> :only-child) {
    justify-content: center;
}

/* WIZARD BUTTON STYLES - FIX */
.btn-wizard-primary {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 160px;
    transition: transform 0.1s, filter 0.2s;
    white-space: nowrap;
    font-size: 1rem;
}

.btn-wizard-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-wizard-secondary {
    background: transparent;
    border: 1px solid var(--box-border);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 100px;
    transition: background 0.2s;
    white-space: nowrap;
    font-size: 1rem;
}

.btn-wizard-secondary:hover {
    background: #333;
}

/* Wizard Progress Dots */
.dots-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 20px 0;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #555; 
    transition: all 0.3s ease;
    box-sizing: border-box;
}

/* Blue filled for completed */
.dot.completed {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* White-ish border for current */
.dot.current {
    border-color: #9dc6d8;
    /* This adds a glow/halo effect without increasing size */
    box-shadow: 0 0 0 2px rgba(157, 198, 216, 0.4); 
}

/* If it is BOTH completed and current, keep it blue but show the border */
.dot.completed.current {
    background-color: var(--accent-color);
    border-color: #ffffff; /* Bright white to pop against blue */
}

.dot.skipped {
    background-color: #333;
    border-color: #555;
}

/* Dark Mode Time Inputs */
.dark-time-input {
    background: #222;
    color: white;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 6px;
    font-size: 1.2rem;
    width: 100%;
    max-width: 100px;
    margin: 0 auto 15px auto;  /* Center it */
}

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 columns for desktop */
    gap: 10px;
    margin-top: 20px;
    text-align: left;
}

.review-item {
    background: #2a2a2a;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
    display: flex;
    justify-content: space-between;
}

.text-muted {
    color: #777;
    font-style: italic;
}
/* END WIZARD CODE */


/* ---- MOBILE ------ */

/* This handles the switch from 6 columns to 4 columns */
@media (max-width: 800px) {

    :root {
        --icon-size: 32px; /* Mobile Override */
    }

    .hour-block {
        min-height: 50px;
    }

    /* 1. Shrink the info bar */
    .info-bar {
        font-size: 0.75rem; 
        padding: 8px 0;
        gap: 10px;
        letter-spacing: 0.5px;
    }
    
    .info-divider {
        margin: 0 4px;
    }

    /* 2. SWITCH TO 4 COLUMNS (6 rows of 4 = 24) */
    .allocation-grid {
        grid-template-columns: repeat(4, 1fr); 
        gap: 8px;
        margin: 20px auto;
        aspect-ratio: auto; /* Remove fixed ratio so it can grow vertically */
    }

    /* 3. Adjust mini-grid */
    .mini-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* 4. Header adjustments for tight spaces */
    .app-header {
        padding: 15px 20px;
    }
    
    /* 5. MOBILE WIZARD SCROLLING FIX */
    #app-wizard-modal .modal-content {
        margin: 0; /* Remove margin on mobile */
        min-height: 100vh; /* Ensure full height */
        border-radius: 0; /* Remove rounded corners on mobile */
    }

    #sleep-text-display {
        /* Use !important to override Safari user-agent styles */
        display: none !important;
        
        /* Forces Safari to treat the element as non-existent in the accessibility tree */
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }
    

}

@media (max-width: 600px) {
    /* wizard */
    .review-grid { grid-template-columns: 1fr; }
}