/* 
   ASCIIOM Shared Styles
   --------------------------------------------------------------
   Common design system, variables, and components for Generator and Player.
*/

:root {
    /* Colors */
    --bg-color: #000;
    --text-main: #e6e6e6;
    --text-muted: #666666;
    --text-header: #DCDCDC;
    --panel-bg: rgba(24, 24, 24, 0.95);
    --border-color: rgba(255, 255, 255, 0.1);
    --accent-color: #38bdf8;
    --accent-hover: #7dd3fc;
    --input-bg: rgba(0, 0, 0, 0.3);
    --input-hover: rgba(0, 0, 0, 0.4);

    /* Layout */
    --panel-width: 390px;
    --panel-radius: 12px;
    --input-radius: 4px;
    --btn-radius: 6px;

    /* Typography */
    --font-family: 'Roboto Mono', ui-monospace, monospace;
}

/* GLOBAL RESETS & BASICS */
body,
html {
    height: 100%;
    margin: 0;
    background: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    user-select: none;
    overflow: hidden;
}

/* STAGE / CANVAS */
#stage {
    position: fixed;
    inset: 0;
    z-index: 0;
}

/* PANELS (Shared Logic) */
.panel {
    position: fixed;
    /* Generator used absolute, Player fixed. Unified to fixed. */
    top: 24px;
    left: 24px;
    z-index: 1000;
    width: var(--panel-width);
    max-height: calc(100vh - 48px);
    /* Safe area */

    background: var(--panel-bg);
    backdrop-filter: blur(2px);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

    display: flex;
    display: flex;
    flex-direction: column;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* Unified smooth easing */
}

/* Unified Collapsed Panel Behavior */
.panel.collapsed {
    height: 70px;
    overflow: hidden;
    width: auto;
    min-width: fit-content;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    /* Slightly stronger shadow when collapsed */
}

/* Ensure hover states work on collapsed buttons */
.panel.collapsed .btn.icon:hover {
    background: rgba(255, 255, 255, 0.15);
    /* Visible hover feedback */
}

/* Panel Head in Collapsed State */
.panel.collapsed .panel-head {
    padding: 17px;
    border-bottom: none;
}

/* Hide scrollable content when collapsed */
.panel.collapsed .scroll-container,
.panel.collapsed .controls-scroll {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* Smooth opacity transitions for content */
.panel:not(.collapsed) .scroll-container,
.panel:not(.collapsed) .controls-scroll {
    opacity: 1;
    transition: opacity 0.2s ease 0.1s;
    /* Delay fade-in slightly */
}

.panel.collapsed>*:not(.panel-head):not(.overlay-header-bar) {
    display: none;
}

/* SCROLLBAR CUSTOMIZATION */
.scroll-container {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) rgba(0, 0, 0, 0.3);
}

.scroll-container::-webkit-scrollbar {
    width: 8px;
    background: rgba(0, 0, 0, 0.3);
}

.scroll-container::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.scroll-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* PANEL HEADERS */
.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 17px;
    flex-shrink: 0;
}

.panel-head h2 {
    margin: 0;
    flex-grow: 1;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: 0.02em;
}

/* SECTIONS (Unified Accordion/OverlaySection) */
.section {
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.section:last-child {
    border-bottom: none;
}

.section-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 17px;
    /* Unified padding */
    background: transparent;
    border: none;
    cursor: pointer;

    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-header);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s ease, background 0.2s ease;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #FFF;
}

.section-header.active {
    background: rgba(255, 255, 255, 0.08);
    /* Active state */
}

/* Icon rotation for toggle */
.section-header .icon {
    transition: transform 0.2s ease;
    font-size: 10px;
    color: #888;
}

/* Collapsed state logic */
.section.collapsed .section-content {
    display: none;
}

.section.collapsed .section-toggle-icon {
    transform: rotate(-90deg);
}

.section:not(.collapsed) .section-header {
    background: rgba(255, 255, 255, 0.08);
    /* Active state inferred from not being collapsed */
}

/* Smooth expansion requires specific JS/Height logic, keeping simple for shared base */
.section-content {
    padding: 12px 17px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* INPUTS & FORM ELEMENTS */
input[type=number],
input[type=text],
select {
    width: 100%;
    height: 28px;
    padding: 0 8px;
    border-radius: var(--input-radius);
    background: var(--input-bg);
    color: #eee;
    border: 1px solid var(--border-color);
    font-family: inherit;
    font-size: 11px;
    box-sizing: border-box;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

input:hover,
select:hover,
button:hover {
    background: var(--input-hover);
}

label {
    font-size: 9px;
    color: var(--text-muted);
    display: block;
}

/* BUTTONS */
.btn {
    cursor: pointer;
    border: none;
    border-radius: var(--btn-radius);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    box-sizing: border-box;
}

/* Ghost / Secondary Button */
.btn.ghost {
    background: rgba(255, 255, 255, 0.08);
    color: #ccc;
    font-size: 11px;
    border: 1px solid transparent;
    height: 28px;
}

.btn.ghost:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
}

/* Primary Button */
.btn.primary {
    background: var(--accent-color);
    color: #07212a;
}

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

/* Icon Button */
.btn.icon {
    background: rgba(255, 255, 255, 0.08);
    /* Ghost-like default */
    color: #eee;
    width: 36px;
    height: 36px;
    padding: 0;
    font-size: 16px;
    border: 1px solid transparent;
    flex-shrink: 0;
    line-height: 1;
}

.btn.icon:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Collapse Toggle Button - Unified Styling */
.panel-head .btn.icon {
    position: relative;
    /* Prevents jumping during state transitions */
    font-size: 18px;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

/* Keep button in same position during collapse */
.panel.collapsed .panel-head .btn.icon {
    position: relative;
    /* Maintains position */
    /* Rotation removed - buttons stay upright */
}

/* UTILITIES */
button:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

/* UTILITIES */
.full-width {
    width: 100%;
}

.tiny {
    font-size: 11px;
    color: var(--text-muted);
}

.grid {
    display: grid;
    gap: 8px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}

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

.space-between {
    justify-content: space-between;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Checkboxes */
input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: var(--accent-color);
    margin: 0;
}

/* Helper for rows */
.row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
}

/* Section styling - unified with Generator */
.section {
    border-bottom: 1px solid var(--border-color);
    /* No padding on section itself, only on header/content */
}

.section:last-child {
    border-bottom: none;
}

.section-header {
    width: 100%;
    display: flex;
    /* justify-content: space-between removed for better local control */
    align-items: center;
    padding: 12px 17px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-header);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: left;
}

.section-header:hover {
    background: rgba(255, 255, 255, 0.05);
}



.section-header span {
    /* Right side arrow */
    transition: transform 0.2s ease;
    font-size: 10px;
    color: #888;
}

/* Arrow rotation for collapsed/expanded state */
.section.collapsed .section-toggle-icon {
    transform: rotate(0deg);
    /* ▶ pointing right when collapsed */
}

.section:not(.collapsed) .section-toggle-icon {
    transform: rotate(90deg);
    /* ▶ pointing down when expanded */
}