/* ===== CSS VARIABLES ===== */
:root {
    --bg-primary: #1e1e1e;
    --bg-secondary: #2d2d2d;
    --bg-tertiary: #3a3a3a;
    --bg-hover: #4a4a4a;
    --bg-active: #0078d4;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border-color: #444;
    --border-light: #555;
    --accent: #0078d4;
    --accent-hover: #1a8ae8;
    --accent-light: rgba(0, 120, 212, 0.15);
    --danger: #e74c3c;
    --success: #27ae60;
    --ribbon-bg: #2b2b2b;
    --ribbon-tab-bg: #333;
    --ribbon-tab-active: #2b2b2b;
    --page-shadow: 0 2px 20px rgba(0, 0, 0, 0.5);
    --dialog-bg: #333;
    --transition: 0.15s ease;
    --radius: 4px;
    --radius-lg: 8px;
}

/* ===== RESET ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
}

/* ===== TITLE BAR ===== */
.title-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 32px;
    background: linear-gradient(135deg, #1a1a2e, #16213e);
    padding: 0 12px;
    user-select: none;
    flex-shrink: 0;
}

.title-bar-left,
.title-bar-right {
    display: flex;
    align-items: center;
    gap: 4px;
}

.title-bar-center {
    font-size: 12px;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
}

.app-icon {
    font-size: 16px;
}

.title-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    font-size: 14px;
    transition: var(--transition);
}

.title-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.title-btn.active {
    color: var(--accent);
}

/* ===== RIBBON TABS ===== */
.ribbon-tabs {
    display: flex;
    gap: 0;
    background: #222;
    padding: 0 8px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.ribbon-tab {
    padding: 8px 18px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 500;
    transition: var(--transition);
    border-bottom: 2px solid transparent;
    letter-spacing: 0.3px;
}

.ribbon-tab:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.ribbon-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--ribbon-bg);
}

/* ===== FILE MENU ===== */
.file-menu {
    display: none;
    position: absolute;
    top: 32px;
    left: 0;
    width: 280px;
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    padding: 8px 0;
}

.file-menu.show {
    display: block;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: var(--transition);
}

.file-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.file-separator {
    height: 1px;
    background: var(--border-color);
    margin: 6px 16px;
}

.file-section-title {
    padding: 6px 20px;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ===== RIBBON PANELS ===== */
.ribbon-container {
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-color);
}

.ribbon-panel {
    display: none;
    background: var(--ribbon-bg);
    padding: 6px 12px;
    min-height: 80px;
    align-items: stretch;
    gap: 4px;
    overflow-x: auto;
}

.ribbon-panel.active {
    display: flex;
}

.ribbon-group {
    display: flex;
    flex-direction: column;
    padding: 0 8px;
    position: relative;
}

.group-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
    padding-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    flex-shrink: 0;
}

.group-content {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
    padding: 2px 0;
}

.group-content.stack {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
}

.group-content.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    width: 100%;
}

/* Ensure buttons in stack align left */
.group-content.stack .ribbon-btn-sm {
    justify-content: flex-start;
    width: 100%;
    text-align: left;
}

.ribbon-sep {
    width: 1px;
    background: var(--border-color);
    margin: 4px 4px;
    flex-shrink: 0;
}

/* Ribbon Buttons */
.ribbon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 11px;
    min-width: 52px;
    white-space: nowrap;
}

.ribbon-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.ribbon-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.rbtn-icon {
    font-size: 18px;
    line-height: 1;
}

.rbtn-label {
    font-size: 10px;
    color: var(--text-secondary);
}

.ribbon-btn-sm {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
    font-size: 12px;
    display: flex;
    /* Ensure flex */
    align-items: center;
    /* Vertical center */
    gap: 8px;
    /* Space between icon and text */
    white-space: nowrap;
}

.rbtn-icon-sm {
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.ribbon-btn-sm:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

/* Font Controls */
.font-group {
    flex-direction: column;
    gap: 4px;
}

.font-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.font-select {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    min-width: 150px;
    height: 28px;
    /* Standard Height */
    color: var(--text-primary);
    font-size: 12px;
    transition: var(--transition);
}

.font-select:hover {
    border-color: var(--accent);
}

.font-select .caret {
    margin-left: auto;
    font-size: 10px;
    color: var(--text-muted);
}

.size-select {
    padding: 0 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    width: 52px;
    height: 28px;
    /* Standard Height */
    font-size: 12px;
}

.fmt-btn {
    width: 32px;
    /* Slightly wider */
    height: 28px;
    /* Standard Height */
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.fmt-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-color);
}

