/* ============================================
   OFD Viewer 样式
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --accent: #E94335;
    --accent-dark: #C63A2E;
    --accent-light: #FFF0EE;
    --ribbon-bg: #F5F5F5;
    --ribbon-border: #E0E0E0;
    --ribbon-hover: #E8E8E8;
    --ribbon-active: #FDE8E6;
    --workspace-bg: #f2f4f7;
    --page-shadow: 0 2px 14px rgba(0,0,0,0.15);
    --font-ui: 'Segoe UI', system-ui, -apple-system, 'Microsoft YaHei', 'PingFang SC', sans-serif;
}

html, body {
    width: 100%; height: 100%; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
    font-family: var(--font-ui); background: var(--workspace-bg); color: #333;
}

/* ========== 标题栏 ========== */
#title-bar {
    display: flex; align-items: center; height: 28px; padding: 0 4px 0 10px;
    background: #FFF; color: #333; font-size: 11px; flex-shrink: 0;
    user-select: none; border-bottom: 1px solid #EEE;
}
.quick-access { display: flex; gap: 0; margin-right: 6px; }
.quick-access button {
    background: transparent; color: #777; border: none; padding: 4px 7px;
    cursor: pointer; font-size: 13px; border-radius: 2px; line-height: 1;
}
.quick-access button:hover { background: #F0F0F0; }
.title-doc { flex: 1; text-align: center; font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.window-ctrl { display: flex; margin-left: auto; }
.ctrl-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 28px; cursor: pointer; font-size: 9px; color: #AAA; }
.ctrl-btn:hover { background: #F0F0F0; color: #444; }
.ctrl-close:hover { background: var(--accent); color: #fff; }

/* ========== 功能区选项卡 ========== */
#ribbon-tabs {
    display: flex; padding: 0; background: #F8F8F8; flex-shrink: 0;
    user-select: none; height: 28px; align-items: stretch;
    border-bottom: 1px solid #E8E8E8;
}
.ribbon-tab {
    display: flex; align-items: center; padding: 0 14px; font-size: 12px; color: #777;
    cursor: pointer; transition: all 0.15s; position: relative; font-weight: 400;
}
.ribbon-tab:hover { color: #333; background: #F0F0F0; }
.ribbon-tab.active { color: var(--accent); font-weight: 600; background: #FFF; }
.ribbon-tab.active::after {
    content: ''; position: absolute; bottom: 0; left: 8px; right: 8px;
    height: 2px; background: var(--accent); border-radius: 2px 2px 0 0;
}

/* ========== 功能区命令 ========== */
#toolbar {
    display: flex; align-items: center; gap: 6px; padding: 6px 16px;
    background: #FFF; flex-shrink: 0; min-height: 44px; user-select: none;
    border-bottom: 1px solid #E8E8E8;
}
#toolbar > span { display: inline-flex; align-items: center; gap: 4px; }
.tb-left { flex: 1; display: flex; align-items: center; gap: 6px; }
.tb-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }

#toolbar button {
    background: transparent; color: #555; border: 1px solid transparent;
    padding: 6px 10px; border-radius: 3px; cursor: pointer;
    font-size: 13px; font-family: var(--font-ui); white-space: nowrap;
    transition: all 0.12s; display: inline-flex; align-items: center; gap: 5px;
}
#toolbar button:hover { background: #F5F5F5; color: #333; }
#toolbar button:active { background: #FDE8E6; color: var(--accent); }
#toolbar button:disabled { opacity: 0.25; cursor: not-allowed; }

#toolbar button svg { width: 18px; height: 18px; flex-shrink: 0; }

.page-info { font-size: 13px; display: flex; align-items: center; gap: 2px; }
#page-input {
    background: #fff; border: 1px solid #D0D0D0; border-radius: 3px; padding: 3px 5px;
    font-size: 12px; width: 44px; text-align: center; font-family: var(--font-ui);
}
#page-input:focus { border-color: var(--accent); outline: none; }

#zoom-select {
    background: #fff; border: 1px solid #D0D0D0; border-radius: 3px; padding: 3px 6px;
    font-size: 11px; cursor: pointer; font-family: var(--font-ui);
}
#zoom-select:focus { border-color: var(--accent); outline: none; }

