/* 
 * CSS Flexbox Cheat Sheet Styles
 * High contrast, vibrant, playful design.
 */

:root {
    --bg-main: #09090b;
    /* Very Dark Zinc */
    --bg-panel: #18181b;
    /* Zinc 900 */
    --bg-elevated: #27272a;
    /* Zinc 800 */

    --text-primary: #f8fafc;
    --text-secondary: #a1a1aa;
    --border: #3f3f46;

    --accent: #3b82f6;
    /* Blue 500 */
    --accent-hover: #2563eb;
    /* Blue 600 */

    /* Vibrant Item Colors */
    --item-1: #60a5fa;
    /* Blue */
    --item-2: #f472b6;
    /* Pink */
    --item-3: #a78bfa;
    /* Purple */
    --item-4: #4ade80;
    /* Green */
    --item-5: #fbbf24;
    /* Yellow */
    --item-6: #fb923c;
    /* Orange */
    --item-7: #2dd4bf;
    /* Teal */
    --item-8: #f87171;
    /* Red */

    --container-bg: #111827;
    /* Dark grayish blue */
    --container-border: #334155;

    --font-ui: 'Outfit', system-ui, sans-serif;
    --font-code: 'Fira Code', monospace;

    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 6px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Utilities */
.flex-col {
    display: flex;
    flex-direction: column;
}

.gap-4 {
    gap: 1rem;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1rem;
}

.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-secondary);
}

.overflow-y {
    overflow-y: auto;
}

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

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

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

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

/* --- Header --- */
.app-header {
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.02em;
}

.logo i {
    color: var(--accent);
    font-size: 1.5rem;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* --- Layout --- */
.app-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Panels */
.panel {
    width: 340px;
    background-color: var(--bg-panel);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.panel:first-child {
    border-right: 1px solid var(--border);
}

.panel:last-child {
    border-left: 1px solid var(--border);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: rgba(39, 39, 42, 0.4);
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
}

.panel-content {
    padding: 1.5rem;
}

/* Controls */
.control-group {
    margin-bottom: 1.5rem;
}

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

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: lowercase;
    font-family: var(--font-code);
}

.control-group label span {
    color: var(--accent);
}

/* Toggle Buttons */
.toggle-group {
    display: flex;
    background: var(--bg-main);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.toggle-group.wrap-group {
    flex-wrap: wrap;
}

.toggle-btn {
    flex: 1;
    min-width: 60px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    font-family: var(--font-code);
}

.toggle-group.wrap-group .toggle-btn {
    flex-basis: 30%;
    margin-bottom: 0.25rem;
}

.toggle-btn:hover {
    color: white;
}

.toggle-btn.active {
    background: var(--bg-elevated);
    color: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Sliders */
.range-slider {
    width: 100%;
    -webkit-appearance: none;
    background: transparent;
    cursor: pointer;
    height: 1.5rem;
}

.range-slider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    border: 1px solid var(--border);
}

.range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: var(--accent);
    margin-top: -6px;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: transform 0.1s;
}

.range-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.range-slider:disabled::-webkit-slider-thumb {
    background: var(--text-secondary);
    box-shadow: none;
}

/* Select Inputs */
.select-input {
    width: 100%;
    background: var(--bg-main);
    color: white;
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-family: var(--font-code);
    font-size: 0.8rem;
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
}

.select-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: white;
    border-color: var(--border);
}

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

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-outline:hover {
    background: rgba(239, 68, 68, 0.1);
    /* Slight red for reset */
    color: #ef4444;
    border-color: #ef4444;
}

/* --- Center Workspace --- */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    position: relative;
    overflow: hidden;
}

.workspace-toolbar {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: center;
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.resize-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 300px;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    backdrop-filter: blur(10px);
}

.resize-controls label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 0.5rem;
}

.stage-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow: auto;
}

/* Flex Stage & Items */
.stage {
    background: var(--container-bg);
    border: 2px dashed var(--container-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    /* Default Flex properties injected by JS, but set base layout */
    display: flex;
    /* We animate size changes for visual smoothness */
    transition: width 0.3s ease, height 0.3s ease;

    /* Dimensions controlled by JS sliders */
    width: 100%;
    height: 100%;

    /* Internal scroll to prevent pure bleeding if content overflows intentionally */
    overflow: hidden;
}

.flex-item {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);

    /* IMPORTANT: The core transition that makes the visualizer beautiful */
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Defaults */
    min-width: 80px;
    min-height: 80px;
    margin: 0;
    /* Margin controlled by container gap */

    position: relative;
    user-select: none;
    border: 2px solid transparent;
}

.flex-item:hover {
    transform: scale(1.05);
    z-index: 10;
}

.flex-item.selected {
    border-color: white;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 10px 25px rgba(0, 0, 0, 0.5);
    transform: scale(1.05);
    z-index: 11;
}

/* Base item colors, cycles through via JS assigned data-index */
.flex-item[data-color="1"] {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

/* Blue */
.flex-item[data-color="2"] {
    background: linear-gradient(135deg, #ec4899, #f472b6);
}

/* Pink */
.flex-item[data-color="3"] {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

/* Purple */
.flex-item[data-color="4"] {
    background: linear-gradient(135deg, #22c55e, #4ade80);
}

/* Green */
.flex-item[data-color="5"] {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

/* Yellow */
.flex-item[data-color="6"] {
    background: linear-gradient(135deg, #f97316, #fb923c);
}

/* Orange */
.flex-item[data-color="7"] {
    background: linear-gradient(135deg, #14b8a6, #2dd4bf);
}

/* Teal */
.flex-item[data-color="8"] {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

/* Red */
.flex-item[data-color="default"] {
    background: linear-gradient(135deg, #64748b, #94a3b8);
}

.hint-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    width: max-content;
    margin-left: auto;
    margin-right: auto;
}

/* --- Code Pane & Items --- */
.code-box {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.btn-icon-sm {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    transition: color 0.2s;
    padding: 0.25rem;
    border-radius: 4px;
}

.btn-icon-sm:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

pre {
    padding: 1rem;
    overflow-x: auto;
}

code {
    font-family: var(--font-code);
    font-size: 0.8rem;
    color: #818CF8;
    line-height: 1.6;
}

/* Item Settings Overlay for Disabled State */
.item-settings {
    position: relative;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    background: rgba(24, 24, 27, 0.5);
    transition: all 0.2s;
}

.item-settings.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.item-settings.disabled .disabled-overlay span {
    display: inline;
}

.item-settings-header h3 {
    font-size: 0.875rem;
    color: white;
    margin-bottom: 1rem;
}

.item-settings-header span {
    display: none;
    color: var(--accent);
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.selected-item-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.color-swatch {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    background: transparent;
}

.color-swatch[data-color="1"] {
    background: linear-gradient(135deg, #3b82f6, #60a5fa);
}

.color-swatch[data-color="2"] {
    background: linear-gradient(135deg, #ec4899, #f472b6);
}

.color-swatch[data-color="3"] {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
}

.color-swatch[data-color="4"] {
    background: linear-gradient(135deg, #22c55e, #4ade80);
}

.color-swatch[data-color="5"] {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.color-swatch[data-color="6"] {
    background: linear-gradient(135deg, #f97316, #fb923c);
}

.color-swatch[data-color="7"] {
    background: linear-gradient(135deg, #14b8a6, #2dd4bf);
}

.color-swatch[data-color="8"] {
    background: linear-gradient(135deg, #ef4444, #f87171);
}

#item-name-lbl {
    font-size: 0.875rem;
    font-weight: 600;
}


/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--accent);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 500;
    font-size: 0.875rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 1000;
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}