/* css/style.css */

/* --- Layout Structure --- */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* --- Header --- */
.header {
    background: #fff;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: var(--z-toolbar);
}

.menu-scroller {
    flex: 1;
    overflow-x: auto;
    margin-right: 15px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.menu-scroller::-webkit-scrollbar { display: none; }

.menu-items {
    display: flex;
    gap: 8px;
}

.menu-btn {
    background: transparent;
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    transition: 0.2s;
}
.menu-btn:hover { background: var(--bg-light); color: var(--text-main); }
.menu-btn.active { background-color: #EFF6FF; color: var(--primary); font-weight: 600; }
.special-menu { border: 1px solid var(--border); }

.preview-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    white-space: nowrap;
}
.preview-btn:hover { background: var(--primary-dark); }

/* --- Toolbar --- */
.toolbar-wrapper {
    background: #fff;
    padding: 5px 15px 10px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    position: relative;
    z-index: var(--z-toolbar);
}

.toolbar {
    display: flex;
    gap: 6px;
    align-items: flex-start; /* Important for expansion */
    height: 46px; /* Initial Height */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 6px 4px 0;
    flex-shrink: 0;
}

/* --- Dropdowns & Icons --- */
.tool-select-container {
    position: relative;
    display: inline-block;
    height: 36px;
    margin-top: 4px; /* Center vertical */
}

.tool-select {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; border-radius: 6px;
    cursor: pointer; color: var(--text-main);
    font-size: 13px;
    transition: 0.2s;
}
.tool-select:hover, .active-trigger { background: var(--bg-light); }

.tool-icon {
    font-size: 18px; padding: 6px;
    border-radius: 6px; cursor: pointer; color: #555;
    margin-top: 4px;
    display: flex;
}
.tool-icon:hover { background: var(--bg-light); color: #000; }

.dropdown-menu {
    position: absolute; top: 100%; left: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    padding: 6px;
    display: none;
    z-index: var(--z-dropdown);
}
.dropdown-menu.show { display: block; animation: slideDown 0.2s; }
@keyframes slideDown { from { opacity:0; transform:translateY(-5px); } to { opacity:1; transform:translateY(0); } }

.dropdown-item {
    padding: 8px 12px;
    border-radius: 4px; cursor: pointer;
    font-size: 13px; color: var(--text-main);
    display: flex; align-items: center; gap: 8px;
}
.dropdown-item:hover { background: var(--bg-light); color: var(--primary); }

/* --- Workspace Area --- */
.workspace {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    padding: 40px 20px;
    position: relative;
    background-color: var(--bg-workspace);
}

.paper {
    background: var(--paper-white);
    width: 816px; /* Letter/A4 Fixed Width */
    min-height: 1056px;
    padding: 60px; /* Default Margins */
    box-shadow: var(--paper-shadow);
    color: var(--text-main);
    font-size: 11pt; /* Print Size */
    line-height: 1.6;
    outline: none;
    transition: padding 0.3s, width 0.3s;
    /* Simulate print paper behavior */
}

/* --- Pages Sidebar (New) --- */
.pages-sidebar {
    position: fixed; top: 0; left: -280px;
    width: 280px; height: 100%;
    background: #fff;
    border-right: 1px solid var(--border);
    z-index: var(--z-sidebar);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.pages-sidebar.open { left: 0; }

.sidebar-header {
    padding: 15px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.close-sidebar-btn { background:none; border:none; font-size:18px; cursor:pointer; }

.sidebar-content { flex: 1; overflow-y: auto; padding: 10px; }
.nav-link { padding: 8px; font-size: 13px; color: var(--text-muted); cursor: pointer; border-radius: 4px; margin-bottom: 2px; }
.nav-link:hover { background: var(--bg-light); color: var(--primary); }
.nav-h1 { font-weight: 600; margin-top: 8px; }
.nav-h2 { margin-left: 16px; }

/* --- Toasts & Modals --- */
.toast-container {
    position: fixed; bottom: 60px; left: 50%;
    transform: translateX(-50%);
    display: flex; flex-direction: column; gap: 10px;
    z-index: var(--z-toast); pointer-events: none;
}
.toast {
    background: #1F2937; color: #fff;
    padding: 12px 24px; border-radius: 30px;
    font-size: 13px; display: flex; align-items: center; gap: 10px;
    box-shadow: var(--shadow-lg); animation: fadeUp 0.3s;
}
@keyframes fadeUp { from {opacity:0; transform:translateY(10px);} to {opacity:1; transform:translateY(0);} }

/* Generic Modal Overlay */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(2px);
    z-index: var(--z-modal);
    display: none; justify-content: center; align-items: center;
}
.modal-overlay.open { display: flex; }

/* Prompt Card */
.prompt-card { background: #fff; padding: 24px; border-radius: 12px; width: 90%; max-width: 380px; box-shadow: var(--shadow-lg); }
.prompt-card h3 { margin-bottom: 16px; font-size: 16px; }
.custom-input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; margin-bottom: 20px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.btn-primary { background: var(--primary); color: #fff; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; }
.btn-secondary { background: var(--bg-light); color: var(--text-main); border: 1px solid var(--border); padding: 8px 16px; border-radius: 6px; cursor: pointer; }

/* Viewer Modal (PDF/Preview) */
.preview-container {
    background: #333;
    width: 90%; height: 90%;
    border-radius: 12px; overflow: hidden;
    display: flex; flex-direction: column;
}
.preview-header {
    background: #222; color: #fff; padding: 12px 20px;
    display: flex; justify-content: space-between; align-items: center;
}
.close-modal-icon { background:none; border:none; color:#fff; font-size:20px; cursor:pointer; }
.preview-body { flex: 1; overflow: auto; padding: 40px; display: flex; justify-content: center; background: #555; }

/* Light Theme Preview (Print) */
.light-theme-preview .paper-clone {
    background: #fff; box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    margin: 20px; padding: 60px;
    width: 816px; min-height: 1056px;
    color: #000; pointer-events: none;
}

/* Footer */
.footer {
    height: 40px; background: #fff; border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    padding: 0 16px; font-size: 12px; color: var(--text-muted);
    flex-shrink: 0; z-index: 100;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
    /* Hide specific non-essential elements on tiny screens */
    .menu-btn { padding: 6px 10px; }
    .header { padding: 8px; }
    .preview-btn { padding: 6px 12px; }
    
    .workspace {
        padding: 20px 10px; /* Less padding around paper */
        display: block; /* Allows horizontal scrolling of paper */
        overflow-x: auto;
    }
    
    .paper {
        /* On mobile, we keep the paper fixed width so it formats like a Doc */
        /* But we scale it down slightly visually or rely on overflow */
        margin: 0 auto; 
        transform-origin: top left;
        padding: 40px;
    }

    /* Modal adjustments */
    .preview-container { width: 100%; height: 100%; border-radius: 0; }
    
    .pages-sidebar { width: 85%; left: -85%; }
}