/* content/global.css */

:root {
    --header-height: 50px;
    --primary-blue: #1d6fa5;
    --dark-navy: #2c3e50;
    --save-green: #1e7e34;
    --save-green-hover: #1e7e34;
    --onedrive-blue: #0078d4;
}

/* Screen Reader Only Utility */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
    clip-path: inset(50%) !important;
}

header {
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-sizing: border-box;
    flex-shrink: 0;
    width: 100%;
    position: relative;
    z-index: 1000;
}

.back-link {
    text-decoration: none;
    color: #34495e;
    font-weight: bold;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
}

.back-link:hover {
    color: var(--primary-blue);
}

header h1,
header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--dark-navy);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Expanding Icon Buttons (Shared Styles) */
.nav-icon-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: hidden;
    height: 32px;
    border-radius: 16px;
    max-width: 32px;
    /* Collapsed width */
    transition: max-width 0.3s ease, background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
    background: white;
    border: 1px solid #ccc;
    cursor: pointer;
    box-sizing: border-box;
    line-height: 1;
    text-decoration: none;
    /* For anchor tags */
    color: #333;
}

/* Save Button Specifics */
.nav-icon-btn.save-btn {
    padding: 1px 0 0 4px;
    /* Tuned alignment for Save Icon */
}

/* Admin Button Specifics (Home Page) */
.nav-icon-btn.admin-btn {
    padding: 1px 0 0 4px;
    /* Tuned alignment for Lock Icon */
}

.nav-icon-btn.admin-btn:hover {
    max-width: 160px;
    background-color: #f3e5f5;
    border-color: #4a148c;
    color: #4a148c;
    padding: 0 15px;
}

/* Gear/Settings Button Specifics */
.nav-icon-btn.gear-btn {
    padding: 1px 0 0 4px;
    /* Tuned alignment for Gear Icon */
}

.nav-icon-btn.gear-btn:hover {
    max-width: 135px;
    background-color: #fff3e0;
    border-color: #e65100;
    color: #e65100;
    padding: 0 12px;
}

.nav-icon-btn.save-btn:hover {
    max-width: 240px;
    background-color: #e8f5e9;
    border-color: var(--save-green);
    color: var(--save-green-hover);
    padding: 0 12px;
}

/* Ensure the ⚠️ is visible even when not hovered */
.nav-icon-btn.stale-connection {
    max-width: 55px; /* Widened from 32px to fit ☁️⚠️ */
    background-color: #fff8e1; /* Subtle warning yellow */
    border-color: #ffc107;
}

/* Ensure the expanded state fits the word "Backup" with two emojis */
.nav-icon-btn.stale-connection:hover {
    max-width: 240px;
}

/* Ensure the ✅ is visible during background sync heartbeats */
.nav-icon-btn.is-syncing {
    max-width: 55px;
    background-color: #e8f5e9;
    border-color: var(--save-green);
}

/* Ensure the text is visible if expanded during sync */
.nav-icon-btn.is-syncing:hover {
    max-width: 240px;
}

/* Home Button Specifics */
.nav-icon-btn.home-btn {
    padding: 0 0 1.5px 4px;
    /* Tuned alignment for Home Icon */
}

.nav-icon-btn.home-btn:hover {
    max-width: 160px;
    background-color: #e3f2fd;
    border-color: var(--primary-blue);
    color: #1565c0;
    padding: 0 12px;
}

/* Stats Button Specifics */
.nav-icon-btn.stats-btn {
    padding: 1px 0 0 4px;
    /* Tuned alignment for Stats Icon */
}

.nav-icon-btn.stats-btn:hover {
    max-width: 130px;
    background-color: #e3f2fd;
    border-color: var(--primary-blue);
    color: #1565c0;
    padding: 0 12px;
}

/* Header Divider */
.header-divider {
    width: 2px;
    height: 24px;
    background-color: #ddd;
    margin: 0 5px;
    border-radius: 1px;
}

.btn-icon-span {
    flex-shrink: 0;
    font-size: 1.1rem;
}

.btn-icon-span.onedrive-icon {
    color: var(--onedrive-blue) !important;
}