/* ========== 主容器 ========== */
#main-container {
    display: flex; flex: 1; min-height: 0; overflow: hidden; position: relative;
}

/* ========== 画布工作区 ========== */
#canvas-area {
    flex: 1; overflow-y: auto; overflow-x: auto; display: block;
    padding: 32px 20px; background: var(--workspace-bg); scroll-behavior: smooth;
}
#canvas-wrapper { position: relative; width: 100%; }
#pages-container {
    display: flex; flex-direction: column; align-items: center;
    gap: 20px; width: 100%; padding-bottom: 20px;
}
.page-wrapper { position: relative; box-shadow: var(--page-shadow); background: #fff; }
.page-wrapper canvas { display: block; }
#pages-container canvas { display: block; background: #fff; }

/* ========== 文字覆盖层 ========== */
.text-overlay { position: absolute; top: 0; left: 0; pointer-events: none; overflow: hidden; }
.text-overlay span {
    position: absolute; white-space: pre; pointer-events: auto;
    cursor: text; color: transparent; user-select: text; -webkit-user-select: text;
}
.text-overlay span::selection { background: rgba(233,67,53,0.25); }
.text-overlay span::-moz-selection { background: rgba(233,67,53,0.25); }

/* ========== 状态栏 ========== */
#status-bar {
    height: 32px; background: #FAFAFA; border-top: 1px solid #E8E8E8;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 12px; font-size: 12px; color: #AAA; flex-shrink: 0; gap: 8px;
}
#status-bar > span { display: inline-flex; align-items: center; gap: 4px; }
#status-bar button {
    background: transparent; color: #666; border: 1px solid transparent;
    padding: 4px 8px; border-radius: 2px; cursor: pointer;
    font-size: 12px; font-family: var(--font-ui);
}
#status-bar button:hover { background: #EEE; color: #333; }
#status-bar select {
    background: transparent; border: 1px solid #DDD; border-radius: 2px;
    padding: 2px 6px; font-size: 12px; color: #666; cursor: pointer; font-family: var(--font-ui);
}
#status-bar button svg { width: 16px; height: 16px; }
#status-bar #page-input {
    width: 36px; border: 1px solid #DDD; border-radius: 2px; padding: 3px 4px;
    font-size: 12px; text-align: center; font-family: var(--font-ui); background: transparent;
}
#status-bar .page-info { font-size: 12px; color: #999; }

/* ========== 加载遮罩 ========== */
#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255,255,255,0.9); display: flex;
    flex-direction: column; align-items: center; justify-content: center; z-index: 9999;
}
.loading-spinner {
    width: 32px; height: 32px; border: 3px solid #EEE;
    border-top-color: var(--accent); border-radius: 50%;
    animation: spin 0.7s linear infinite; margin-bottom: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loading-text { color: #888; font-size: 13px; }

/* ========== 响应式 ========== */
@media (max-width: 768px) {
    #ribbon-tabs { display: none; }
    #title-bar { display: none; }
    #toolbar { display: none; }
    #canvas-area { padding: 4px; }
    #pages-container { gap: 12px; padding-bottom: 10px; }
    #status-bar { height: 28px; padding: 0 8px; font-size: 10px; }
    #status-bar button { padding: 2px 5px; font-size: 10px; }
    #status-bar button svg { width: 13px; height: 13px; }
    #status-bar select { font-size: 10px; padding: 1px 3px; }
    #status-bar #page-input { width: 28px; font-size: 10px; }
}
@media (max-width: 480px) {
    #status-bar { height: 26px; padding: 0 4px; gap: 2px; }
    #status-bar button { padding: 2px 4px; font-size: 9px; }
    #status-bar button svg { width: 12px; height: 12px; }
    #status-bar select { font-size: 9px; padding: 0 2px; }
    #status-bar #page-input { width: 24px; font-size: 9px; padding: 2px; }
    #status-bar .page-info { font-size: 9px; }
    #pages-container { gap: 6px; padding-bottom: 8px; }
}
