/* ============================================
   Glassmorphism Gen — Styles
   Theme: Coral Reef Dark
   ============================================ */

/* --- Design Tokens --- */
:root {
    --primary: #E17055;
    --primary-light: #FAB1A0;
    --accent: #00CEC9;
    --bg: #2D1B16;
    --bg-deep: #1A0F0B;
    --surface: rgba(255, 255, 255, 0.04);
    --surface-hover: rgba(255, 255, 255, 0.07);
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.15);
    --text: #F5F0ED;
    --text-muted: rgba(245, 240, 237, 0.55);
    --radius: 12px;
    --radius-lg: 16px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: 250ms ease;
}

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

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

body {
    font-family: var(--font);
    background: var(--bg-deep);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Header --- */
.app-header {
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.12), rgba(0, 206, 201, 0.06));
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.5rem;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    flex-wrap: wrap;
}

.logo-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.logo-icon {
    font-size: 1.5rem;
    color: var(--primary);
    filter: drop-shadow(0 0 6px rgba(225, 112, 85, 0.5));
}

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

.tagline {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}

/* --- Main Layout --- */
.app-main {
    display: grid;
    grid-template-columns: 280px 1fr 320px;
    gap: 0;
    min-height: calc(100vh - 60px);
}

/* --- Controls Panel --- */
.controls-panel {
    background: var(--bg);
    border-right: 1px solid var(--border);
    padding: 1.25rem;
    overflow-y: auto;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.panel-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

/* --- Control Group --- */
.control-group {
    margin-bottom: 1.1rem;
}

.control-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.control-value {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
}

/* --- Range Sliders --- */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--surface);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    border: 1px solid var(--border);
    transition: background var(--transition);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: 2px solid var(--bg);
    box-shadow: 0 2px 8px rgba(225, 112, 85, 0.35);
    cursor: grab;
    transition: transform var(--transition), box-shadow var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(225, 112, 85, 0.5);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border: 2px solid var(--bg);
    box-shadow: 0 2px 8px rgba(225, 112, 85, 0.35);
    cursor: grab;
}

input[type="range"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* --- Color Input --- */
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

input[type="color"] {
    -webkit-appearance: none;
    appearance: none;
    width: 32px;
    height: 32px;
    border: 2px solid var(--border-light);
    border-radius: 8px;
    cursor: pointer;
    background: none;
    padding: 2px;
}

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

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

.color-hex {
    font-size: 0.75rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    color: var(--text-muted);
}

/* --- Toggle Button --- */
.toggle-group {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.toggle-btn {
    width: 44px;
    height: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-light);
    background: var(--surface);
    cursor: pointer;
    position: relative;
    transition: background var(--transition), border-color var(--transition);
}

.toggle-btn.active {
    background: rgba(225, 112, 85, 0.25);
    border-color: var(--primary);
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--text-muted);
    transition: transform var(--transition), background var(--transition);
}

.toggle-btn.active .toggle-knob {
    transform: translateX(20px);
    background: var(--primary);
}

/* --- Upload Area --- */
.upload-area {
    position: relative;
    margin-bottom: 0.4rem;
}

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.upload-label {
    display: block;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border-light);
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.upload-area:hover .upload-label {
    border-color: var(--primary);
    color: var(--primary-light);
}

.btn-small {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: var(--font);
    transition: all var(--transition);
}

.btn-small:hover {
    background: var(--surface-hover);
    color: var(--text);
    border-color: var(--border-light);
}

/* --- Preview Size Buttons --- */
.preview-size-btns {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border);
}

.size-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 28px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.size-btn.active {
    background: rgba(225, 112, 85, 0.2);
    color: var(--primary);
}

.size-btn:hover:not(.active) {
    background: var(--surface-hover);
    color: var(--text);
}

/* --- Preview Section --- */
.preview-section {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: var(--bg-deep);
    position: relative;
    overflow: hidden;
}

