/**
 * Component Styles - Reusable UI Components
 *
 * Sections:
 * 1. Cards
 * 2. Buttons
 * 3. Forms & Inputs
 * 4. Toggle Switches
 * 5. Tables
 * 6. Accordion
 * 7. Segmented Control
 * 8. Tabs
 * 9. Summary & Stats
 * 10. Warnings
 */

/* =============================================================================
   1. CARDS
   ============================================================================= */

.card {
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    background-color: var(--card);
    box-shadow: var(--shadow-md);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.data-card {
    max-height: 480px;
    overflow: auto;
}

#programSequence {
    max-height: none;
    overflow: visible;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.card-header h2 {
    margin: 0;
}

.card-header .btn {
    width: auto;
    flex-shrink: 0;
}

/* Score Controls Section */
#scoreControls {
    margin-bottom: var(--space-md);
}

#scorePositions {
    border-top: 1px solid var(--border);
    padding-top: var(--space-md);
}

#scoreOptions .score-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-lg);
}

#scoreOptions h3 {
    margin: 0;
}

/* =============================================================================
   2. BUTTONS
   ============================================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 0 var(--space-md);
    height: 40px;
    cursor: pointer;
    text-align: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--button-border, var(--button-bg));
    background-color: var(--button-bg);
    color: var(--button-ink);
    font: inherit;
    transition: filter var(--transition-fast), background-color var(--transition-normal);
}

.btn .icon {
    line-height: 1;
}

/* Button Variants */
.btn-secondary {
    --button-bg: var(--card);
    --button-ink: var(--ink);
}

.btn-tertiary {
    --button-bg: transparent;
    --button-ink: var(--ink);
}

.btn-success {
    --button-bg: var(--success);
    --button-ink: var(--card);
}

/* Button States */
.btn:hover:not([disabled]) {
    filter: brightness(0.95);
}

.btn:active:not([disabled]),
.btn.active {
    filter: brightness(0.9);
}

.btn:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

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

/* Icon Button */
.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-icon .icon {
    font-size: 20px;
}

/* Button Grid */
.button-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.button-grid .btn {
    width: 100%;
}

.button-grid .custom-size-button {
    grid-column: 1 / -1;
}

/* Copy Button */
.copy-btn {
    width: auto;
    padding: 0 var(--space-sm);
}

/* =============================================================================
   3. FORMS & INPUTS
   ============================================================================= */

form {
    display: grid;
    row-gap: var(--space-md);
}

.dimensions-section {
    margin: 0;
}

input,
select {
    width: 100%;
    height: 40px;
    padding: var(--space-sm);
    box-sizing: border-box;
    background-color: var(--card);
    color: var(--ink);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

input:focus,
select:focus {
    outline: 2px solid var(--blue);
    outline-offset: -1px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(120px, auto) 1fr;
    column-gap: var(--space-sm);
    row-gap: var(--space-md);
    align-items: center;
}

/* Checkbox Label */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    grid-column: 1 / -1;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    height: auto;
}

/* Input with Unit Suffix */
.input-with-unit {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.input-with-unit input {
    flex: 1;
}

.input-unit {
    font-size: 14px;
    color: var(--ink);
    opacity: 0.7;
    min-width: 24px;
}

/* =============================================================================
   4. TOGGLE SWITCHES
   ============================================================================= */

.menu-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.switch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 16px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.switch .slider {
    position: relative;
    width: 40px;
    height: 24px;
    background-color: var(--border);
    border-radius: 24px;
    transition: background-color var(--transition-normal);
    cursor: pointer;
}

.switch .slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background-color: var(--card);
    border-radius: 50%;
    transition: transform var(--transition-normal);
}

.switch input:checked + .slider {
    background-color: var(--blue);
}

.switch input:checked + .slider::before {
    transform: translateX(16px);
}

.switch input:focus-visible + .slider {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* =============================================================================
   5. TABLES
   ============================================================================= */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: var(--space-md);
}

