/* ============================================================
   SHS Yearbook Digital Proof Viewer — Stylesheet
   ============================================================ */

/* ---------- Design Tokens ---------- */
:root {
    --bg-dark:        #0f1117;
    --bg-surface:     #1a1d27;
    --bg-card:        #222632;
    --bg-hover:       #2c3040;
    --gold:           #d4a845;
    --gold-dim:       #a8862f;
    --gold-glow:      rgba(212,168,69,0.25);
    --accent-blue:    #118AB2;
    --accent-green:   #06D6A0;
    --accent-red:     #EF476F;
    --accent-purple:  #E07CFC;
    --text-primary:   #f0ece4;
    --text-secondary: #a09b90;
    --text-muted:     #6b6760;
    --border:         rgba(255,255,255,0.08);
    --shadow-lg:      0 12px 40px rgba(0,0,0,0.5);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.35);
    --radius-sm:      6px;
    --radius-md:      10px;
    --radius-lg:      16px;
    --font-display:   'Playfair Display', Georgia, serif;
    --font-body:      'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition:     0.2s cubic-bezier(0.4,0,0.2,1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Loading Overlay ---------- */
#loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
}
#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}
.loader-content {
    text-align: center;
    max-width: 320px;
}
.loader-content h2 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 8px;
    font-size: 1.5rem;
}
.loader-content p {
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.loader-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar-track {
    width: 100%;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}
.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--gold-dim), var(--gold));
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* ---------- Top Bar ---------- */
#top-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    height: 56px;
    background: rgba(26,29,39,0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    gap: 12px;
}

.top-bar-left, .top-bar-center, .top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--gold);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}
.logo small {
    font-family: var(--font-body);
    font-size: 0.7rem;
    font-weight: 400;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
}

/* Nav Buttons */
.nav-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.nav-btn:hover { background: var(--bg-hover); border-color: var(--gold-dim); }
.nav-btn:active { transform: scale(0.93); }

/* Page Indicator */
.page-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
#page-input {
    width: 48px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 4px;
    outline: none;
    transition: border-color var(--transition);
    -moz-appearance: textfield;
}
#page-input::-webkit-inner-spin-button,
#page-input::-webkit-outer-spin-button { -webkit-appearance: none; }
#page-input:focus { border-color: var(--gold); }

/* Tool Buttons */
.tool-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    transition: all var(--transition);
    position: relative;
    white-space: nowrap;
}
.tool-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tool-btn.active {
    color: var(--gold);
    background: var(--gold-glow);
    border-color: var(--gold-dim);
}
.tool-btn .material-symbols-outlined { font-size: 20px; }
.btn-label { display: inline; }

.badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.separator {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 4px;
}

.icon-btn {
    width: 32px; height: 32px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---------- Main Viewer ---------- */
#viewer-area {
    position: fixed;
    top: 56px;
    left: 0; right: 0; bottom: 0;
    display: flex;
    background: var(--bg-dark);
    /* subtle texture pattern */
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(212,168,69,0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 50%, rgba(17,138,178,0.04) 0%, transparent 50%);
}

#flipbook-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 24px;
}

/* StPageFlip container */
#flipbook {
    box-shadow: var(--shadow-lg);
    border-radius: 4px;
}

/* Override StPageFlip internals to look nice */
.stf__parent {
    /* The library adds this class */
}

/* Page styling for the rendered pages */
.page-canvas-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    position: relative;
    overflow: hidden;
}
.page-canvas-wrapper canvas {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ---------- Annotation Layer ---------- */
#annotation-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 50;
}

body.annotate-mode #annotation-layer {
    pointer-events: auto;
    cursor: crosshair;
}

.annotation-pin {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg) translate(-50%, -50%);
    transform-origin: center center;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    z-index: 51;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.6);
}
.annotation-pin::after {
    content: attr(data-index);
    transform: rotate(45deg);
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(0,0,0,0.7);
}
.annotation-pin:hover {
    transform: rotate(-45deg) translate(-50%, -50%) scale(1.15);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

/* ---------- Notes Panel ---------- */
#notes-panel {
    width: 360px;
    min-width: 300px;
    background: var(--bg-surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: margin-right var(--transition), opacity var(--transition);
    z-index: 60;
}
#notes-panel.panel-closed {
    margin-right: -360px;
    opacity: 0;
    pointer-events: none;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-header h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    color: var(--gold);
    display: flex;
    align-items: center;
    gap: 6px;
}
.panel-header h2 .material-symbols-outlined { font-size: 20px; }

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-actions select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 4px 8px;
    outline: none;
    cursor: pointer;
}
.panel-actions select:focus { border-color: var(--gold); }

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
}
.empty-state .material-symbols-outlined {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.4;
}
.empty-state p { font-size: 0.85rem; line-height: 1.6; }

/* Note Card */
.note-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 10px;
    border-left: 4px solid var(--gold);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
}
.note-card:hover { background: var(--bg-hover); transform: translateX(2px); }
.note-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}
.note-card-page {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}
.note-card-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.note-card-comment {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    word-break: break-word;
}
.note-card-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* ---------- Annotation Dialog ---------- */
#annotation-dialog {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}
#annotation-dialog.dialog-hidden {
    opacity: 0;
    pointer-events: none;
}
.dialog-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
}
.dialog-box {
    position: relative;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    width: 400px;
    max-width: 90vw;
    box-shadow: var(--shadow-lg);
    animation: dialog-in 0.25s ease;
}
@keyframes dialog-in {
    from { transform: translateY(20px) scale(0.96); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.dialog-box h3 {
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--gold);
    margin-bottom: 20px;
    font-size: 1.15rem;
}
.dialog-body label {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    margin-top: 14px;
}
.dialog-body label:first-child { margin-top: 0; }

.dialog-body input[type="text"],
.dialog-body textarea {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    padding: 10px 12px;
    outline: none;
    transition: border-color var(--transition);
    resize: vertical;
}
.dialog-body input:focus,
.dialog-body textarea:focus { border-color: var(--gold); }

.color-picker {
    display: flex;
    gap: 8px;
    padding: 4px 0;
}
.color-swatch {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--text-primary); box-shadow: 0 0 0 2px var(--bg-surface); }

.dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}
.dialog-footer button {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn-primary {
    background: linear-gradient(135deg, var(--gold), var(--gold-dim));
    color: #1a1a1a;
}
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary {
    background: var(--bg-card);
    color: var(--text-secondary);
    border: 1px solid var(--border) !important;
}
.btn-secondary:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-danger {
    background: var(--accent-red);
    color: #fff;
}
.btn-danger:hover { filter: brightness(1.1); }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .btn-label { display: none; }
    .logo small { display: none; }
    #notes-panel { width: 100%; position: absolute; right: 0; top: 0; bottom: 0; }
    #notes-panel.panel-closed { margin-right: -100%; }
}

@media (max-width: 600px) {
    #top-bar { padding: 0 10px; gap: 6px; }
    .separator { display: none; }
    #flipbook-wrapper { padding: 12px; }
}
