/* ========================================
   Components — Buttons, Chips, Sliders, Cards
   ======================================== */

/* ---- Buttons ---- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    line-height: 1.4;
}

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

.btn-primary {
    background: var(--glow-color, rgba(37, 99, 235, 0.15));
    color: var(--color-primary-light);
    border-color: var(--glow-border, rgba(59, 130, 246, 0.4));
    box-shadow: var(--glow-shadow, 0 0 8px rgba(59, 130, 246, 0.25));
}

.btn-primary:hover:not(:disabled) {
    background: rgba(250, 204, 100, 0.12);
    box-shadow: var(--glow-shadow-strong, 0 0 12px rgba(59, 130, 246, 0.35));
}

.btn-secondary {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border-color: var(--color-border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--color-text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.btn-lg {
    padding: 12px var(--space-lg);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

/* ---- Hidden Inputs ---- */

.hidden-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
    pointer-events: none;
}

/* display:none variant for file inputs that don't need positioning */
input[type="file"].hidden-input {
    display: none;
}

/* ---- Chips ---- */

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.chip-group-spaced {
    margin-bottom: var(--space-sm);
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-family: var(--font-family);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip:hover {
    border-color: var(--glow-border, var(--color-primary-light));
    color: var(--color-primary);
}

.chip.active {
    background: var(--glow-color, rgba(37, 99, 235, 0.15));
    color: var(--color-primary-light);
    border-color: var(--glow-border, rgba(59, 130, 246, 0.4));
    box-shadow: var(--glow-shadow, 0 0 8px rgba(59, 130, 246, 0.25));
}

.chip-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.chip-color-pick {
    position: relative;
    cursor: pointer;
}

/* ---- Sliders ---- */

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

.slider-control-spaced {
    margin-top: var(--space-sm);
}

.slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slider-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
}

.slider-value {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-primary);
    min-width: 32px;
    text-align: right;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    outline: none;
    cursor: pointer;
    padding: 0 2px;
    overflow: hidden;
}

input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, rgba(250, 204, 100, 0.08) var(--range-progress, 50%), transparent var(--range-progress, 50%));
    height: 28px;
    border-radius: var(--radius-full);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 48px;
    height: 24px;
    margin-top: 2px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    border: 1px solid rgba(250, 204, 100, 0.2);
    box-shadow: 0 0 8px rgba(250, 204, 100, 0.08);
    cursor: pointer;
}

input[type="range"]::-moz-range-track {
    background: transparent;
    height: 28px;
    border-radius: var(--radius-full);
}

input[type="range"]::-moz-range-progress {
    background: rgba(250, 204, 100, 0.08);
    border-radius: var(--radius-full);
    height: 28px;
}

input[type="range"]::-moz-range-thumb {
    width: 48px;
    height: 24px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-full);
    border: 1px solid rgba(250, 204, 100, 0.2);
    box-shadow: 0 0 8px rgba(250, 204, 100, 0.08);
    cursor: pointer;
}

/* Light theme overrides for sliders */
[data-theme="light"] input[type="range"]::-webkit-slider-runnable-track {
    background: linear-gradient(to right, rgba(37, 99, 235, 0.15) var(--range-progress, 50%), transparent var(--range-progress, 50%));
}
[data-theme="light"] input[type="range"]::-webkit-slider-thumb {
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.25);
}
[data-theme="light"] input[type="range"]::-moz-range-progress {
    background: rgba(37, 99, 235, 0.15);
}
[data-theme="light"] input[type="range"]::-moz-range-thumb {
    border: 1px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.25);
}

/* ---- Section Cards ---- */

.control-section {
    padding: var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
}

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

.section-title {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-sm);
}

.section-title.collapsible {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.section-title.collapsible:hover {
    color: var(--color-text-secondary);
}

.section-chevron {
    display: inline-block;
    font-size: 10px;
    transition: transform var(--transition-fast);
    margin-left: auto;
}

.section-chevron::after {
    content: "\25B2";
}

.collapsed .section-chevron::after {
    content: "\25BC";
}

.collapsed > .section-title {
    margin-bottom: 0;
}

.section-body {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.collapsed > .section-body {
    display: none;
}

/* ---- Stepper ---- */

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

.stepper-label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    min-width: 32px;
}

.stepper-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    font-size: var(--font-size-lg);
    font-family: var(--font-family);
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

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

.stepper-btn:active {
    background: var(--color-bg-tertiary);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.stepper-value {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    min-width: 28px;
    text-align: center;
}

/* ---- Number Input ---- */

.number-input {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.number-input label {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--color-text-secondary);
    min-width: 36px;
}

.number-input input[type="number"] {
    width: 60px;
    padding: var(--space-xs) var(--space-sm);
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    text-align: center;
    background: var(--color-bg-input);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    outline: none;
}

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

/* ---- Toast Container ---- */

.toast-container {
    position: fixed;
    bottom: var(--space-lg);
    right: var(--space-lg);
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.toast {
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    font-size: var(--font-size-sm);
    animation: slideIn 200ms ease forwards;
    max-width: 320px;
}

.toast.toast-success { border-left: 3px solid var(--color-success); }
.toast.toast-error   { border-left: 3px solid var(--color-danger); }
.toast.toast-warning { border-left: 3px solid var(--color-warning); }

.toast.toast-exit {
    animation: slideOut 200ms ease forwards;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes slideOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* ---- Modal ---- */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal);
    opacity: 0;
    transition: opacity var(--transition-base);
    pointer-events: none;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    background: var(--color-bg-secondary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-xl);
    max-width: 400px;
    width: 90%;
}

.modal-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    margin-bottom: var(--space-sm);
}

.modal-message {
    font-size: var(--font-size-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
}

/* ---- Tier Badge ---- */

.tier-badge {
    display: inline-block;
    font-size: 9px;
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border-light);
    border-radius: var(--radius-full);
    padding: 1px 6px;
    vertical-align: middle;
    line-height: 1.4;
}
