/**
 * ============================================================================
 * MARKPRESS DESIGN SYSTEM & DASHBOARD STYLESHEET
 * Strict adherence to the requested custom properties:
 * --main-color: #e53f28;
 * --text-color: #071344;
 * --bg-color: #fff;
 * --hover-color: hsl(7,78%,48%);
 * --container-color: #6c7283;
 * --border-color: #d4d9dd;
 * ============================================================================
 */

:root {
    /* Required Core Design System Tokens */
    --main-color: #e53f28;
    --text-color: #071344;
    --bg-color: #fff;
    --hover-color: hsl(7, 78%, 48%);
    --container-color: #6c7283;
    --border-color: #d4d9dd;

    /* Semantic Extensions & Accents */
    --main-subtle: rgba(229, 63, 40, 0.08);
    --main-focus: rgba(229, 63, 40, 0.25);
    --surface-bg: #f8fafc;
    --surface-card: #ffffff;
    --surface-active: #f1f4f8;
    --text-muted: #576175;
    --text-subtle: #8993a4;
    --code-bg: #0d1527;
    --code-text: #e2e8f0;
    --success-color: #0f8b57;
    --success-bg: #eafaf1;
    --warning-color: #b7791f;
    --warning-bg: #fefcbf;
    
    /* Layout & Geometry */
    --sidebar-width: 310px;
    --header-height: 64px;
    --toolbar-height: 44px;
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-pill: 9999px;

    /* Elevation & Shadows */
    --shadow-sm: 0 1px 2px rgba(7, 19, 68, 0.04);
    --shadow-md: 0 4px 12px rgba(7, 19, 68, 0.06);
    --shadow-lg: 0 12px 32px rgba(7, 19, 68, 0.12);

    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: all 0.12s ease;

    /* Typography */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
}

/* ============================================================================
   1. CSS RESET & GLOBAL BASE
   ============================================================================ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}

a {
    color: var(--main-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: var(--hover-color);
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--main-color);
    outline-offset: 2px;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--container-color);
}

/* ============================================================================
   2. APP SHELL LAYOUT
   ============================================================================ */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    background: var(--bg-color);
}

/* ============================================================================
   3. SIDEBAR NAVIGATION
   ============================================================================ */
.app-sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface-bg);
    border-right: 1px solid var(--border-color);
    z-index: 40;
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.brand-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.brand-icon {
    width: 32px;
    height: 32px;
    background: var(--main-color);
    color: #fff;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 2px 6px rgba(229, 63, 40, 0.3);
}

.brand-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-color);
    letter-spacing: -0.3px;
}

.brand-sub {
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.8px;
    color: var(--main-color);
    background: var(--main-subtle);
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    margin-left: 4px;
}

/* Sidebar Search & Actions */
.sidebar-controls {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border-bottom: 1px solid var(--border-color);
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    padding: 8px 12px 8px 34px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 13px;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--main-color);
    box-shadow: 0 0 0 3px var(--main-focus);
    outline: none;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--container-color);
    pointer-events: none;
    display: flex;
}

.btn-new-doc {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    background: var(--main-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(229, 63, 40, 0.2);
    transition: var(--transition);
}

.btn-new-doc:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(229, 63, 40, 0.25);
}

.btn-new-doc:active {
    transform: translateY(0);
}

/* Documents List in Sidebar */
.documents-section {
    flex: 1;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--container-color);
    margin: 4px 6px 8px;
}

.doc-item {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    user-select: none;
}

.doc-item:hover {
    background: var(--bg-color);
    border-color: var(--border-color);
    box-shadow: var(--shadow-sm);
}

.doc-item.active {
    background: var(--bg-color);
    border-color: var(--main-color);
    box-shadow: var(--shadow-sm);
}

.doc-item.active::before {
    content: '';
    position: absolute;
    left: -1px;
    top: 6px;
    bottom: 6px;
    width: 4px;
    background: var(--main-color);
    border-radius: var(--radius-pill);
}

.doc-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.doc-item-title {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-item-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: var(--radius-pill);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.doc-item-badge.published {
    background: var(--success-bg);
    color: var(--success-color);
}

.doc-item-badge.draft {
    background: #f1f3f7;
    color: var(--container-color);
}

.doc-item-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--container-color);
}