.btn-text-span {
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: opacity 0.2s, transform 0.2s;
    font-size: 0.85rem;
    font-weight: bold;
}

.nav-icon-btn:hover .btn-text-span {
    opacity: 1;
    transform: translateX(0);
}

/* Load Button Specifics */
.nav-icon-btn.load-btn {
    padding: 1px 0 0 4px;
}

.nav-icon-btn.load-btn:hover {
    max-width: 140px;
    background-color: #e0f7fa;
    border-color: #006064;
    color: #006064;
    padding: 0 12px;
}


/* Main containers are handled by module-specific flex layouts */

/* Global Focus Ring (Blue for navigation) */
:focus-visible {
    outline: 3px solid var(--primary-blue) !important;
    outline-offset: 2px;
}

/* High-contrast focus for elements on dark backgrounds */
#sidebar button:focus-visible,
#sidebar [role="button"]:focus-visible,
#sidebar div[tabindex="0"]:focus-visible,
#sidebar .source-btn:focus-visible {
    outline-color: #ffffff !important;
    /* Pure white ring */
    outline-width: 3px !important;
    outline-style: solid !important;
    outline-offset: 2px !important;
}

/* -------------------------------------------------------------------------
   CHARACTER BADGE
-------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------
   LOAD WARNING MODAL
-------------------------------------------------------------------------- */
.load-warning-modal {
    border: none;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    background: white;
}

.load-warning-modal::backdrop {
    background: rgba(0, 0, 0, 0.7);
}

.load-warning-modal .warning-icon {
    font-size: 3.5rem;
    margin-bottom: 15px;
}

.load-warning-modal h2 {
    color: #d32f2f;
    margin: 0 0 10px 0;
    font-size: 1.6rem;
}

.load-warning-modal .warning-sub {
    font-size: 0.95rem;
    color: #444;
    line-height: 1.4;
    margin-bottom: 20px;
}

.load-warning-modal .save-info-box {
    background: #fff3e0;
    border: 1px solid #ffe0b2;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 25px;
}

.load-warning-modal .save-info-box p {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: #856404;
}

.load-warning-modal .time-display {
    font-size: 1.4rem;
    font-weight: bold;
    color: #333;
    margin-bottom: 4px;
}

.load-warning-modal .relative-display {
    font-size: 1rem;
    color: #666;
    font-weight: 500;
}

.load-warning-modal .btn-wipe {
    background-color: #d32f2f;
    border-color: #b71c1c;
    color: white;
}

.load-warning-modal .btn-wipe:hover {
    background-color: #b71c1c;
}

.load-warning-modal .btn-large {
    font-size: 1.1rem;
    padding: 12px 24px;
    font-weight: bold;
}

.character-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    flex-shrink: 0;
    line-height: 1;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.character-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* -------------------------------------------------------------------------
   PROFILE MODAL OVERLAY
-------------------------------------------------------------------------- */
.profile-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    /* initial state for animation */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.profile-modal-overlay.show {
    opacity: 1;
}

.profile-modal-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 90%;
    max-width: 380px;
    text-align: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
    position: relative;
    /* initial state for animation */
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.profile-modal-overlay.show .profile-modal-card {
    transform: translateY(0);
}

.profile-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #666;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, color 0.2s;
}

.profile-close-btn:hover {
    background-color: #f0f0f0;
    color: #333;
}

.profile-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto 25px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4.5rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

.profile-name {
    margin: 0 0 10px 0;
    color: var(--dark-navy);
    font-size: 1.8rem;
    font-weight: bold;
}

.profile-subtext {
    margin: 0;
    color: #666;
    font-size: 1rem;
}

/* -------------------------------------------------------------------------
   WELCOME HEADER
-------------------------------------------------------------------------- */
.welcome-header {
    display: flex;
    align-items: center;
    gap: 20px;
    width: 100%;
    max-width: 1000px;
    padding: 20px 20px 0 20px; /* Reduced top padding from 30px */
    box-sizing: border-box;
    animation: fadeIn 0.8s ease-out forwards;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wh-large-badge {
    width: 64px !important;
    height: 64px !important;
    font-size: 2.5rem !important;
    cursor: default !important;
}

.wh-large-badge:hover {
    transform: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25) !important;
}

