/* ========================================
   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: 10;
}

.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: 16px;
}

.upload-group:last-child {
    margin-bottom: 0;
}

.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-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;
    top: 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: 100;
    pointer-events: auto;
}

.remove-btn:hover {
    background-color: #dc2626;
    transform: scale(1.1);
}

/* ========================================
   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);
}

/* Fold Diagram */
.fold-diagram {
    margin-top: 16px;
    padding: 16px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fold-diagram svg {
    max-width: 100%;
    height: auto;
}

/* ========================================
   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);
}

.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 {
    position: absolute;
}

[data-theme="dark"] .icon-sun {
    display: none;
}

[data-theme="dark"] .icon-moon {
    display: block;
}

:root:not([data-theme="dark"]) .icon-moon,
body:not([data-theme="dark"]) .icon-moon {
    display: none;
}

#theme-toggle {
    position: relative;
}

/* ========================================
   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;
}

.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 span {
    padding: 20px 30px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* ========================================
   Controls Bar
   ======================================== */

.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-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;
}

/* ========================================
   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 */
::-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);
}
