/* ============================================
   危险品规则 DGR CMS 专题 - 样式表
   ============================================ */

/* ========== CSS Variables ========== */
:root {
    --primary: #4b5563;
    --primary-dark: #374151;
    --primary-light: #6b7280;
    --bg-dark: #111827;
    --bg-light: #f9fafb;
    --text-dark: #1f2937;
    --text-light: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --header-height: 60px;
    --footer-height: 50px;
    --toc-width: 280px;
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark);
    background: var(--bg-dark);
    overflow: hidden;
}

/* ========== Header ========== */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left {
    flex: 1;
}

.header-right {
    flex: 1;
    justify-content: flex-end;
}

.logo {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo .version {
    font-size: 11px;
    font-weight: 400;
    opacity: 0.8;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ========== Buttons ========== */
.btn-toggle,
.btn-icon,
.btn-nav {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-toggle {
    width: 40px;
    height: 40px;
    font-size: 20px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-nav {
    padding: 8px 12px;
    font-size: 13px;
}

.btn-toggle:hover,
.btn-icon:hover,
.btn-nav:hover {
    background: rgba(255,255,255,0.2);
}

/* ========== Page Navigation ========== */
.page-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.1);
    padding: 6px 12px;
    border-radius: 8px;
}

.page-input {
    width: 50px;
    padding: 4px 8px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(255,255,255,0.9);
    text-align: center;
    font-size: 13px;
    color: var(--text-dark);
}

.page-sep,
.total-pages {
    color: rgba(255,255,255,0.7);
    font-size: 13px;
}

.zoom-level {
    min-width: 50px;
    text-align: center;
    font-size: 13px;
    color: rgba(255,255,255,0.9);
}

/* ========== TOC Sidebar ========== */
.toc-sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: var(--footer-height);
    width: var(--toc-width);
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    transform: translateX(0);
    transition: transform 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.toc-sidebar.collapsed {
    transform: translateX(-100%);
}

.toc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
}

.toc-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.btn-close {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
}

.toc-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.toc-list {
    list-style: none;
}

.toc-item {
    display: block;
    padding: 10px 20px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}

.toc-item:hover {
    background: var(--bg-light);
    color: var(--primary);
}

.toc-item.active {
    background: rgba(75, 85, 99, 0.1);
    border-left-color: var(--primary);
    color: var(--primary);
    font-weight: 500;
}

.toc-section {
    padding: 12px 20px 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* TOC Overlay (Mobile) */
.toc-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 85;
}

.toc-overlay.active {
    display: block;
}

/* ========== Main Content ========== */
.main-content {
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: var(--footer-height);
    overflow: auto;
    background: var(--bg-dark);
}

.viewer {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    min-height: 100%;
}

/* ========== Page Item ========== */
.page-item {
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    margin-bottom: 20px;
    position: relative;
}

.page-item img {
    display: block;
    width: 100%;
    height: auto;
}

.page-item .page-number {
    position: absolute;
    bottom: -28px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.4);
    font-size: 12px;
}

/* ========== Footer Navigation ========== */
.footer-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--footer-height);
    background: var(--bg-dark);
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 100;
}

.btn-nav-lg {
    padding: 8px 20px;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-nav-lg:hover {
    background: #1f2937;
}

.footer-page-info {
    color: white;
    font-size: 14px;
    min-width: 80px;
    text-align: center;
}

/* ========== Loading ========== */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    color: white;
    z-index: 150;
    background: rgba(0,0,0,0.7);
    padding: 30px 50px;
    border-radius: 12px;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ========== Search ========== */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box input {
    width: 0;
    padding: 0;
    border: none;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 13px;
    border-radius: 6px;
    transition: all 0.3s ease;
    outline: none;
}

.search-box input:focus {
    width: 200px;
    padding: 8px 36px 8px 12px;
    background: rgba(255,255,255,0.95);
    color: var(--text-dark);
}

.search-box input::placeholder {
    color: rgba(255,255,255,0.6);
}

.btn-search,
.btn-search-clear {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: white;
    font-size: 16px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-search:hover,
.btn-search-clear:hover {
    background: rgba(255,255,255,0.1);
}

.btn-search-clear {
    display: none;
    position: absolute;
    right: 0;
}

.search-box input:focus ~ .btn-search-clear,
.search-box input:not(:placeholder-shown) ~ .btn-search-clear {
    display: flex;
    right: 36px;
}

.search-results {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    width: 400px;
    max-height: 500px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 200;
    margin-top: 8px;
}

.search-results-header {
    padding: 10px 16px;
    background: var(--bg-light);
    font-size: 12px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

.search-results-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
}

.btn-search-nav {
    padding: 4px 12px;
    background: var(--primary);
    border: none;
    color: white;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
}

.btn-search-nav:hover {
    background: var(--primary-dark);
}

.search-result-counter {
    font-size: 12px;
    color: var(--text-light);
}

.search-results-list {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
}

.search-result-item {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.search-result-item:hover,
.search-result-item.active {
    background: rgba(75, 85, 99, 0.08);
}

.search-result-page {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
}

.search-result-snippet {
    font-size: 12px;
    color: var(--text-dark);
    line-height: 1.5;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result-snippet mark {
    background: rgba(255, 193, 7, 0.4);
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
}

.search-no-results {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

.search-loading {
    position: fixed;
    top: 70px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 13px;
    z-index: 200;
}

.search-loading .loading-spinner {
    width: 20px;
    height: 20px;
    border-width: 2px;
    margin: 0;
}

/* ========== Page Text (OCR) ========== */
.page-text {
    padding: 12px 16px;
    background: #f8f9fa;
    border-top: 1px solid var(--border);
    font-size: 13px;
}

.page-text-label {
    cursor: pointer;
    color: var(--primary);
    font-weight: 500;
    user-select: none;
}

.page-text-content {
    margin-top: 10px;
    padding: 12px;
    background: white;
    border-radius: 6px;
    border: 1px solid var(--border);
    white-space: pre-wrap;
    line-height: 1.8;
    max-height: 300px;
    overflow-y: auto;
    font-size: 12px;
    color: var(--text-dark);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
    .header {
        padding: 0 12px;
    }
    
    .header-center {
        display: none;
    }
    
    .search-box input:focus {
        width: 140px;
    }
    
    .search-results {
        width: 300px;
        right: -50px;
    }
    
    .logo {
        font-size: 14px;
    }
    
    .logo .version {
        display: none;
    }
    
    .toc-sidebar {
        top: 0;
        bottom: 0;
        z-index: 200;
    }
    
    .toc-sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    .btn-close {
        display: block;
    }
    
    .toc-overlay.active {
        display: block;
    }
    
    .footer-nav {
        gap: 10px;
    }
    
    .btn-nav-lg {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .viewer {
        padding: 10px;
    }
}

/* ========== Print ========== */
@media print {
    .header,
    .footer-nav,
    .toc-sidebar,
    .toc-overlay {
        display: none !important;
    }
    
    .main-content {
        position: static;
        overflow: visible;
    }
    
    .viewer {
        padding: 0;
    }
    
    .page-item {
        box-shadow: none;
        margin: 0;
        page-break-after: always;
    }
}