.wh-text-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 6px;
}

.wh-text-container h2 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--dark-navy);
}

.wh-text-container h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #444;
    font-weight: normal;
}

.wh-text-container h3 span {
    font-weight: bold;
    color: var(--primary-blue);
}

.wh-text-container p {
    margin: 0;
    font-size: 0.95rem;
    color: #666;
    font-style: italic;
}

/* -------------------------------------------------------------------------
   PROGRESS TRACKER & ANALYTICS
-------------------------------------------------------------------------- */
.progress-strip {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    background: #f8f9fc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 25px;
    margin: 10px auto 5px auto; /* Tighter vertical spacing for small screens */
    width: 100%;
    max-width: 1000px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    font-size: 0.95rem;
    color: #334155;
    font-weight: 500;
}

.progress-strip span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-top: 20px;
}

.stat-box {
    background: #f8f9fc;
    border: 1px solid #eef;
    border-radius: 12px;
    padding: 20px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-box:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.stat-val {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dark-navy);
    line-height: 1;
    margin-bottom: 4px;
}

.stat-lbl {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* -------------------------------------------------------------------------
   PROGRESS TABLE
-------------------------------------------------------------------------- */
.progress-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    text-align: left;
}

.progress-table th {
    background: #f8f9fc;
    color: #64748b;
    font-weight: 700;
    padding: 12px 10px;
    border-bottom: 2px solid #eee;
    position: sticky;
    top: 0;
    z-index: 10;
}

.progress-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #f0f0f5;
    color: #334155;
}

.progress-table tr:hover {
    background-color: #fcfdfe;
}

.progress-table tr:last-child td {
    border-bottom: none;
}

.table-scroll-wrapper::-webkit-scrollbar {
    width: 8px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}


/* -------------------------------------------------------------------------
   BOTTOM NAVIGATION BAR (Standalone from Backup)
   ------------------------------------------------------------------------- */
:root {
    --bottom-nav-height: 48px;
}

.bottom-nav {
    height: var(--bottom-nav-height);
    min-height: var(--bottom-nav-height);
    background: var(--dark-navy);
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 2px;
    flex-shrink: 0;
    z-index: 1000;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 0 8px;
    width: 100%;
}

.bottom-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 14px;
    min-height: 44px;         /* WCAG target size */
    min-width: 44px;
    text-decoration: none;
    color: rgba(255,255,255,0.9);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
    white-space: nowrap;
    flex-shrink: 1;
}

.bottom-nav a:hover {
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
}

.bottom-nav a.active {
    background: var(--primary-blue);
    color: #ffffff;
}

.bottom-nav a.nav-locked {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: none;
    text-decoration: none;
}

.bottom-nav a .nav-emoji {
    font-size: 1.1rem;
    line-height: 1;
}

@media (max-width: 900px) {
    .bottom-nav a .nav-label { display: none; }
    .bottom-nav a { padding: 0 10px; }
}

/* -------------------------------------------------------------------------
   24. DASHBOARD FOOTER
-------------------------------------------------------------------------- */
.dashboard-footer {
    position: fixed;
    bottom: 15px;
    left: 0;
    right: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px; /* Match header/grid horizontal padding */
    gap: 20px;       /* "Force field" to prevent items from touching */
    box-sizing: border-box;
    opacity: 0.8;
    font-size: 0.8rem;
    color: var(--dark-navy);
    transition: opacity 0.3s ease;
    z-index: 50;
    pointer-events: none;
}

.dashboard-footer:hover {
    opacity: 1;
}

.footer-left, .footer-right {
    display: flex;
    align-items: center;
    pointer-events: auto;
}

.footer-logo {
    height: 18px;
    width: auto;
    margin-right: 8px;
    vertical-align: middle;
}

.footer-right a {
    color: var(--primary-blue);
    text-decoration: none;
    font-weight: 600;
}

