@import url('fonts.css');

:root {
    /* Dynamic Theme Color Variables */
    --theme-color: #FF5733;
    --theme-color-hover: #C83E1D;
    --theme-color-rgb: 255, 87, 51;

    --bg-primary: #f0f1f3; /* Light grey/beige from screenshot */
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --accent-color: var(--theme-color); /* Bound to dynamic theme color */
    --accent-hover: var(--theme-color-hover);
    --border-color: #d1d5db;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --font-body: 'Inter', sans-serif;
    --font-heading: 'Cinzel', serif;
    --font-article: 'Lora', serif;
    --transition-speed: 0.2s;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-color: var(--theme-color);
    --accent-hover: var(--theme-color-hover);
    --border-color: #334155;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Restore native vertical scrolling */
body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    overflow-y: auto; /* Enable natural vertical scrollbar */
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

/* Two-tier Sticky Header */
.epaper-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Row 1: Brand details and site navigation links */
.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.brand-block {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
    color: var(--text-primary);
    line-height: 1.1;
    text-transform: uppercase;
}

.brand-subtitle {
    font-size: 10px;
    font-weight: 700;
    color: var(--accent-color);
    letter-spacing: 2px;
    text-transform: uppercase;
}

/* Navigation Links */
.site-nav {
    display: flex;
    align-items: center;
    gap: 20px;
}

.site-nav .nav-link {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

.site-nav .nav-link:hover, .site-nav .nav-link.active {
    color: var(--accent-color);
}

/* Row 2: Selectors, zoom controls, thumbnails */
.header-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.selectors-row {
    display: flex;
    gap: 12px;
}

.selector-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.selector-label {
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: 4px;
}

/* PAGE NO Display Card */
.page-no-box {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 8px;
    min-width: 65px;
    height: 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-secondary);
    line-height: 1.1;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.page-no-label {
    font-size: 8px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.page-no-val {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-color);
}

/* Right Side: Horizontal Page Thumbnail Slider */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    max-width: 650px;
    height: 54px;
}

.slider-arrow {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1.5px solid var(--accent-color);
    background-color: var(--bg-secondary);
    color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    transition: all var(--transition-speed) ease;
    flex-shrink: 0;
}

.slider-arrow:hover {
    background-color: var(--accent-color);
    color: #ffffff;
}

.horizontal-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-behavior: smooth;
    padding: 2px 0;
    height: 100%;
    align-items: center;
    justify-content: center;
}

/* Hide horizontal scrollbar inside list */
.horizontal-thumbnails::-webkit-scrollbar {
    display: none;
}
.horizontal-thumbnails {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.slider-thumbnail-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
    width: 50px;
    transition: transform var(--transition-speed) ease;
}

.slider-thumbnail-card:hover {
    transform: translateY(-2px);
}

