﻿/* ============================================
   site.css — EPaperSystem
   ============================================ */

:root {
    --primary: #C0392B;
    --primary-dark: #96281B;
    --dark-bg: #1a1a2e;
    --dark-nav: #16213e;
    --accent: #e8b84b;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --border: #e0e0e0;
    --text-main: #212529;
    --text-muted: #6c757d;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --sidebar-w: 240px;
    --topbar-h: 64px;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --font: 'Segoe UI',system-ui,sans-serif;
    --transition: 0.2s ease;
    --region-color: #145A32;
    --region-color-fill: rgba(20, 90, 50, 0.15);
    --pending-color: #1a1a2e;
}

/* ============================================
   Base
   ============================================ */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font);
    color: var(--text-main);
    background: var(--surface-2);
    margin: 0;
    padding: 0;
}

a {
    text-decoration: none;
    transition: color var(--transition);
}

/* ============================================
   Article View — standalone shared page
   ============================================ */
.article-view-card {
    max-width: 480px;
    margin: 30px auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.article-view-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.article-view-logo {
    height: 28px;
}

.article-view-paper-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.article-view-close {
    margin-left: auto;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.article-view-image {
    width: 100%;
    display: block;
}

.article-view-meta {
    padding: 12px 16px 4px;
    font-size: 0.82rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.article-view-ad {
    margin: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
}

.article-view-ad-image {
    width: 100%;
    display: block;
}

.article-view-actions {
    padding: 14px 16px 18px;
    border-top: 1px solid var(--border);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.article-view-download {
    white-space: nowrap;
}

@media (max-width: 520px) {
    .article-view-card {
        margin: 0;
        border-radius: 0;
        min-height: 100vh;
    }
}


@media print {
    .article-view-actions,
    .article-view-close {
        display: none !important;
    }
}

/* ============================================
   Admin / Manager Shell Layout
   ============================================ */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-w);
    background: var(--dark-bg);
    color: #fff;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition);
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    background: var(--dark-nav);
    font-weight: 600;
    font-size: 1.05rem;
}

    .sidebar-brand i {
        color: var(--accent);
        font-size: 1.3rem;
    }

.sidebar-nav {
    flex: 1;
    padding: 12px 0;
    overflow-y: auto;
}

    .sidebar-nav a {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 20px;
        color: rgba(255,255,255,0.7);
        font-size: 0.92rem;
        border-left: 3px solid transparent;
    }

        .sidebar-nav a i {
            width: 18px;
            text-align: center;
        }

        .sidebar-nav a:hover {
            background: rgba(255,255,255,0.06);
            color: #fff;
        }

        .sidebar-nav a.active {
            background: rgba(192,57,43,0.15);
            color: #fff;
            border-left-color: var(--primary);
        }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.3rem;
    cursor: pointer;
}

/* Topbar */
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
}

.topbar-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* Main content area */
.main-content {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    min-height: 100vh;
}

.content-body {
    padding: 24px;
}


.article-popup .share-row a.twitter {
    background: #1DA1F2;
}

.article-popup .share-row a.linkedin {
    background: #0077B5;
}

.article-popup .share-row a.print {
    background: #6c757d;
}

.article-popup .share-row a.email {
    background: #b23121;
}

.article-view-actions .share-row a.twitter {
    background: #1DA1F2;
}

.article-view-actions .share-row a.linkedin {
    background: #0077B5;
}

.article-view-actions .share-row a.print {
    background: #6c757d;
}

.article-view-actions .share-row a.email {
    background: #b23121;
}

/* ============================================
   Cards
   ============================================ */
.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    background: var(--primary);
    flex-shrink: 0;
}

    .stat-card-icon.success {
        background: var(--success);
    }

    .stat-card-icon.warning {
        background: var(--warning);
    }

    .stat-card-icon.accent {
        background: var(--accent);
    }

.stat-card-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.1;
}

.stat-card-label {
    color: var(--text-muted);
    font-size: 0.85rem;
}