.fmt-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
}

.fmt-sep {
    width: 1px;
    height: 20px;
    background: var(--border-color);
    margin: 0 4px;
}

.color-wrap {
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
}

.color-wrap label {
    font-size: 14px;
    cursor: pointer;
}

/* Input Fields in Ribbon */
/* Color Input Styling */
.ribbon-panel input[type="color"] {
    -webkit-appearance: none;
    border: none;
    width: 50px;
    /* Wider swatch */
    height: 28px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius);
    overflow: hidden;
    /* Clip rounded corners */
}

.ribbon-panel input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.ribbon-panel input[type="color"]::-webkit-color-swatch {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.ribbon-panel input[type="number"],
.ribbon-panel input[type="text"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius);
    padding: 0 6px;
    /* Vertical centering */
    font-size: 12px;
    width: 60px;
    /* Fixed width for better alignment */
    height: 28px;
    /* Standard Height */
    outline: none;
    transition: var(--transition);
}

.ribbon-panel input[type="number"]:focus,
.ribbon-panel input[type="text"]:focus {
    border-color: var(--accent);
    background: var(--bg-hover);
}

/* Range Sliders */
.ribbon-panel input[type="range"] {
    appearance: none;
    -webkit-appearance: none;
    width: 100px;
    /* Wider sliders */
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    outline: none;
    margin: 8px 0;
}

.ribbon-panel input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: var(--text-secondary);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--transition);
}

.ribbon-panel input[type="range"]::-webkit-slider-thumb:hover {
    background: var(--accent);
    transform: scale(1.1);
}

