﻿/* =========================================================
   1. CORE VARIABLES & RESET
   ========================================================= */
:root {
    --bg-dark: #1e1e1e;
    --bg-panel: #252526;
    --bg-header: #2d2d2d;
    --text-main: #d4d4d4;
    --text-muted: #858585;
    --border: #3e3e42;
    --gold: #cd9b47;
    --danger: #d9534f;
    --success: #4caf50;
    --accent: #777;
}

* { box-sizing: border-box; margin: 0; padding: 0; outline: none; }
body {
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: 'Segoe UI', Tahoma, sans-serif;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: #1e1e1e; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; border: 1px solid #1e1e1e; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* =========================================================
   2. HEADER SECTION (EXACTLY MATCHING MAIN SITE)
   ========================================================= */
.main-header {
    height: 80px; background: var(--bg-header); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; padding: 0 15px; flex-shrink: 0; z-index: 20; gap: 20px; overflow: hidden;
}
.header-left { flex-shrink: 0; display: flex; align-items: center; height: 100%; }
.header-logo { height: 72px; width: auto; object-fit: contain; display: block; }

.tabs-container {
    flex-grow: 1; display: flex; gap: 5px; height: 100%; align-items: center;
    overflow-x: auto; overflow-y: hidden; -ms-overflow-style: none; scrollbar-width: none;
}
.tabs-container::-webkit-scrollbar { display: none; }

.tab-btn {
    background: transparent; border: none; color: #aaa; padding: 0 15px; height: 100%;
    font-size: 14px; cursor: pointer; border-bottom: 4px solid transparent;
    white-space: nowrap; font-weight: 500; display: flex; align-items: center; justify-content: center;
}
.tab-btn:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab-btn.active { color: #fff; border-bottom: 4px solid var(--gold); font-weight: 700; background: rgba(255,255,255,0.05); }

.header-right { flex-shrink: 0; display: flex; align-items: center; gap: 15px; height: 100%; flex-wrap: nowrap; }
.header-login-btn { background: var(--gold); color: #000; border: none; padding: 6px 8px; font-weight: bold; border-radius: 4px; cursor: pointer; font-size: 12px; display: block; white-space: nowrap; transition: 0.2s; }
.header-login-btn:hover { transform: scale(1.05); }

.usp-container { height: 30px; align-self: center; border-left: 1px solid rgba(255, 255, 255, 0.4); margin-left: 25px; padding-left: 10px; margin-right: 15px; min-width: 200px; overflow: hidden; display: flex; align-items: flex-start; }
.usp-slider { display: flex; flex-direction: column; text-align: center; width: 100%; animation: slideUp 12s infinite cubic-bezier(0.4, 0, 0.2, 1); }
.usp-item { height: 30px; display: flex; align-items: center; justify-content: center; padding-top: 0; white-space: nowrap; font-size: 13px; font-weight: 500; color: #ccc; letter-spacing: 0.5px; line-height: 1; }
@keyframes slideUp { 0%, 20% { transform: translateY(0); } 25%, 45% { transform: translateY(-30px); } 50%, 70% { transform: translateY(-60px); } 75%, 95% { transform: translateY(-90px); } 100% { transform: translateY(-120px); } }

.close-art-btn { background: transparent; color: #d9534f; border: 1px solid rgba(217, 83, 79, 0.3); padding: 5px 12px; border-radius: 4px; font-weight: bold; cursor: pointer; font-size: 12px; transition: 0.2s; }
.close-art-btn:hover { background: rgba(217, 83, 79, 0.1); border-color: #d9534f; }

/* =========================================================
   3. APP LAYOUT & LEFT SIDEBAR
   ========================================================= */
.app-body { display: flex; flex-grow: 1; width: 100%; overflow: hidden; }

.left-sidebar { width: 260px; background: var(--bg-panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; z-index: 10; transition: width 0.3s ease, transform 0.3s ease; }

.fixed-sidebar-top { padding: 12px 15px; border-bottom: 1px solid var(--border); background: #202020; flex-shrink: 0; }
.master-mode-switch { display: flex; background: #151515; border-radius: 6px; padding: 3px; border: 1px solid #333; position: relative; }
.mode-btn { flex: 1; display: flex; align-items: center; justify-content: center; padding: 6px 0; color: #777; font-size: 12px; font-weight: 700; text-decoration: none; border-radius: 4px; transition: all 0.3s ease; letter-spacing: 0.5px; }
.mode-btn:hover:not(.active) { color: #ccc; }
.mode-btn.active { background: #2b2b2b; color: var(--gold); box-shadow: 0 2px 8px rgba(0,0,0,0.5); border: 1px solid #444; }

.sb-header-row { height: 50px; display: flex; align-items: center; justify-content: space-between; padding: 0 15px; border-bottom: 1px solid var(--border); background: transparent; flex-shrink: 0; }
.sb-title-main { font-weight: bold; color: var(--gold); font-size:12px; letter-spacing: 1px; }

.sidebar-scroll { flex-grow: 1; overflow-y: auto; padding: 15px; }
.sb-section { margin-bottom: 25px; border-bottom: 1px solid #333; padding-bottom: 15px; }
.sb-title { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 10px; white-space: nowrap; border-bottom: none; display: block; }

.check-row-wrapper { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0; padding-left: 0; cursor: pointer; }
.check-row-wrapper .label-text { color: #ccc; font-weight: 500; font-size: 13px; transition: 0.2s; }
.check-row-wrapper:hover .label-text { color: #fff; }
.arrow-btn { cursor: pointer; color: #666; font-size: 10px; padding: 8px; transition: transform 0.3s ease; }
.arrow-btn.open { transform: rotate(180deg); color: var(--gold); }
.sub-group { padding-left: 20px; margin-bottom: 8px; border-left: 1px solid #444; margin-left: 10px; margin-top: 5px; }
.check-item { display: flex; align-items: center; font-size: 13px; color: #aaa; cursor: pointer; margin-bottom: 4px; padding: 6px 8px; border-radius: 4px; transition: 0.2s; }
.check-item:hover { background: #333; color: #fff; }
.check-item input[type="radio"], .check-item input[type="checkbox"] { margin-right: 12px; accent-color: var(--gold); width: 14px; height: 14px; cursor: pointer; }

/* =========================================================
   4. MAIN WORKSPACE & ORGANIZER (FIXED GRID)
   ========================================================= */
.main-area { flex-grow: 1; display: flex; flex-direction: column; background: var(--bg-dark); position: relative; }
.editor-wrapper { flex-grow: 1; position: relative; background: #1e1e1e; display: flex; flex-direction: column; }

.pdf-drop-zone { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #888; transition: 0.3s; }
.pdf-drop-zone.drag-over { background: rgba(205, 155, 71, 0.05); border: 2px dashed var(--gold); }
.upload-btn { padding: 10px 24px; background: var(--gold); color: #000; font-weight: bold; border: none; border-radius: 4px; cursor: pointer; font-size: 14px; transition: 0.2s; }
.upload-btn:hover { transform: scale(1.05); }
.upload-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

#pagesGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 15px; padding-bottom: 150px; }
.page-card { background: #2b2b2b; border: 1px solid #444; border-radius: 6px; display: flex; flex-direction: column; position: relative; user-select: none; transition: transform 0.2s, box-shadow 0.2s; overflow: hidden; }
.page-card:hover { border-color: var(--gold); transform: translateY(-3px); box-shadow: 0 6px 15px rgba(0,0,0,0.5); z-index: 10; }

.thumb-wrapper { width: 100%; aspect-ratio: 1 / 1.414; background: #111; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.page-thumb-img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.3s ease; display: block; }

.wm-preview-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; overflow: hidden; z-index: 15; }
.pg-num-preview-overlay { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(255, 255, 255, 0.9); color: #000; font-size: 9px; padding: 2px 6px; border-radius: 3px; pointer-events: none; z-index: 16; font-weight: bold; white-space: nowrap; box-shadow: 0 1px 3px rgba(0,0,0,0.5); }

.card-actions { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; opacity: 0; transition: 0.2s; z-index: 20; }
.page-card:hover .card-actions { opacity: 1; }
.mini-btn { width: 24px; height: 24px; background: rgba(0,0,0,0.8); color: #fff; border: 1px solid #444; border-radius: 4px; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 12px; }
.mini-btn:hover { background: var(--gold); color: #000; border-color: var(--gold); }
.mini-btn.del:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.seq-badge { position: absolute; top: 5px; left: 5px; background: var(--gold); color: #000; font-size: 10px; font-weight: bold; padding: 2px 6px; border-radius: 3px; z-index: 20; box-shadow: 0 2px 4px rgba(0,0,0,0.5); }

.card-footer { padding: 6px; background: #1e1e1e; border-top: 1px solid #333; display: flex; flex-direction: column; gap: 5px; }
.file-info-mini { font-size: 11px; color: #aaa; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 5px; }

.expand-btn, .undo-btn { width: 100%; background: #333; color: var(--gold); border: 1px solid #444; font-size: 10px; padding: 5px; border-radius: 3px; cursor: pointer; font-weight: bold; transition: 0.2s; text-transform: uppercase; }
.expand-btn:hover { background: var(--gold); color: #000; }
.undo-btn { background: #a94442; color: #fff; border-color: #8a3130; }
.undo-btn:hover { background: var(--danger); }

.add-more-box { border: 2px dashed #444; border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; aspect-ratio: 1 / 1.414; cursor: pointer; color: #888; transition: 0.2s; }
.add-more-box:hover { border-color: var(--gold); background: rgba(205, 155, 71, 0.1); color: #ccc; }

.floating-action-bar { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%); background: #252526; border: 1px solid var(--gold); padding: 15px 30px; border-radius: 50px; box-shadow: 0 10px 30px rgba(0,0,0,0.8); z-index: 1000; text-align: center; min-width: 300px; animation: slideUpAction 0.3s ease; }
@keyframes slideUpAction { from { bottom: -100px; } to { bottom: 30px; } }
.action-big-btn { background: var(--gold); color: #000; border: none; padding: 12px 30px; font-weight: bold; font-size: 14px; border-radius: 25px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; transition: 0.2s; }
.action-big-btn:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(205, 155, 71, 0.4); }
.action-big-btn:disabled { background: #444; color: #888; cursor: not-allowed; transform: none; box-shadow: none; }
.action-big-btn.download { background: var(--success); color: #fff; border: 1px solid #3e8e41; }

#canvasContainer { border: 1px dashed #555; margin-bottom: 50px; display: flex; justify-content: center; align-items: center; background: #333; padding: 20px; overflow: auto; }

/* =========================================================
   RIGHT SIDEBAR
   ========================================================= */
.right-sidebar { width: 220px; background: var(--bg-panel); border-left: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; z-index: 10; }
.socials-mini { display: flex; gap: 10px; }
.socials-mini a { color: #666; transition: 0.3s; }
.socials-mini a:hover { color: var(--gold); }
.buy-pro-btn { display: inline-block; background: var(--gold); color: #000; padding: 5px 15px; font-weight: bold; text-decoration: none; border-radius: 4px; font-size: 12px; transition: 0.3s; }
.buy-pro-btn:hover { transform: scale(1.05); }

.article-link { display: block; padding: 12px 15px; color: #aaa; text-decoration: none; border-bottom: 1px solid #333; font-size: 13px; transition: 0.2s; background: none; border: none; width: 100%; text-align: left; cursor: pointer; display: flex; align-items: center; }
.article-link svg { margin-right: 8px; fill: #aaa; transition: 0.2s; }
.article-link:hover { background: #333; color: var(--gold); padding-left: 20px; }
.article-link:hover svg { fill: var(--gold); }
.ad-box { margin-top: 20px; width: 100%; height: 600px; background: #252526; border: 1px dashed #444; display: flex; align-items: center; justify-content: center; color: #666; font-size: 12px; text-align: center; }

.info-container { display: none; width: 100%; height: 100%; background: #1e1e1e; color: #d4d4d4; padding: 40px; overflow-y: auto; font-size: 16px; line-height: 1.6; animation: fadeIn 0.3s ease; }
.info-container h2 { color: var(--gold); border-bottom: 1px solid #333; padding-bottom: 10px; margin-bottom: 20px; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* =========================================================
   MOBILE RESPONSIVE
   ========================================================= */
.mobile-menu-btn { display: none; background: none; border: none; font-size: 24px; color: #aaa; cursor: pointer; margin-right: 15px; }
.mobile-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 99; backdrop-filter: blur(2px); }
.mobile-overlay.active { display: block; }

@media (max-width: 768px) {
    .main-header { height: 60px; padding: 0 10px; gap: 10px; justify-content: space-between; }
    .header-logo { height: 35px; }
    .header-login-btn { padding: 4px 10px; font-size: 11px; }
    .usp-container { display: none !important; }
    .mobile-menu-btn { display: block; }
    .tabs-container { overflow-x: auto; padding-bottom: 0; gap: 10px; }
    .tab-btn { font-size: 13px; padding: 0 10px; white-space: nowrap; }
    .pro-badge { display: none; }
    .left-sidebar { position: absolute; left: 0; top: 0; bottom: 0; width: 80%; max-width: 300px; z-index: 100; transform: translateX(-100%); box-shadow: 5px 0 15px rgba(0,0,0,0.5); }
    .left-sidebar.mobile-active { transform: translateX(0); }
    .right-sidebar { width: 45px !important; min-width: 45px !important; }
    .right-sidebar .article-link, .right-sidebar .ad-box, .right-sidebar .buy-pro-btn { display: none !important; }
    .right-sidebar .socials-mini { flex-direction: column; gap: 20px; margin: 20px 0 !important; }
    #pagesGrid { grid-template-columns: repeat(2, 1fr); }
}

#btnClearAll { background: #444 !important; color: #ccc !important; font-weight: 600; padding: 8px 15px; border-radius: 4px; font-size: 11px; text-transform: uppercase; text-decoration: none; transition: 0.2s; border: 1px solid #555; }
#btnClearAll:hover { background: #555 !important; color: #fff !important; border-color: #777; }

/* =========================================================
   5. BOTTOM BAR & FOOTER (MATCHING TEXT EDITOR)
   ========================================================= */
.bottom-bar { height: 35px; background: var(--bg-panel); border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; padding: 0 15px; font-size: 12px; color: #aaa; flex-shrink: 0; }
.stat-group { display: flex; gap: 15px; min-width: 150px; }
.center-stats { justify-content: center; flex-grow: 1; }
.right-stats { justify-content: flex-end; color: #666; }
.highlight { font-weight: bold; color: var(--gold); }

.sidebar-footer { padding: 15px; border-top: 1px solid var(--border); flex-shrink: 0; background: var(--bg-panel); position: sticky; bottom: 0; z-index: 10; }
.footer-row { display: flex; align-items: center; justify-content: center; gap: 8px; color: #666; }
.footer-text-btn { background: none; border: none; color: #888; cursor: pointer; font-size: 13px; padding: 6px 10px; transition: 0.2s; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.footer-text-btn svg { width: 16px; height: 16px; opacity: 0.7; }
.footer-text-btn:hover { color: #fff; }
.footer-text-btn:hover svg { opacity: 1; }
.footer-sep { color: #444; font-size: 14px; }

/* =========================================================
   6. MODALS / POPUPS (MATCHING TEXT EDITOR)
   ========================================================= */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); backdrop-filter: blur(2px); z-index: 9999; justify-content: center; align-items: center; }
.modal-overlay.active { display: flex; }
.modal-box { background: #252526; width: 500px; max-width: 90%; border-radius: 8px; box-shadow: 0 15px 30px rgba(0,0,0,0.6); border: 1px solid #444; display: flex; flex-direction: column; max-height: 85vh; color: #ccc; }
.small-box { width: 350px; }
.modal-header { padding: 15px 20px; border-bottom: 1px solid #333; display: flex; justify-content: space-between; align-items: center; flex-shrink: 0; }
.modal-header h3 { margin: 0; font-size: 16px; }
.close-modal { font-size: 24px; cursor: pointer; color: #aaa; transition: 0.2s; }
.close-modal:hover { color: #fff; }
.modal-body { padding: 20px; font-size: 14px; line-height: 1.6; overflow-y: auto; }