.slider-thumbnail-img-box {
    width: 38px;
    aspect-ratio: 1 / 1.414;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    background-color: var(--bg-secondary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.slider-thumbnail-card.active .slider-thumbnail-img-box {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 1.5px var(--accent-color);
}

.slider-thumbnail-svg {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.slider-thumbnail-num {
    font-size: 9.5px;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 2px;
    line-height: 1;
}

.slider-thumbnail-card.active .slider-thumbnail-num {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

/* Main Workspace Layout */
.app-container {
    display: block; /* Normal block height flow */
    position: relative;
}

/* Center main newspaper viewport area with vertical scrolling support */
.viewer-workspace {
    display: block;
    text-align: center;
    overflow-x: auto; /* Horizontal scroll if zoomed wide */
    overflow-y: visible; /* Parent body handles vertical scroll */
    padding: 24px;
    user-select: none;
    position: relative;
    min-height: calc(100vh - 180px);
}

.viewport-container {
    width: 100%;
    display: inline-block;
    vertical-align: top;
    position: relative;
}

.canvas-zoomable {
    transition: width 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    background-color: #ffffff;
    width: 95%;
    max-width: 100%;
    aspect-ratio: 1 / 1.414;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    margin: 0 auto;
    text-align: left;
}

.canvas-zoomable.animating {
    transition: width 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.canvas-svg {
    width: 100%;
    height: 100%;
    display: block;
}

/* Floating Theme Switcher Overlay */
.floating-theme-switch {
    position: fixed; /* Pin to browser window */
    bottom: 24px;
    left: 24px;
    z-index: 1000;
    display: flex;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.theme-btn {
    border: none;
    background: transparent;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.theme-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
}

.theme-btn.active {
    background-color: var(--bg-tertiary);
    color: var(--accent-color);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

/* Accent swatches picker */
.accent-swatches {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.accent-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.accent-swatch.active {
    outline: 2px solid rgba(0,0,0,0.06);
    transform: scale(1.05);
    border-color: rgba(255,255,255,0.6);
}

/* Floating Control Panel (Fixed, Centered, Sticky) */
.floating-control-panel {
    position: fixed;
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    z-index: 999;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    padding: 16px;
    max-width: 140px;
    transition: all var(--transition-speed) ease;
}

.floating-control-panel:hover {
    box-shadow: 0 25px 70px rgba(0,0,0,0.2);
}

.panel-inner {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-section label {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-section .btn {
    font-size: 12px;
    padding: 6px 8px;
}

.accent-swatch-small {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
    transition: all 0.12s ease;
}

.accent-swatch-small:hover { transform: translateY(-2px); }

.accent-swatch-small.active {
    outline: 2px solid rgba(0,0,0,0.06);
    transform: scale(1.08);
    border-color: rgba(255,255,255,0.6);
}

/* Mobile: Adjust floating panel position */
@media (max-width: 768px) {
    .floating-control-panel {
        right: 10px;
        max-width: 130px;
        padding: 12px;
    }
}

/* Toast Message */
.toast-msg {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background-color: var(--text-primary);
    color: var(--bg-secondary);
    padding: 10px 20px;
    border-radius: 4px;
    font-size: 12.5px;
    font-weight: 500;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast-msg.show {
    opacity: 1;
    transform: translateY(0);
}

/* Theme adaptation for Bootstrap components */
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-control,
[data-theme="dark"] .btn-outline-secondary,
[data-theme="dark"] .btn-outline-danger,
[data-theme="sepia"] .form-select,
[data-theme="sepia"] .form-control,
[data-theme="sepia"] .btn-outline-secondary,
[data-theme="sepia"] .btn-outline-danger,
[data-theme="ocean"] .form-select,
[data-theme="ocean"] .form-control,
[data-theme="ocean"] .btn-outline-secondary,
[data-theme="ocean"] .btn-outline-danger,
[data-theme="forest"] .form-select,
[data-theme="forest"] .form-control,
[data-theme="forest"] .btn-outline-secondary,
[data-theme="forest"] .btn-outline-danger {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

/* Copyright Footer */
footer {
    background-color: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

/* Footer Navigation Links */
.footer-links .nav-link {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-secondary) !important;
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

.footer-links .nav-link:hover {
    color: var(--accent-color) !important;
}

/* Responsive Overrides */
@media (max-width: 768px) {
    .epaper-header {
        position: relative !important; /* Save vertical reading space on mobile! */
        padding: 10px 15px !important;
    }
    
    .brand-title {
        font-size: 26px !important;
        letter-spacing: 1px !important;
    }
    
    .brand-description {
        font-size: 9.5px !important;
        line-height: 1.3;
    }
    
    .brand-meta {
        font-size: 9.5px !important;
    }
    
    .viewer-workspace {
        padding: 12px !important;
    }
    
    .floating-theme-switch {
        bottom: 16px;
        left: 16px;
    }
    
    .floating-logout-switch {
        bottom: 16px;
        right: 16px;
    }
    
    .horizontal-thumbnails {
        justify-content: flex-start !important;
    }
}

/* Floating Logout Button */
.floating-logout-switch {
    position: fixed; /* Pin to browser window */
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-speed), border-color var(--transition-speed);
}

.logout-btn {
    border: none;
    background: transparent;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
}

.logout-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--accent-color) !important;
}

/* --- PREMIUM STICKY THEME SELECTOR PANEL --- */
.theme-selector-panel {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1050;
    width: auto;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(226, 232, 240, 0.8);
    border-radius: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08), 
                0 0 0 1px rgba(0, 0, 0, 0.02);
    padding: 8px 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-theme="dark"] .theme-selector-panel {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(51, 65, 85, 0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3),
                0 0 0 1px rgba(255, 255, 255, 0.05);
}

.theme-panel-header {
    display: none; /* No header needed in a compact pill dock */
}

.theme-mode-section {
    display: flex;
    align-items: center;
    gap: 4px;
}

.section-label {
    display: none; /* No labels needed inside the pill */
}

/* Mode buttons (Light/Dark) */
.theme-mode-buttons {
    display: flex;
    background: var(--bg-tertiary);
    padding: 2px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.mode-btn {
    border: none;
    background: transparent;
    padding: 6px 12px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-btn i {
    font-size: 12px;
}

.mode-btn:hover {
    color: var(--text-primary);
}

.mode-btn.active {
    background-color: var(--bg-secondary);
    color: var(--theme-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .mode-btn.active {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Pill Separator */
.theme-pill-separator {
    width: 1px;
    height: 18px;
    background-color: var(--border-color);
}

/* Logout Section */
.theme-logout-section {
    display: flex;
    align-items: center;
}

.btn-theme-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 18px;
    cursor: pointer;
    text-decoration: none !important;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-theme-logout:hover {
    color: #ffffff !important;
    background: #ef4444;
    border-color: #ef4444;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* General Layout Transition */
body, header, footer, .btn, .slider-arrow, .slider-thumbnail-card, .theme-selector-panel, .page-no-box, .canvas-zoomable {
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease, box-shadow 0.4s ease;
}

/* Hide Redundant Components on e_paper.aspx */
body.epaper-page #accentSwatches,
body.epaper-page #themeToggleBtn,
body.epaper-page #floatingControlPanel,
body.epaper-page .floating-theme-switch,
body.epaper-page .floating-logout-switch {
    display: none !important;
}

/* Responsive overrides */
@media (max-width: 768px) {
    .theme-selector-panel {
        bottom: 16px;
        padding: 6px 12px;
        gap: 8px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    }
    
    .mode-btn {
        padding: 5px 10px;
        font-size: 10.5px;
    }
    
    .btn-theme-logout {
        padding: 5px 10px;
        font-size: 10.5px;
    }
    
    body.epaper-page {
        padding-bottom: 80px !important;
    }
}

