/* ============================
   OBS Mask Generator - Styles
   ============================ */

/* CSS Variables for Theming */
:root {
    /* Colors - Dark Mode (OBS-like) */
    --bg-primary: #0e0e10;
    --bg-secondary: #18181b;
    --bg-tertiary: #1f1f23;
    --bg-elevated: #26262c;

    --text-primary: #efeff1;
    --text-secondary: #adadb8;
    --text-muted: #848494;

    --accent-primary: #9146ff;
    --accent-secondary: #772ce8;
    --accent-hover: #a970ff;
    --accent-subtle: rgba(145, 70, 255, 0.15);

    --border-color: #2f2f35;
    --border-hover: #3d3d45;

    --success: #00f593;
    --warning: #ffb800;
    --error: #eb0400;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* App Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================
   Header
   ============================ */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-lg) 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: var(--space-lg);
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* ============================
   Presets Bar
   ============================ */
.presets-bar {
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.presets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: var(--space-sm);
}

.preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
}

.preset-card:hover {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-primary);
    transform: translateY(-2px);
}

.preset-card:active {
    transform: translateY(0);
}

.preset-icon {
    width: 48px;
    height: 48px;
    background: var(--text-primary);
    position: relative;
}

.preset-rounded-rect {
    border-radius: var(--radius-md);
}

.preset-circle {
    border-radius: 50%;
}

.preset-bubble {
    border-radius: 30%;
    width: 40px;
    height: 40px;
}

.preset-hex {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.preset-vertical {
    width: 28px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.preset-triangle {
    clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}

/* ============================
   Editor Layout
   ============================ */
.editor {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: var(--space-lg);
    flex: 1;
}

@media (max-width: 900px) {
    .editor {
        grid-template-columns: 1fr;
    }
}

/* ============================
   Controls Panel
   ============================ */
.controls-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.control-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
}

.control-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.control-title svg {
    color: var(--accent-primary);
}

/* Size Inputs */
.size-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input[type="number"] {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    width: 100%;
    transition: border-color var(--transition-fast);
}

.input-group input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.input-group .unit {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: var(--space-xs);
}

/* Aspect Ratio Buttons */
.aspect-buttons {
    display: flex;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.aspect-btn {
    flex: 1;
    min-width: 50px;
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.aspect-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.aspect-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Shape Buttons */
.shape-buttons {
    display: flex;
    gap: var(--space-sm);
}

.shape-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.shape-btn svg {
    width: 28px;
    height: 28px;
}

.shape-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.shape-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Sliders */
.slider-group {
    margin-bottom: var(--space-sm);
}

.slider-group label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.slider-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: var(--space-xs);
}

.slider-group 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);
}

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

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

.slider-value {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.slider-value input[type="number"] {
    width: 60px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: var(--space-xs) var(--space-sm);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-family: inherit;
}

.slider-value input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.slider-value span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-group {
    margin-top: var(--space-sm);
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.toggle-label input[type="checkbox"] {
    display: none;
}

.toggle-switch {
    position: relative;
    width: 36px;
    height: 20px;
    background: var(--bg-tertiary);
    border-radius: 10px;
    transition: background var(--transition-fast);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: var(--text-muted);
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.toggle-label input[type="checkbox"]:checked+.toggle-switch {
    background: var(--accent-primary);
}

.toggle-label input[type="checkbox"]:checked+.toggle-switch::after {
    left: 18px;
    background: white;
}

/* Color Input */
.color-input {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.color-input label {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.color-input input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 40px;
    height: 30px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: transparent;
    padding: 2px;
}

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

.color-input input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

/* Hidden State */
.hidden {
    display: none !important;
}

/* ============================
   Preview Panel
   ============================ */
.preview-panel {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Preview Header with Dimension Badge */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.preview-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.dimension-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace, 'Courier New';
}

/* Fixed Canvas Container */
.canvas-container {
    height: 400px;
    max-height: 400px;
    background:
        linear-gradient(45deg, #2a2a2e 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a2e 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a2e 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a2e 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    padding: var(--space-md);
}

/* For 100% zoom mode - allow scrolling */
.canvas-container.scrollable {
    overflow: auto;
}

/* Canvas Wrapper for Scaling */
.canvas-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

#preview-canvas {
    box-shadow: var(--shadow-lg);
    display: block;
    max-width: 100%;
    max-height: 360px;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* For 100% zoom - show actual size */
.canvas-container.scrollable #preview-canvas {
    max-width: none;
    max-height: none;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
}

.zoom-btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.zoom-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.zoom-btn.active {
    background: var(--accent-subtle);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Download Actions */
.download-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.download-btn {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.download-btn.primary {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
}

.download-btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent-primary));
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.download-btn.secondary:hover {
    background: var(--accent-subtle);
}

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

/* Help Text */
.help-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
}

.help-text strong {
    color: var(--accent-primary);
}

/* ============================
   How to Use Section
   ============================ */
.how-to-use {
    margin-top: var(--space-xl);
    padding: var(--space-xl);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.how-to-use h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: var(--space-lg);
    text-align: center;
}

.tutorial-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
    align-items: center;
}

.tutorial-gif {
    width: 100%;
    max-width: 500px;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    box-shadow: var(--shadow-lg);
}

.tutorial-steps ol {
    list-style: none;
    counter-reset: step-counter;
    padding: 0;
    margin: 0;
}

.tutorial-steps li {
    counter-increment: step-counter;
    display: flex;
    align-items: flex-start;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.tutorial-steps li::before {
    content: counter(step-counter);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    font-weight: 700;
    font-size: 0.85rem;
    border-radius: 50%;
}

.tutorial-steps li strong {
    color: var(--text-primary);
}

@media (max-width: 900px) {
    .tutorial-content {
        grid-template-columns: 1fr;
    }

    .tutorial-gif {
        max-width: 100%;
        margin: 0 auto;
    }
}

/* ============================
   Footer
   ============================ */
.footer {
    text-align: center;
    padding: var(--space-lg) 0;
    margin-top: var(--space-xl);
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================
   Responsive Adjustments
   ============================ */
@media (max-width: 600px) {
    .presets-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .preset-card {
        padding: var(--space-sm);
    }

    .preset-icon {
        width: 36px;
        height: 36px;
    }

    .shape-buttons {
        flex-direction: column;
    }

    .download-btn {
        min-width: 100%;
    }
}