.preview-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 20% 30%, rgba(225, 112, 85, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 70%, rgba(0, 206, 201, 0.06) 0%, transparent 60%);
    pointer-events: none;
}

.preview-viewport {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: max-width 400ms ease, aspect-ratio 400ms ease;
    position: relative;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.preview-viewport.size-desktop {
    max-width: 100%;
    aspect-ratio: 16 / 10;
}

.preview-viewport.size-tablet {
    max-width: 500px;
    aspect-ratio: 3 / 4;
}

.preview-viewport.size-mobile {
    max-width: 320px;
    aspect-ratio: 9 / 16;
}

.preview-bg {
    width: 100%;
    height: 100%;
    background:
        linear-gradient(135deg, #E17055 0%, #00CEC9 50%, #FAB1A0 100%);
    background-size: cover;
    background-position: center;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* --- Glass Container --- */
.glass-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

/* --- Glass Card --- */
.glass-card {
    position: absolute;
    width: 320px;
    max-width: 85%;
    padding: 2rem;
    text-align: center;
    transition: all var(--transition);
    /* Glass properties set via JS */
}

.glass-card.layer-1 {
    z-index: 4;
}

.glass-card.layer-2 {
    z-index: 3;
    transform: translate(20px, 20px) scale(0.95);
    opacity: 0.7;
}

.glass-card.layer-3 {
    z-index: 2;
    transform: translate(40px, 40px) scale(0.9);
    opacity: 0.5;
}

.glass-card.layer-4 {
    z-index: 1;
    transform: translate(60px, 60px) scale(0.85);
    opacity: 0.35;
}

.glass-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.6rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.glass-body {
    font-size: 0.85rem;
    line-height: 1.5;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 1rem;
}

.glass-tags {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.glass-tag {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* --- Noise overlay for glass --- */
.glass-card.has-noise::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    background-size: 128px 128px;
    pointer-events: none;
    z-index: 1;
}

/* --- Code Panel --- */
.code-panel {
    background: var(--bg);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 60px);
    position: sticky;
    top: 60px;
}

.code-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    padding: 0;
}

.code-tab {
    flex: 1;
    padding: 0.7rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
    position: relative;
}

.code-tab.active {
    color: var(--primary);
    background: rgba(225, 112, 85, 0.06);
}

.code-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

.code-tab:hover:not(.active) {
    color: var(--text);
    background: var(--surface);
}

.code-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.code-block {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.72rem;
    line-height: 1.65;
    color: var(--primary-light);
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.code-block.hidden {
    display: none;
}

/* --- Copy Button --- */
.copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.15), rgba(225, 112, 85, 0.08));
    border: 1px solid rgba(225, 112, 85, 0.2);
    border-top: 1px solid var(--border);
    color: var(--primary-light);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: linear-gradient(135deg, rgba(225, 112, 85, 0.25), rgba(225, 112, 85, 0.15));
    color: var(--primary);
}

.copy-btn.copied {
    background: linear-gradient(135deg, rgba(0, 206, 201, 0.2), rgba(0, 206, 201, 0.1));
    border-color: rgba(0, 206, 201, 0.3);
    color: var(--accent);
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    .app-main {
        grid-template-columns: 260px 1fr;
        grid-template-rows: auto auto;
    }

    .code-panel {
        grid-column: 1 / -1;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 300px;
        position: static;
    }
}

@media (max-width: 768px) {
    .app-main {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .controls-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: none;
        position: static;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 1rem;
    }

    .panel-title {
        grid-column: 1 / -1;
    }

    .preview-section {
        padding: 1rem;
    }

    .preview-viewport {
        aspect-ratio: 4 / 3;
    }

    .code-panel {
        max-height: 250px;
        position: static;
    }
}

@media (max-width: 480px) {
    .controls-panel {
        grid-template-columns: 1fr;
        padding: 1rem;
    }

    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }

    .glass-card {
        width: 260px;
        padding: 1.25rem;
    }

    .glass-title {
        font-size: 1.1rem;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- Focus Outline --- */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}