.doc-item-actions {
    position: absolute;
    right: 8px;
    bottom: 8px;
    opacity: 0;
    transition: var(--transition-fast);
}

.doc-item:hover .doc-item-actions {
    opacity: 1;
}

.btn-icon-subtle {
    background: transparent;
    border: none;
    color: var(--container-color);
    padding: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

.btn-icon-subtle:hover {
    color: var(--main-color);
    background: var(--main-subtle);
}

/* Sidebar Info Cards (API Key & Paddle) */
.sidebar-footer-panels {
    padding: 12px 14px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.api-key-panel, .paddle-billing-panel {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 12px;
}

.panel-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.panel-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--container-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.paddle-pill {
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    background: var(--success-bg);
    color: var(--success-color);
}

.api-key-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.api-key-input {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 5px 8px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-color);
    letter-spacing: 0.5px;
}

.api-key-input:read-only {
    cursor: default;
}

.btn-copy-key {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-fast);
}

.btn-copy-key:hover {
    border-color: var(--main-color);
    color: var(--main-color);
}

.paddle-billing-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.paddle-desc {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
}

.btn-paddle-manage {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-paddle-manage:hover {
    border-color: var(--container-color);
    background: var(--surface-active);
}

/* Legal Links Area in Sidebar Footer */
.sidebar-legal-footer {
    padding: 10px 14px 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    font-size: 11px;
    color: var(--container-color);
    border-top: 1px solid var(--border-color);
    background: var(--bg-color);
}

.legal-tab-trigger {
    background: none;
    border: none;
    color: var(--container-color);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    transition: var(--transition-fast);
}

.legal-tab-trigger:hover {
    color: var(--main-color);
    text-decoration: underline;
}

.paddle-compliance-notice {
    width: 100%;
    font-size: 10px;
    color: var(--text-subtle);
    margin-top: 4px;
    line-height: 1.3;
}

/* ============================================================================
   4. MAIN VIEWPORT & SPLIT-SCREEN WORKSPACE
   ============================================================================ */
.main-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-color);
}

/* Header Bar */
.app-header {
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    z-index: 20;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
    min-width: 0;
}

.sidebar-toggle-btn {
    display: none;
    background: none;
    border: 1px solid var(--border-color);
    padding: 6px;
    border-radius: var(--radius-sm);
    color: var(--text-color);
    cursor: pointer;
}

.doc-title-input {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-color);
    border: 1px solid transparent;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: transparent;
    width: 100%;
    max-width: 420px;
    transition: var(--transition-fast);
}

.doc-title-input:hover {
    border-color: var(--border-color);
    background: var(--surface-bg);
}

.doc-title-input:focus {
    border-color: var(--main-color);
    background: var(--bg-color);
    box-shadow: 0 0 0 3px var(--main-focus);
    outline: none;
}

.slug-badge-container {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--container-color);
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slug-badge-container span {
    overflow: hidden;
    text-overflow: ellipsis;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.status-select {
    padding: 6px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-color);
    font-size: 12px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.status-select:focus {
    border-color: var(--main-color);
    outline: none;
}

.btn-save-doc {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 16px;
    background: var(--main-color);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.btn-save-doc:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(229, 63, 40, 0.25);
}

.btn-save-doc:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.save-indicator {
    font-size: 12px;
    color: var(--container-color);
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Document Metadata Bar (SEO Meta Description) */
.doc-meta-bar {
    height: 38px;
    min-height: 38px;
    background: var(--surface-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
}

.meta-desc-wrapper {
    display: flex;
    align-items: center;
    width: 100%;
    gap: 10px;
}

.meta-desc-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--container-color);
    white-space: nowrap;
    user-select: none;
}

.doc-meta-desc-input {
    flex: 1;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    color: var(--text-color);
    transition: var(--transition-fast);
}

.doc-meta-desc-input::placeholder {
    color: var(--container-color);
    opacity: 0.75;
}

.doc-meta-desc-input:hover {
    background: var(--bg-color);
    border-color: var(--border-color);
}

.doc-meta-desc-input:focus {
    background: var(--bg-color);
    border-color: var(--main-color);
    box-shadow: 0 0 0 2px var(--main-focus);
    outline: none;
}

.meta-char-count {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--container-color);
    white-space: nowrap;
    user-select: none;
}

