/* ========================================
   Print Fold Visualizer - Styles
   ======================================== */

/* CSS Variables for theming */
:root {
    /* Light theme (default) */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a6a;
    --text-muted: #8a8aa0;
    --border-color: #d1d5db;
    --accent-primary: #3b82f6;
    --accent-primary-hover: #2563eb;
    --accent-secondary: #6366f1;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --sidebar-width: 320px;
}

/* Dark theme */
[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --text-primary: #f0f0f5;
    --text-secondary: #b0b0c5;
    --text-muted: #6a6a85;
    --border-color: #3a3a55;
    --accent-primary: #60a5fa;
    --accent-primary-hover: #3b82f6;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    overflow: hidden;
}

/* ========================================
   Layout
   ======================================== */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
    position: sticky;
    top: 0;
    z-index: 200;
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Panels */
.panel {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.panel h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ========================================
   Upload Zones
   ======================================== */

.upload-group {
    margin-bottom: 12px;
}

.upload-zones-gap {
    position: relative;
    min-height: 60px;
    margin: 0 0 8px 0;
}

.upload-zones-gap .upload-label {
    position: absolute;
    bottom: 0;
    left: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
}

.swap-images-wrap {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.swap-images-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.swap-images-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: var(--bg-primary);
}

.upload-group > label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.upload-zone {
    position: relative;
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
    aspect-ratio: 16 / 10;
}

.upload-zone:hover {
    border-color: var(--accent-primary);
    background-color: var(--bg-primary);
}

.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background-color: rgba(59, 130, 246, 0.1);
}

.upload-zone.pulse {
    animation: upload-pulse 1.5s ease-in-out infinite;
}

@keyframes upload-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
        border-color: var(--accent-primary);
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(59, 130, 246, 0.25);
        border-color: var(--accent-primary);
    }
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 20px;
    text-align: center;
}

.upload-icon {
    font-size: 32px;
    margin-bottom: 8px;
    opacity: 0.6;
}

.upload-text {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.upload-preview {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.upload-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background-color: var(--bg-tertiary);
}

.remove-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background-color: #ef4444;
    color: white;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 5;
    pointer-events: auto;
}

.remove-btn:hover {
    background-color: #dc2626;
    transform: scale(1.1);
}

.page-selector-wrap {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 5;
    pointer-events: auto;
}

.page-selector-wrap select {
    padding: 4px 8px;
    font-size: 11px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.page-selector-wrap select:hover {
    border-color: var(--accent-primary);
}

/* ========================================
   Form Elements
   ======================================== */

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

.form-group:last-child {
    margin-bottom: 0;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.form-row .btn {
    grid-column: 1 / -1;
}

select, input[type="text"] {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    outline: none;
}

select:hover, input[type="text"]:hover {
    border-color: var(--accent-primary);
}

select:focus, input[type="text"]:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.size-display {
    margin-top: 12px;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    text-align: center;
}

.size-display span {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Guide Toggles */
.guide-toggles {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toggle-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background-color var(--transition-fast);
}

.toggle-item:hover {
    background-color: var(--bg-tertiary);
}

.toggle-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
}

.guide-color {
    width: 16px;
    height: 3px;
    border-radius: 2px;
}

.guide-color.trim {
    background-color: #ef4444;
}

.guide-color.bleed {
    background-color: #f97316;
}

.guide-color.safe {
    background-color: #22c55e;
}

.guide-color.folds {
    background-color: #3b82f6;
    height: 3px;
    border-style: dashed;
    background: repeating-linear-gradient(
        90deg,
        #3b82f6 0px,
        #3b82f6 4px,
        transparent 4px,
        transparent 8px
    );
}

.guide-color.grid {
    background-color: #888888;
}

.guide-color.ruler {
    background-color: #8b5cf6;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #8b5cf6 0px,
        #8b5cf6 2px,
        transparent 2px,
        transparent 4px
    );
}

.guide-color.measurements {
    background-color: transparent;
    border: 1.5px solid #8b5cf6;
    position: relative;
}

.guide-color.measurements::before {
    content: '"';
    position: absolute;
    font-size: 10px;
    font-weight: bold;
    color: #8b5cf6;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

/* Guide Submenu */
.toggle-submenu {
    margin-left: 24px;
    padding-left: 12px;
    border-left: 2px solid var(--border-color);
    margin-top: 4px;
    margin-bottom: 4px;
}

.toggle-item.sub-item {
    padding: 6px 8px;
    font-size: 12px;
}

.toggle-item.sub-item .toggle-label {
    color: var(--text-secondary);
}

.autofit-tooltip-wrap {
    position: relative;
    display: inline-flex;
    margin-left: 4px;
}

.autofit-tooltip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-tertiary);
    border-radius: 50%;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.toggle-item:hover .autofit-tooltip,
.autofit-tooltip-wrap:hover .autofit-tooltip {
    background-color: var(--border-color);
    color: var(--text-secondary);
}

.autofit-tooltip-box {
    position: fixed;
    padding: 10px 12px;
    width: 320px;
    max-width: min(320px, calc(100vw - 2rem));
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-primary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    white-space: normal;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-fast), visibility var(--transition-fast);
    z-index: 9999;
    pointer-events: none;
}