.panel {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

    .panel-header h5 {
        margin: 0;
        font-weight: 600;
    }

/* ============================================
   Buttons
   ============================================ */
.btn-brand {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

    .btn-brand:hover {
        background: var(--primary-dark);
        border-color: var(--primary-dark);
        color: #fff;
    }

.btn-outline-brand {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

    .btn-outline-brand:hover {
        background: var(--primary);
        color: #fff;
    }

/* ============================================
   Tables
   ============================================ */
.table-clean thead th {
    background: var(--surface-2);
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 2px solid var(--border);
}

.table-clean td {
    vertical-align: middle;
    font-size: 0.92rem;
}

.badge-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
}

    .badge-status.draft {
        background: #e9ecef;
        color: #495057;
    }

    .badge-status.processing {
        background: #fff3cd;
        color: #856404;
    }

    .badge-status.annotating {
        background: #cce5ff;
        color: #004085;
    }

    .badge-status.published {
        background: #d4edda;
        color: #155724;
    }

    .badge-status.unpublished {
        background: #f8d7da;
        color: #721c24;
    }

/* ============================================
   Login Page
   ============================================ */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark-bg), var(--dark-nav));
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
}

    .login-card h2 {
        font-weight: 700;
        margin-bottom: 4px;
    }

    .login-card p.subtitle {
        color: var(--text-muted);
        margin-bottom: 24px;
    }

/* ============================================
   Annotate Page — Canvas
   ============================================ */
.annotate-wrap {
    display: flex;
    gap: 16px;
}

.annotate-canvas-area {
    flex: 1;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    overflow: auto;
    text-align: center;
}

    .annotate-canvas-area canvas {
        max-width: 100%;
        border: 1px solid var(--border);
        cursor: crosshair;
    }

.annotate-page-strip {
    width: 140px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 80vh;
    overflow-y: auto;
}

    .annotate-page-strip img {
        width: 100%;
        border-radius: 6px;
        border: 2px solid transparent;
        cursor: pointer;
    }

        .annotate-page-strip img.active {
            border-color: var(--primary);
        }

.region-list-item {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* ============================================
   Viewer Page
   ============================================ */
.viewer-body {
    background: var(--dark-bg);
    min-height: 100vh;
}

.viewer-header {
    background: var(--dark-nav);
    color: #fff;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

    .viewer-header .paper-name {
        font-weight: 700;
        font-size: 1.1rem;
    }

.viewer-page-frame {
    max-width: 900px;
    margin: 24px auto;
    position: relative;
    background: #fff;
    box-shadow: var(--shadow-lg);
}

    .viewer-page-frame img {
        width: 100%;
        display: block;
    }

.hotspot {
    position: absolute;
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

    .hotspot:hover {
        border-color: var(--accent);
        background: rgba(232,184,75,0.15);
    }

.viewer-controls {
    position: fixed;
    right: 20px;
    bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 500;
}

    .viewer-controls button {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: var(--primary);
        color: #fff;
        border: none;
        box-shadow: var(--shadow-lg);
        font-size: 1.1rem;
    }

/* Article popup */
.article-popup .modal-content {
    border-radius: var(--radius);
    overflow: hidden;
}

.article-popup .share-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

    .article-popup .share-row a {
        width: 38px;
        height: 38px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #fff;
        background: var(--text-muted);
    }

        .article-popup .share-row a.whatsapp {
            background: #25D366;
        }

        .article-popup .share-row a.telegram {
            background: #0088cc;
        }

        .article-popup .share-row a.facebook {
            background: #1877F2;
        }

        .article-popup .share-row a.other {
            background: var(--dark-nav);
        }

/* Ad popup */
.ad-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.ad-popup-box {
    background: #fff;
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    position: relative;
    overflow: hidden;
}

.ad-popup-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    border: none;
    z-index: 10;
}

.pending-region-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 10px;
    background: var(--surface-2);
}

    .pending-region-item .form-control {
        margin-bottom: 6px;
        font-size: 0.85rem;
    }

    .pending-region-item .pr-remove {
        float: right;
        color: var(--danger);
        cursor: pointer;
        font-size: 0.8rem;
    }
/* ============================================
   Viewer — Professional Layout Overhaul
   ============================================ */

.viewer-brand-header {
    background: var(--surface);
    padding: 14px 24px;
    box-shadow: var(--shadow);
}

    .viewer-brand-header .paper-name {
        font-weight: 800;
        font-size: 1.3rem;
        color: var(--primary);
    }

.viewer-logo {
    height: 40px;
}

/* Edition selector — shown only when multiple editions exist on the same date */
.edition-bar {
    background: var(--dark-nav);
    padding: 10px 24px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    overflow-x: auto;
}

.edition-chip {
    color: rgba(255,255,255,0.75);
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: all var(--transition);
}

    .edition-chip:hover {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }

/* Toolbar */
.viewer-toolbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 800;
}