.meta-char-count.optimal {
    color: var(--success-color);
}

.meta-char-count.warning {
    color: var(--main-color);
    font-weight: 600;
}

/* ============================================================================
   5. SPLIT-SCREEN WORKSPACE LAYOUT
   ============================================================================ */
.workspace-container {
    flex: 1;
    display: flex;
    height: calc(100vh - var(--header-height) - 38px);
    overflow: hidden;
    position: relative;
}

/* LEFT PANE: MARKDOWN EDITOR */
.editor-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 320px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-color);
}

/* Editor Toolbar */
.editor-toolbar {
    height: var(--toolbar-height);
    min-height: var(--toolbar-height);
    display: flex;
    align-items: center;
    padding: 0 14px;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-bg);
    overflow-x: auto;
}

.toolbar-btn {
    background: none;
    border: 1px solid transparent;
    padding: 5px 7px;
    border-radius: var(--radius-sm);
    color: var(--text-color);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
}

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

.toolbar-divider {
    width: 1px;
    height: 18px;
    background: var(--border-color);
    margin: 0 4px;
}

/* Line-Numbered Editor Container */
.editor-input-wrapper {
    flex: 1;
    display: flex;
    position: relative;
    overflow: hidden;
    background: var(--bg-color);
}

.line-numbers {
    width: 48px;
    padding: 16px 8px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--container-color);
    background: var(--surface-bg);
    border-right: 1px solid var(--border-color);
    user-select: none;
    overflow: hidden;
}

.markdown-textarea {
    flex: 1;
    height: 100%;
    border: none;
    outline: none;
    padding: 16px 18px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-color);
    background: var(--bg-color);
    resize: none;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    tab-size: 2;
}

/* Editor Status Bar */
.editor-status-bar {
    height: 28px;
    min-height: 28px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: 11px;
    color: var(--container-color);
}

.status-stats {
    display: flex;
    gap: 14px;
}

/* RIGHT PANE: LIVE HTML / API PREVIEW */
.preview-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    min-width: 320px;
    background: var(--bg-color);
    overflow: hidden;
}

.preview-tabs-header {
    height: var(--toolbar-height);
    min-height: var(--toolbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface-bg);
}

.preview-tab-pills {
    display: flex;
    gap: 4px;
}

.preview-pill {
    background: none;
    border: 1px solid transparent;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    color: var(--container-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.preview-pill:hover {
    color: var(--text-color);
}

.preview-pill.active {
    background: var(--bg-color);
    border-color: var(--border-color);
    color: var(--main-color);
    box-shadow: var(--shadow-sm);
}

.btn-copy-preview {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition-fast);
}

.btn-copy-preview:hover {
    border-color: var(--main-color);
    color: var(--main-color);
}

/* Content Rendering Area */
.preview-viewport {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    background: var(--bg-color);
}

/* Tab 2: Raw HTML View */
.raw-html-view, .json-api-view {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    background: var(--code-bg);
    color: var(--code-text);
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================================================
   6. RENDERED PROSE & HTML TYPOGRAPHY
   ============================================================================ */
.prose-rendered {
    color: var(--text-color);
    line-height: 1.7;
    max-width: 820px;
    margin: 0 auto;
}

.prose-rendered h1, 
.prose-rendered h2, 
.prose-rendered h3, 
.prose-rendered h4 {
    color: var(--text-color);
    font-weight: 700;
    margin-top: 1.6em;
    margin-bottom: 0.6em;
    line-height: 1.3;
}

.prose-rendered h1 {
    font-size: 26px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.prose-rendered h2 {
    font-size: 20px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.prose-rendered h3 {
    font-size: 16px;
}

.prose-rendered p {
    margin-bottom: 1.1em;
}

.prose-rendered blockquote {
    border-left: 4px solid var(--main-color);
    padding: 8px 16px;
    background: var(--main-subtle);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-color);
    margin: 1.2em 0;
    font-style: italic;
}

.prose-rendered ul, 
.prose-rendered ol {
    margin: 0 0 1.2em 24px;
}

.prose-rendered li {
    margin-bottom: 0.4em;
}

.prose-rendered code {
    font-family: var(--font-mono);
    font-size: 85%;
    padding: 2px 6px;
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--main-color);
}

.prose-rendered pre {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 14px 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 1.2em 0;
}

.prose-rendered pre code {
    background: transparent;
    border: none;
    color: inherit;
    padding: 0;
    font-size: 13px;
}

.prose-rendered table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.4em 0;
    font-size: 13px;
}

.prose-rendered th, 
.prose-rendered td {
    padding: 9px 12px;
    border: 1px solid var(--border-color);
    text-align: left;
}

.prose-rendered th {
    background: var(--surface-bg);
    font-weight: 700;
}

.prose-rendered tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.7);
}