.autofit-tooltip-box.visible {
    opacity: 1;
    visibility: visible;
}

.panel-subsection {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.subsection-heading {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0 0 8px 0;
}

.reflect-subsection .reflect-section {
    margin-top: 0;
}

.reflect-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.reflect-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
}

.reflect-row-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.reflect-buttons {
    display: flex;
    gap: 6px;
}

.reflect-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
}

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

.reflect-btn input[type="checkbox"] {
    display: none;
}

.reflect-btn:has(input:checked) {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.reflect-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: color 0.15s ease;
}

.reflect-btn:hover .reflect-icon {
    color: var(--text-primary);
}

.reflect-btn:has(input:checked) .reflect-icon {
    color: white;
}

.toggle-submenu .slider-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    font-size: 12px;
}

.toggle-submenu .slider-row label {
    min-width: 32px;
    color: var(--text-secondary);
}

.toggle-submenu .slider-row input[type="range"] {
    flex: 1;
    min-width: 0;
}

/* ========================================
   Buttons
   ======================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-primary {
    background-color: var(--accent-primary);
    color: white;
}

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

.control-icon {
    flex-shrink: 0;
    color: currentColor;
}

.btn-play-pause {
    width: auto;
    min-width: 44px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-play-pause #play-icon,
.btn-play-pause #pause-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.btn-play-pause .control-icon {
    display: block;
}

.icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background-color: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background-color: var(--bg-tertiary);
}

/* Theme toggle icons */
.icon-sun, .icon-moon {
    color: var(--text-primary);
    display: none;
}

/* Light mode: Show sun, hide moon */
html:not([data-theme="dark"]) .icon-sun {
    display: block !important;
}
html:not([data-theme="dark"]) .icon-moon {
    display: none !important;
}

/* Dark mode: Show moon, hide sun */
html[data-theme="dark"] .icon-sun {
    display: none !important;
}
html[data-theme="dark"] .icon-moon {
    display: block !important;
}

#theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Viewport
   ======================================== */

.viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
    overflow: hidden;
}

.viewport-container {
    flex: 1;
    position: relative;
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-primary) 100%);
    overflow: hidden;
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background-color: var(--bg-primary);
}

.viewport-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    font-size: 16px;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.viewport-overlay[hidden] {
    opacity: 0;
}

.viewport-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 30px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

.viewport-overlay-content span:first-child {
    font-size: 16px;
}

.viewport-overlay-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.viewport-overlay span {
    text-align: center;
}

/* Fold viewport toolbar (fold type + orientation) */
.fold-viewport-toolbar {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.fold-type-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.fold-type-toolbar .fold-type-btn {
    flex: 1;
    min-width: 0;
}

.fold-orientation-toolbar {
    display: flex;
    gap: 4px;
    padding: 6px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.orientation-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

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

.orientation-btn.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

.fold-type-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background-color: transparent;
    color: var(--text-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

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

.fold-type-btn.active {
    background-color: rgba(59, 130, 246, 0.15);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Export toolbar */
.export-toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 20;
    display: flex;
    align-items: center;
    padding: 6px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    height: 48px;
    box-sizing: border-box;
}

.export-btn-wrap {
    display: flex;
    align-items: center;
    flex: 1;
    position: relative;
}

.export-btn-wrap .export-btn {
    flex: 1;
}

.export-btn-wrap .export-dropdown {
    left: 0;
    right: auto;
}

.export-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-width: 80px;
    height: 36px;
    padding: 0 16px;
    background-color: transparent;
    color: var(--text-primary);
    border: none;
    border-radius: calc(var(--radius-md) - 2px);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.export-btn:hover {
    background-color: var(--bg-tertiary);
}

.export-btn:active {
    background-color: var(--border-color);
    transform: scale(0.98);
}

.export-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    padding: 12px;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
}

.export-dropdown .export-option {
    margin-bottom: 10px;
}

.export-dropdown .export-option:first-child label {
    margin-bottom: 4px;
}

.export-dropdown .toggle-item {
    padding: 4px 10px;
}

.export-dropdown .export-option:last-of-type {
    margin-bottom: 12px;
}

.export-dropdown label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
}

.export-dropdown select {
    width: 100%;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.export-dropdown .btn {
    width: 100%;
    padding: 8px;
}

/* ========================================
   Controls Bar
   ======================================== */

.controls-bar-wrapper {
    position: relative;
}

.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    gap: 24px;
}

.controls-bar.controls-disabled {
    opacity: 0.45;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.controls-bar-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.controls-bar.controls-disabled ~ .controls-bar-overlay {
    pointer-events: auto;
    cursor: default;
}

.viewport-overlay-content.pulse {
    animation: overlay-pulse 1.5s ease-in-out infinite;
}

@keyframes overlay-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 16px 6px rgba(59, 130, 246, 0.3);
    }
}

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