.footer-right a:hover {
    text-decoration: underline;
}

/* Optimization for small/low-res screens */

/* 1. DELL LATITUDES / SMALL LAPTOPS (Keep Row) */
@media (max-height: 720px) {
    .dashboard-footer {
        position: static;
        padding: 15px 20px; /* Tighter vertical padding */
        margin-top: 20px;
        opacity: 0.7;
    }
}

/* 2. MOBILE VIEW (Stack Vertically) */
@media (max-width: 600px) {
    .dashboard-footer {
        flex-direction: column;
        text-align: center;
        gap: 10px;
        padding-bottom: 20px;
    }
    
    .footer-left, .footer-right {
        justify-content: center;
        width: 100%;
    }
}

/* -------------------------------------------------------------------------
   HELP BUTTON (nav-icon-btn variant)
------------------------------------------------------------------------- */
.nav-icon-btn.help-btn {
    padding: 1px 0 0 4px;
}

.nav-icon-btn.help-btn:hover {
    max-width: 110px;
    background-color: #fff8e1;
    border-color: #f59e0b;
    color: #92400e;
    padding: 0 12px;
}

/* -------------------------------------------------------------------------
   HELP MODAL
------------------------------------------------------------------------- */
dialog.help-modal-overlay {
    background: transparent;
    border: none;
    padding: 0;
    max-width: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    overflow: visible;
}

dialog.help-modal-overlay::backdrop {
    background: rgba(0, 0, 0, 0.65);
}

.help-modal-overlay.show {
    /* No longer needed but kept for backward compat if JS hasn't reloaded */
    opacity: 1;
    pointer-events: auto;
}

.help-modal-card {
    background: #fff;
    border-radius: 16px;
    padding: 30px 30px 24px 30px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh; /* Safety: Don't overflow small screens */
    overflow-y: auto;  /* Allow content to scroll if it's too tall */
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 18px;
    transition: transform 0.3s ease;
}

.help-modal-overlay.show .help-modal-card {
    transform: translateY(0);
}

.help-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    color: #888;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, color 0.2s;
}

.help-modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.help-modal-header {
    display: flex;
    align-items: center;
    gap: 12px;
}

.help-modal-icon {
    font-size: 2rem;
    flex-shrink: 0;
}

.help-modal-title {
    margin: 0;
    font-size: 1.4rem;
    color: var(--dark-navy, #2c3e50);
    font-weight: 700;
}

.help-modal-video-wrap {
    background: #111;
    border-radius: 10px;
    overflow: hidden;
    min-height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-modal-goal {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border: 1px solid #fcd34d;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.help-modal-goal-label {
    font-weight: 700;
    font-size: 0.95rem;
    color: #92400e;
}

.help-modal-goal-text {
    font-size: 0.95rem;
    color: #78350f;
    line-height: 1.5;
}

.help-modal-footer {
    display: flex;
    justify-content: flex-end;
}

.help-modal-btn {
    background: var(--primary-blue, #1d6fa5);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.help-modal-btn:hover {
    background: #155b8a;
}

.help-modal-btn:active {
    transform: scale(0.97);
}

@media (max-width: 600px) {
    .help-modal-card {
        padding: 24px 18px 18px 18px;
    }

    .help-modal-title {
        font-size: 1.2rem;
    }
}

/* -------------------------------------------------------------------------
   BIMODAL READ-ALOUD STYLES
------------------------------------------------------------------------- */
#article-audio-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #d5dadd; /* Darker gray background */
    border-bottom: 2px solid #bdc3c7;
    display: flex;
    align-items: center;
    gap: 15px;
    max-height: 45px;
    box-sizing: border-box;
}

#article-audio-bar button {
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background 0.2s;
}

#article-audio-bar button:hover {
    background: #f0f0f0;
}

#article-audio-bar button:active {
    background: #e0e0e0;
}

.reading-active {
    background-color: #fff3cd; /* Soft light yellow/gold */
    border-radius: 3px;
    box-shadow: 0 0 0 2px #fff3cd; /* Extend visual padding */
    transition: background-color 0.1s;
}