.prose-rendered hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 2em 0;
}

.prose-rendered img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* ============================================================================
   7. PADDLE COMPLIANCE LEGAL MODAL (Terms, Privacy, Refund)
   ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(7, 19, 68, 0.55);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 20px;
    animation: fadeIn 0.18s ease;
}

.modal-overlay.active {
    display: flex;
}

.legal-modal-card {
    background: var(--bg-color);
    width: 100%;
    max-width: 860px;
    max-height: 85vh;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
    animation: slideUp 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.modal-title-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-color);
}

.compliance-badge {
    font-size: 11px;
    font-weight: 700;
    background: var(--main-subtle);
    color: var(--main-color);
    padding: 2px 8px;
    border-radius: var(--radius-pill);
}

.btn-close-modal {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--container-color);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: var(--transition-fast);
}

.btn-close-modal:hover {
    color: var(--main-color);
}

/* Modal Nav Tabs */
.modal-tabs {
    display: flex;
    padding: 0 22px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    gap: 8px;
}

.tab-btn {
    padding: 12px 14px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 600;
    color: var(--container-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-color);
}

.tab-btn.active {
    color: var(--main-color);
    border-bottom-color: var(--main-color);
}

/* Modal Body Content */
.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--text-color);
}

.legal-tab-pane {
    display: none;
}

.legal-tab-pane.active {
    display: block;
}

.legal-tab-pane h3 {
    font-size: 18px;
    color: var(--text-color);
    margin-bottom: 12px;
    font-weight: 700;
}

.legal-tab-pane h4 {
    font-size: 14px;
    color: var(--text-color);
    margin-top: 18px;
    margin-bottom: 6px;
    font-weight: 700;
}

.legal-tab-pane p {
    margin-bottom: 12px;
    color: var(--text-muted);
}

.legal-tab-pane ul {
    margin: 8px 0 16px 20px;
    color: var(--text-muted);
}

.legal-callout-box {
    background: var(--surface-bg);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--main-color);
    padding: 14px 16px;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin: 16px 0;
}

.legal-callout-title {
    font-weight: 700;
    color: var(--text-color);
    margin-bottom: 4px;
}

.modal-footer {
    padding: 12px 22px;
    border-top: 1px solid var(--border-color);
    background: var(--surface-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-footer-info {
    font-size: 11px;
    color: var(--container-color);
}

/* ============================================================================
   8. TOAST NOTIFICATIONS
   ============================================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--text-color);
    color: #fff;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

.toast.success {
    border-left: 4px solid #10b981;
}

.toast.error {
    border-left: 4px solid var(--main-color);
}

/* ============================================================================
   9. RESPONSIVE BREAKPOINTS (Mobile & Tablet)
   ============================================================================ */
@media (max-width: 960px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .app-sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle-btn {
        display: flex;
    }

    .workspace-container {
        flex-direction: column;
    }

    .editor-pane {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: 50%;
    }

    .preview-pane {
        height: 50%;
    }

    .slug-badge-container {
        display: none;
    }
}

@media (max-width: 600px) {
    .header-left {
        gap: 8px;
    }

    .doc-title-input {
        font-size: 15px;
    }

    .modal-tabs {
        padding: 0 10px;
        overflow-x: auto;
    }

    .tab-btn {
        padding: 10px 8px;
        font-size: 11px;
    }
}

/* Keyframe Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(12px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

@keyframes toastIn {
    from { transform: translateY(16px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