.controls-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: 500px;
}

.controls-center label,
.controls-right label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.controls-center input[type="range"] {
    flex: 1;
}

.controls-right input[type="range"] {
    width: 100px;
}

#fold-progress-label,
#speed-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-primary);
    min-width: 40px;
    text-align: right;
}

/* Range input styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    transition: transform var(--transition-fast);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* ========================================
   Header Buttons
   ======================================== */

.header-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Help button icon color */
#help-toggle svg {
    color: var(--accent-primary);
    transition: color var(--transition-fast);
}

#help-toggle:hover svg {
    color: var(--accent-primary-hover);
}

/* ========================================
   Help Modal
   ======================================== */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1001;
}

.modal-content {
    position: relative;
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    max-height: 85vh;
    width: 100%;
    z-index: 1002;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    padding: 24px 24px 16px;
    border-bottom: 1px solid var(--border-color);
    margin: 0;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 24px;
    line-height: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    z-index: 1;
}

.modal-close:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

/* Source Export Modal */
.source-export-modal-content {
    max-width: 480px;
}

.source-export-intro {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 8px 24px 16px;
    line-height: 1.5;
}

.source-export-form {
    padding: 0 24px 24px;
    overflow-y: auto;
}

.source-export-row {
    margin-bottom: 14px;
}

.source-export-row > label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.source-export-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
}

.source-export-output-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.source-export-transform-section {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.source-export-transform-section h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.source-export-transform-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.source-export-transform-row .toggle-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.source-export-transform-row select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 13px;
}

.help-content {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.help-section {
    margin-bottom: 24px;
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.help-section p {
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
    margin-bottom: 8px;
}

.help-section li {
    color: var(--text-secondary);
    padding-left: 20px;
    position: relative;
    margin-bottom: 6px;
    line-height: 1.6;
}

.help-section li::before {
    content: "•";
    position: absolute;
    left: 8px;
    color: var(--accent-primary);
    font-weight: bold;
}

.help-section strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .viewport {
        flex: 1;
        min-height: 50vh;
    }

    .controls-bar {
        flex-wrap: wrap;
        padding: 12px 16px;
        gap: 12px;
    }

    .controls-center {
        order: 3;
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 600px) {
    .sidebar-header h1 {
        font-size: 16px;
    }

    .panel {
        padding: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .controls-bar {
        justify-content: center;
    }

    .controls-left,
    .controls-right {
        width: 100%;
        justify-content: center;
    }
}

/* ========================================
   Utility Classes
   ======================================== */

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Scrollbar styling */
/* About panel */
.about-panel {
    border-bottom: 1px solid var(--border-color);
}

.about-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    font: inherit;
    color: var(--text-primary);
    text-align: left;
}

.about-toggle h2 {
    margin: 0;
}

.about-chevron {
    font-size: 12px;
    color: var(--text-muted);
}

.about-content {
    padding-top: 12px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-secondary);
}

.about-intro {
    margin: 0 0 10px 0;
}

.about-features {
    margin: 0;
    padding-left: 18px;
}

.about-features li {
    margin-bottom: 6px;
}

.about-subheading {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 16px 0 8px 0;
}

.about-privacy {
    margin: 0 0 8px 0;
    line-height: 1.5;
}

.about-disclaimer {
    margin: 12px 0 0 0;
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.donation-panel {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    border-bottom: none;
    padding: 16px 20px;
    background-color: var(--bg-secondary);
}

.kofi-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    background-color: #29abe0;
    color: white;
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: transform var(--transition-fast), background-color var(--transition-fast);
}

.kofi-button:hover {
    background-color: #1a8dbb;
    transform: translateY(-2px);
}

.kofi-icon {
    font-size: 18px;
}

.made-by {
    margin: 12px 0 0 0;
    font-size: 12px;
    color: var(--text-muted);
}

.made-by a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

.made-by a:hover {
    color: var(--text-primary);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}