/* Group Labels */
.group-label {
    font-size: 11px;
    /* Readable size */
    color: var(--text-muted);
    text-align: center;
    margin-top: auto;
    padding-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Paragraph Group */
.para-group {
    flex-direction: column;
    gap: 4px;
}

.para-row {
    display: flex;
    align-items: center;
    gap: 4px;
    /* Increased gap */
}

.mini-label {
    font-size: 11px;
    /* Readable */
    color: var(--text-muted);
    margin-left: 8px;
    /* More spacing */
}

.mini-select {
    padding: 2px 4px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    width: 60px;
    height: 28px;
    /* Standard Height */
}

/* Specific selector to override generic ribbon input */
.ribbon-panel .mini-input {
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    width: 60px;
    height: 28px;
    /* Standard Height */
}

/* Styles */
.styles-group {
    gap: 6px;
}

.style-preset {
    padding: 0 12px;
    /* Use line-height/height for centering */
    height: 28px;
    /* Standard Height */
    line-height: 26px;
    /* 28px - 2px border */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.style-preset:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.style-preset.heading {
    font-size: 14px;
    /* Standardized */
    font-weight: 700;
    color: var(--accent);
}

/* Properties */
.props-group {
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    /* Center vertically */
}

.prop-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    height: 30px;
    /* Slightly taller containers */
}

.prop-row label {
    min-width: 80px;
    /* Increased for better alignment */
    color: var(--text-secondary);
    text-align: right;
    padding-right: 6px;
}

.prop-row input[type="range"] {
    width: 100px;
    height: 4px;
    accent-color: var(--accent);
    margin: 0;
}

.prop-val {
    font-size: 11px;
    color: var(--text-muted);
    min-width: 32px;
    text-align: right;
}

.tool-select {
    padding: 0 8px;
    height: 28px;
    /* Standard Height */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
}

/* Margin Presets */
.margin-preset {
    padding: 0 12px;
    height: 28px;
    /* Standard Height */
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 12px;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.margin-preset:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ===== FONT DROPDOWN ===== */
.font-dropdown {
    display: none;
    position: absolute;
    top: 120px;
    left: 80px;
    width: 280px;
    max-height: 400px;
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    z-index: 3000;
    overflow: hidden;
}

.font-dropdown.show {
    display: block;
}

.font-search {
    width: 100%;
    padding: 6px 14px;
    height: 36px;
    background: var(--bg-primary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.font-list {
    max-height: 350px;
    overflow-y: auto;
    padding: 4px 0;
}

.font-category-header {
    padding: 6px 14px;
    font-size: 10px;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.font-separator {
    height: 1px;
    background: var(--border-color);
    margin: 4px 12px;
}

.font-item {
    padding: 6px 14px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
    color: var(--text-primary);
}

.font-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.font-list::-webkit-scrollbar {
    width: 6px;
}

.font-list::-webkit-scrollbar-track {
    background: transparent;
}

.font-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* ===== MAIN AREA ===== */
.main-area {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Navigation Panel */
.nav-panel {
    width: 0;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    transition: width 0.3s ease;
    flex-shrink: 0;
}

.nav-panel.show {
    width: 180px;
}

.nav-header {
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.nav-thumbnails {
    padding: 8px;
}

.thumbnail {
    padding: 4px;
    margin-bottom: 6px;
    border: 2px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
}

.thumbnail.active {
    border-color: var(--accent);
}

.thumbnail:hover {
    border-color: var(--border-light);
}

.thumb-preview {
    background: #fff;
    height: 80px;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 18px;
    font-weight: 600;
}

.outline-content {
    padding: 8px;
}

.outline-item {
    padding: 6px 10px;
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
}

.outline-item:hover {
    background: var(--bg-hover);
}

.outline-page {
    font-weight: 600;
    font-size: 12px;
    color: var(--accent);
}

.outline-heading {
    padding-left: 16px;
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Document Area */
.document-area {
    flex: 1;
    overflow: auto;
    background: #1a1a1a;
    padding: 20px;
}

.pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    min-height: 100%;
}

.pages-container.side-by-side {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
}

.page-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* Page */
.page {
    position: relative;
    background: #ffffff;
    box-shadow: var(--page-shadow);
    overflow: hidden;
    transition: transform 0.2s ease;
}

.page.active {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.page-label {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 0;
}

.page-number {
    pointer-events: none;
}

/* Margin Guides */
.margin-guides {
    pointer-events: none;
}

/* ===== ELEMENTS ===== */
.element-wrapper {
    position: absolute;
    cursor: move;
    border: 1px solid transparent;
    transition: border-color 0.1s;
}

.element-wrapper:hover {
    border-color: rgba(0, 120, 212, 0.4);
}

.element-wrapper.selected {
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 1px rgba(0, 120, 212, 0.3);
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border: 1px solid #fff;
    border-radius: 50%;
    z-index: 100;
}

.resize-nw {
    top: -4px;
    left: -4px;
    cursor: nw-resize;
}

.resize-n {
    top: -4px;
    left: 50%;
    transform: translateX(-50%);
    cursor: n-resize;
}

.resize-ne {
    top: -4px;
    right: -4px;
    cursor: ne-resize;
}

.resize-e {
    top: 50%;
    right: -4px;
    transform: translateY(-50%);
    cursor: e-resize;
}

.resize-se {
    bottom: -4px;
    right: -4px;
    cursor: se-resize;
}

.resize-s {
    bottom: -4px;
    left: 50%;
    transform: translateX(-50%);
    cursor: s-resize;
}

.resize-sw {
    bottom: -4px;
    left: -4px;
    cursor: sw-resize;
}

.resize-w {
    top: 50%;
    left: -4px;
    transform: translateY(-50%);
    cursor: w-resize;
}

/* Element Types */
.element-textbox {
    outline: none;
    cursor: text;
    word-wrap: break-word;
}

.element-textbox:focus {
    box-shadow: inset 0 0 0 1px rgba(0, 120, 212, 0.3);
}

.element-image-container {
    overflow: hidden;
}

.element-image-container img {
    pointer-events: none;
}

.element-table {
    color: #333;
}

.element-table td {
    outline: none;
}

.element-table td:focus {
    box-shadow: inset 0 0 0 2px var(--accent);
}

.element-watermark {
    pointer-events: none;
}

.element-signature {
    cursor: pointer;
}

.element-comment {
    cursor: default;
}

/* ===== FIND & REPLACE ===== */
.find-replace-panel {
    display: none;
    position: fixed;
    top: 160px;
    right: 20px;
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 5000;
    width: 340px;
}

.find-replace-panel.show {
    display: block;
}

.fr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

.fr-header button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}

.fr-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
}

.fr-row label {
    min-width: 55px;
    font-size: 12px;
    color: var(--text-secondary);
}

.fr-row input {
    flex: 1;
    padding: 5px 8px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    outline: none;
}

.fr-row input:focus {
    border-color: var(--accent);
}

.fr-row button {
    padding: 5px 10px;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition);
}

.fr-row button:hover {
    background: var(--accent-hover);
}

/* ===== DIALOGS ===== */
.dialog-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 6000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.dialog-overlay.show {
    display: flex;
}

.dialog {
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 380px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

.dialog-wide {
    width: 500px;
}

.dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.dialog-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.dialog-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 18px;
    padding: 4px;
}

.dialog-close:hover {
    color: var(--text-primary);
}

.dialog-body {
    padding: 18px;
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 7px 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
    transition: var(--transition);
}

.form-group input:focus {
    border-color: var(--accent);
}

.dialog-btn {
    padding: 8px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.dialog-btn:hover {
    background: var(--bg-hover);
}

.dialog-btn.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.dialog-btn.primary:hover {
    background: var(--accent-hover);
}

/* Table Grid Selector */
.table-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 10px;
}

.grid-cell {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: 2px;
    cursor: pointer;
    transition: var(--transition);
}

.grid-cell.highlight {
    background: var(--accent-light);
    border-color: var(--accent);
}

.grid-cell:hover {
    background: var(--accent);
}

.table-size-label {
    text-align: center;
    padding: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Shape Dropdown */
.dropdown-wrapper {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 4000;
    padding: 8px;
}

.dropdown-menu.show {
    display: block;
}

.shape-dropdown {
    width: 200px;
}

.shape-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.shape-btn {
    width: 56px;
    height: 48px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 22px;
    color: var(--text-primary);
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.shape-btn:hover {
    background: var(--accent-light);
    border-color: var(--accent);
}

/* Signature */
.sig-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 14px;
}

.sig-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.sig-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.sig-canvas {
    width: 100%;
    height: 150px;
    background: #fff;
    border-radius: var(--radius);
    cursor: crosshair;
}

.sig-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    justify-content: flex-end;
}

/* ===== OCR PROGRESS ===== */
.ocr-progress {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    width: 300px;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    overflow: hidden;
    z-index: 7000;
}

.ocr-progress.show {
    display: block;
}

.ocr-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #27ae60);
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 3px;
}

/* ===== STATUS BAR ===== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 26px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 0 12px;
    flex-shrink: 0;
}

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

.status-left {
    font-size: 11px;
    color: var(--text-secondary);
}

.status-center {
    font-size: 11px;
    color: var(--text-muted);
}

.status-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: var(--radius);
}

.status-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

#zoom-level {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: center;
}

/* ===== CONTEXT MENU ===== */
.context-menu {
    position: fixed;
    background: var(--dialog-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 9000;
    min-width: 200px;
    padding: 4px 0;
}

.context-item {
    display: flex;
    justify-content: space-between;
    padding: 7px 16px;
    cursor: pointer;
    font-size: 12.5px;
    transition: var(--transition);
}

.context-item:hover {
    background: var(--accent-light);
    color: var(--accent);
}

.context-shortcut {
    font-size: 11px;
    color: var(--text-muted);
}

.context-separator {
    height: 1px;
    background: var(--border-color);
    margin: 3px 10px;
}

/* ===== VIEW MODES ===== */
.view-read .page {
    max-width: 700px;
    margin: 0 auto;
}

.view-web-layout .page {
    width: 100% !important;
    max-width: none;
    box-shadow: none;
    border: none;
}

.view-outline .page {
    max-width: 600px;
    margin: 0 auto;
}

body.focus-active .title-bar,
body.focus-active .ribbon-tabs,
body.focus-active .ribbon-container,
body.focus-active .status-bar,
body.focus-active .nav-panel {
    display: none;
}

body.focus-active .document-area {
    padding: 40px;
}

body.immersive-active .title-bar,
body.immersive-active .ribbon-tabs,
body.immersive-active .ribbon-container,
body.immersive-active .status-bar {
    display: none;
}

body.immersive-active .document-area {
    background: #111;
    padding: 60px;
}

body.immersive-active .page {
    background: #1a1a1a;
    color: #e0e0e0;
    max-width: 700px;
    margin: 0 auto;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ===== RESPONSIVE ===== */
@media(max-width:1024px) {
    .ribbon-panel {
        min-height: auto;
        flex-wrap: wrap;
    }

    .font-select {
        min-width: 100px;
    }

    .styles-group {
        display: none;
    }

    .nav-panel.show {
        width: 120px;
    }
}

@media(max-width:768px) {
    .ribbon-panel {
        padding: 4px 6px;
    }

    .ribbon-btn .rbtn-label {
        display: none;
    }

    .ribbon-btn {
        min-width: 36px;
        padding: 4px 6px;
    }

    .group-label {
        display: none;
    }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px)
    }

    to {
        opacity: 1;
        transform: translateY(0)
    }
}

.dialog-overlay.show .dialog {
    animation: fadeIn 0.2s ease;
}

.font-dropdown.show {
    animation: fadeIn 0.15s ease;
}

.file-menu.show {
    animation: fadeIn 0.15s ease;
}

.context-menu {
    animation: fadeIn 0.1s ease;
}

/* ===== LOCKED ELEMENTS ===== */
.element-wrapper.locked {
    cursor: default !important;
    opacity: 0.85;
}

.element-wrapper.locked::after {
    content: '🔒';
    position: absolute;
    top: -8px;
    right: -8px;
    font-size: 10px;
    background: var(--bg-secondary);
    border-radius: 50%;
    padding: 2px;
    z-index: 200;
}

/* ===== VIEW MODE BUTTONS ===== */
.view-mode-btn {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 11px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
}

.view-mode-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.view-mode-btn.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ===== COLUMN OPTIONS ===== */
.column-option {
    padding: 5px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition);
}

.column-option:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.column-option.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ===== LIGHT MODE (when body does NOT have dark-mode class) ===== */
body:not(.dark-mode) {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --bg-hover: #ddd;
    --text-primary: #333;
    --text-secondary: #666;
    --text-muted: #999;
    --border-color: #ccc;
    --border-light: #bbb;
    --ribbon-bg: #f0f0f0;
    --ribbon-tab-bg: #e8e8e8;
    --ribbon-tab-active: #f0f0f0;
    --page-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    --dialog-bg: #fff;
}

body:not(.dark-mode) .title-bar {
    background: linear-gradient(135deg, #e8eaf6, #c5cae9);
}

body:not(.dark-mode) .title-bar .title-btn {
    color: #555;
}

body:not(.dark-mode) .title-bar .title-btn:hover {
    background: rgba(0, 0, 0, 0.08);
    color: #333;
}

body:not(.dark-mode) .ribbon-tabs {
    background: #e8e8e8;
}

body:not(.dark-mode) .document-area {
    background: #d0d0d0;
}

body:not(.dark-mode) .page {
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

/* ===== PAGENUM DIALOG FORM ===== */
.form-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.form-row .form-group {
    flex: 1;
}

.dialog-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
}

/* ===== IMAGE FIX CONTROLS ===== */
.img-controls {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.img-controls .prop-row {
    gap: 4px;
}

/* ===== LOADING STATE ===== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    color: #fff;
    font-size: 14px;
}

/* ===== RUBBER-BAND SELECTION ===== */
.rubber-band-select {
    border: 1px dashed var(--accent, #0078d4);
    background: rgba(0, 120, 212, 0.08);
    pointer-events: none;
    z-index: 9999;
}

/* ===== FILE DRAG-DROP OVERLAY ===== */
.document-area.file-drag-over {
    background: rgba(0, 120, 212, 0.05);
    outline: 3px dashed var(--accent);
    outline-offset: -8px;
    position: relative;
}

/* ===== GROUPED ELEMENTS ===== */
.element-wrapper[data-group-id].selected {
    outline: 1px dashed #27ae60;
    outline-offset: 4px;
}

/* ===== ELEMENT INTERACTION ===== */
.element-wrapper {
    user-select: none;
    touch-action: none;
}

.element-wrapper:not(.selected):not(.locked):hover {
    border-color: rgba(0, 120, 212, 0.4);
    box-shadow: 0 0 0 1px rgba(0, 120, 212, 0.2);
}

/* ===== GLASSMORPHISM PRO UI ===== */
.dialog-overlay {
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
}

.dialog {
    background: rgba(40, 40, 40, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    color: #e0e0e0;
}

.dialog-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.dialog-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Watermark Tabs */
.wm-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.2);
    padding: 3px;
    border-radius: 6px;
}

.wm-tab {
    flex: 1;
    padding: 8px;
    background: transparent;
    border: none;
    color: #aaa;
    cursor: pointer;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.wm-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.wm-tab.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.wm-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.wm-tab-content.active {
    display: block;
}

.separator-line {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 16px 0;
}

.form-help {
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}