th,
td {
    border: 1px solid var(--border);
    padding: var(--space-sm);
    font-size: 14px;
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

th {
    background-color: var(--bg);
    color: var(--ink);
    position: sticky;
    top: 0;
    text-align: left;
}

td {
    font-family: monospace;
    text-align: right;
}

tbody tr:nth-child(even) {
    background-color: var(--bg);
}

/* Step Column Width */
#programSequence table td:first-child,
#scorePositions table td:first-child {
    width: 4ch;
}

/* Dense Table Variant */
.dense-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.dense-table th,
.dense-table td {
    padding: 6px var(--space-sm);
    border: 1px solid var(--border);
}

.dense-table th {
    background-color: var(--bg);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dense-table td {
    font-family: monospace;
    font-variant-numeric: tabular-nums;
}

/* =============================================================================
   6. ACCORDION
   ============================================================================= */

.accordion {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.accordion-item {
    border: 1px solid var(--border);
    background-color: var(--card);
    transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.accordion-item:first-child {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.accordion-item:last-child {
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.accordion-item:only-child {
    border-radius: var(--radius-lg);
}

.accordion-item + .accordion-item {
    border-top: none;
}

.accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 20px;
    cursor: pointer;
    user-select: none;
    transition: background-color var(--transition-normal);
}

.accordion-header:hover {
    background-color: var(--bg);
}

.accordion-header:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

.accordion-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.accordion-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 18px;
    transition: transform var(--transition-normal);
}

.accordion-item.expanded .accordion-icon {
    transform: rotate(180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow);
}

.accordion-item.expanded .accordion-content {
    max-height: 1000px;
}

.accordion-body {
    padding: 0 20px 20px;
}

/* =============================================================================
   7. SEGMENTED CONTROL
   ============================================================================= */

.segmented-control {
    display: inline-flex;
    background-color: var(--bg);
    border-radius: var(--radius-md);
    padding: 2px;
    gap: 2px;
    width: 100%;
}

.segmented-control input[type="radio"] {
    display: none;
}

.segmented-control label {
    flex: 1;
    padding: var(--space-sm) 12px;
    text-align: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: background-color var(--transition-normal), color var(--transition-normal);
    user-select: none;
}

.segmented-control input[type="radio"]:checked + label {
    background-color: var(--card);
    color: var(--ink);
    box-shadow: var(--shadow-sm);
}

.segmented-control label:hover {
    opacity: 0.8;
}

/* =============================================================================
   8. TABS
   ============================================================================= */

.tabs {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.tab-list {
    display: flex;
    border-bottom: 2px solid var(--border);
    gap: var(--space-xs);
    padding: 0;
    margin: 0;
    list-style: none;
}

.tab-button {
    flex: 1;
    padding: 12px var(--space-md);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font: inherit;
    color: var(--ink);
    opacity: 0.6;
    transition: opacity var(--transition-normal), border-color var(--transition-normal);
}

.tab-button:hover {
    opacity: 0.8;
}

.tab-button.active {
    opacity: 1;
    border-bottom-color: var(--blue);
    font-weight: 600;
}

.tab-button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: -2px;
}

.tab-panels {
    flex: 1;
    overflow: auto;
}

.tab-panel {
    display: none;
    padding: 20px;
}

.tab-panel.active {
    display: block;
}

/* =============================================================================
   9. SUMMARY & STATS
   ============================================================================= */

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.summary-card {
    padding: var(--space-md);
    background-color: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.summary-card-label {
    font-size: 12px;
    opacity: 0.7;
    margin-bottom: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-card-value {
    font-size: 24px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.summary-section {
    margin-bottom: var(--space-lg);
}

.summary-section h3 {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    opacity: 0.7;
}

/* =============================================================================
   10. WARNINGS
   ============================================================================= */

.warning-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.warning-item {
    padding: 12px;
    background-color: rgba(255, 193, 7, 0.1);
    border-left: 3px solid #ffc107;
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-sm);
    font-size: 14px;
}

.warning-item:last-child {
    margin-bottom: 0;
}