.viewer-toolbar-left, .viewer-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.viewer-page-select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 0.85rem;
    background: var(--surface);
    min-width: 90px;
}

.viewer-nav-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

    .viewer-nav-btn:hover {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
    }

.viewer-page-numbers {
    display: flex;
    gap: 4px;
    max-width: 260px;
    overflow-x: auto;
}

.viewer-page-num-btn {
    min-width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.8rem;
    color: var(--text-main);
    flex-shrink: 0;
}

    .viewer-page-num-btn.active {
        background: var(--primary);
        color: #fff;
        border-color: var(--primary);
        font-weight: 600;
    }

.viewer-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
}

    .viewer-icon-btn:hover {
        background: var(--surface-2);
    }

.viewer-action-btn {
    padding: 7px 14px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-main);
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

    .viewer-action-btn:hover {
        background: var(--surface-2);
    }

.viewer-action-btn-dark {
    background: var(--dark-bg);
    color: #fff;
    border-color: var(--dark-bg);
}

    .viewer-action-btn-dark:hover {
        background: var(--dark-nav);
    }

/* Body row: sidebar + main */
.viewer-body-row {
    display: flex;
    gap: 0;
    align-items: flex-start;
    min-height: calc(100vh - 130px);
}

.viewer-sidebar {
    width: 150px;
    flex-shrink: 0;
    background: #0f0f1e;
    padding: 16px 10px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    position: sticky;
    top: 130px;
}

.viewer-thumb-wrap {
    margin-bottom: 14px;
    text-align: center;
}

.viewer-thumb {
    width: 100%;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color var(--transition);
    display: block;
}

    .viewer-thumb:hover {
        border-color: var(--accent);
    }

    .viewer-thumb.active-thumb {
        border-color: var(--primary);
    }

.viewer-thumb-label {
    color: rgba(255,255,255,0.6);
    font-size: 0.72rem;
    margin-top: 4px;
}

.viewer-main {
    flex: 1;
    padding: 20px;
    min-width: 0;
}

.viewer-current-edition {
    text-align: center;
    color: rgba(255,255,255,0.7);
    font-size: 0.85rem;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Archive modal — modern card look */
.archive-modal-content {
    border-radius: var(--radius);
    overflow: hidden;
    border: none;
}

.archive-modal-header {
    background: var(--dark-bg);
    color: #fff;
    border: none;
}

    .archive-modal-header .btn-close {
        filter: invert(1);
    }

#archiveCalendar {
    padding: 16px;
}

    #archiveCalendar .flatpickr-calendar {
        box-shadow: none;
        width: 100%;
        max-width: 100%;
    }

.archive-results {
    padding: 0 16px 16px;
    max-height: 240px;
    overflow-y: auto;
}

.archive-result-item {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--text-main);
    transition: all var(--transition);
}

    .archive-result-item:hover {
        border-color: var(--primary);
        background: var(--surface-2);
    }

    .archive-result-item .archive-result-title {
        font-weight: 600;
        display: block;
    }

    .archive-result-item .archive-result-date {
        font-size: 0.78rem;
        color: var(--text-muted);
    }

/* Mobile */
@media (max-width: 767px) {
    .viewer-body-row {
        flex-direction: column;
    }

    .viewer-sidebar {
        width: 100%;
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        position: static;
        max-height: none;
    }

    .viewer-thumb-wrap {
        min-width: 70px;
        margin-right: 10px;
        margin-bottom: 0;
    }

    .viewer-toolbar {
        justify-content: center;
    }

    .viewer-toolbar-left, .viewer-toolbar-right {
        justify-content: center;
        width: 100%;
    }
}

/* ============================================
   Mobile Responsive
   ============================================ */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
    }

        .sidebar.open {
            transform: translateX(0);
        }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle-btn {
        display: inline-block;
    }

    .annotate-wrap {
        flex-direction: column;
    }

    .annotate-page-strip {
        width: 100%;
        flex-direction: row;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
    }

        .annotate-page-strip img {
            width: 90px;
            flex-shrink: 0;
        }
}

@media (max-width: 576px) {
    .content-body {
        padding: 14px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .stat-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .viewer-header {
        padding: 10px 14px;
    }

    .viewer-controls {
        right: 12px;
        bottom: 12px;
    }
}
