/**
 * shell.css - Shared Layout Shell
 * Ez Editorials Platform
 * Ground Rule 2: Mobile: < 768px, Tablet: min-width: 768px, Desktop: min-width: 1024px
 */

/* ==========================================================================
   1. DESKTOP TOP NAVBAR (@media (min-width: 1024px) & html.is-desktop)
   ========================================================================== */
.desktop-navbar {
    display: none;
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

html.is-desktop .desktop-navbar {
    display: block;
}

.desktop-nav-inner {
    max-width: var(--container-desktop, 1440px);
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg, 24px);
}

.desktop-nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm, 8px);
    font-size: var(--font-lg, 18px);
    font-weight: 800;
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

.desktop-nav-tools {
    display: flex;
    align-items: center;
    gap: var(--space-md, 12px);
}

.target-exam-pill,
.streak-pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs, 6px);
    padding: 6px var(--space-md, 12px);
    border-radius: var(--radius-full, 9999px);
    font-size: var(--font-sm, 13px);
    font-weight: 600;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.target-exam-pill:hover {
    background: var(--brand-light);
    border-color: var(--color-info-border);
    color: var(--brand-blue);
}

.desktop-tool-btn,
.desk-avatar-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-base, 12px);
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.desktop-tool-btn:hover,
.desk-avatar-btn:hover {
    background: var(--brand-light);
    transform: translateY(-1px);
}

/* ==========================================================================
   2. DESKTOP LEFT NAVIGATION RAIL (240px)
   ========================================================================== */
.left-nav-rail {
    display: none;
    width: var(--rail-left-width, 240px);
    flex-shrink: 0;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
    padding: var(--space-base, 16px) var(--space-md, 12px);
    flex-direction: column;
    justify-content: space-between;
    overflow-y: auto;
}

html.is-desktop .left-nav-rail {
    display: flex;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: var(--space-sm, 8px);
    padding: var(--space-sm, 8px) var(--space-md, 12px);
    margin-bottom: var(--space-base, 16px);
    font-size: var(--font-lg, 18px);
    font-weight: 800;
    color: var(--text-main);
    cursor: pointer;
}

.nav-links-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs, 4px);
    flex-grow: 1;
}

.nav-rail-btn {
    display: flex;
    align-items: center;
    gap: var(--space-md, 12px);
    width: 100%;
    padding: 10px var(--space-md, 12px);
    border-radius: var(--radius-md, 8px);
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: var(--font-base, 14px);
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-rail-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.nav-rail-btn.active {
    background: var(--brand-light);
    color: var(--brand-blue);
    font-weight: 700;
}

.nav-rail-footer {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs, 4px);
    padding-top: var(--space-base, 16px);
    border-top: 1px solid var(--border-color);
}

.nav-rail-logout {
    color: var(--color-danger);
}

.nav-rail-logout:hover {
    background: var(--color-danger-bg);
    color: var(--color-danger-text);
}

/* ==========================================================================
   3. MOBILE BOTTOM NAVIGATION (< 768px)
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 99;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

html.is-desktop .bottom-nav {
    display: none !important;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    color: var(--text-muted);
    font-size: var(--font-xs, 11px);
    font-weight: 600;
    cursor: pointer;
    transition: color 0.15s ease;
    user-select: none;
}

.nav-item.active {
    color: var(--brand-blue);
    font-weight: 700;
}

.nav-icon {
    width: 22px;
    height: 22px;
}

/* ==========================================================================
   4. STANDARDIZED MODAL SHELL PATTERN (Sheet on mobile, Centered on Tablet/Desktop)
   ========================================================================== */
.ez-modal-overlay,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay, rgba(0, 0, 0, 0.5));
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 1000;
    display: flex;
    align-items: flex-end; /* Mobile default: bottom sheet */
    justify-content: center;
    transition: opacity 0.2s ease;
}

.ez-modal-dialog,
.bottom-sheet {
    width: 100%;
    background: var(--bg-card);
    border-radius: var(--radius-xl, 20px) var(--radius-xl, 20px) 0 0;
    max-height: 88vh;
    overflow-y: auto;
    box-shadow: var(--shadow-dialog);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Tablet & Desktop: Centered Dialog */
@media (min-width: 768px) {
    .ez-modal-overlay,
    .modal-overlay {
        align-items: center;
        justify-content: center;
        padding: var(--space-lg, 24px);
    }

    .ez-modal-dialog,
    .bottom-sheet {
        max-width: 540px;
        border-radius: var(--radius-base, 16px);
        max-height: 82vh;
        margin: auto;
    }
}

@media (min-width: 1024px) {
    .ez-modal-dialog,
    .bottom-sheet {
        max-width: 580px;
    }
}

/* --- TACTILE ACTIVE STATES & TOUCH TARGETS --- */
button:active,
.btn:active,
[role="button"]:active,
.nav-rail-btn:active,
.p-card-item:active,
.rail-day-pill:active,
.cup-header-back-btn:active,
.cup-analytics-btn:active,
.progress-chart-btn:active,
.profile-settings-btn:active {
    transform: scale(0.98);
    transition: transform 0.08s ease;
}

/* --- ACCESSIBILITY FOCUS RING --- */
button:focus-visible,
.btn:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--brand-blue, #1c64f2) !important;
    outline-offset: 2px !important;
}

/* --- MINIMUM TOUCH TARGETS (≥ 44px) --- */
button,
.btn,
[role="button"],
.p-card-item,
.nav-item,
.nav-rail-btn,
select,
.cup-header-back-btn,
.cup-analytics-btn,
.progress-chart-btn,
.profile-settings-btn {
    min-height: 44px;
    box-sizing: border-box;
}
