/* ChartFlam Styles - Based on PromptFlam Design System */

/* ============================================
   CSS VARIABLES
   ============================================ */
:root {
    /* Colors from PromptFlam */
    --bg-light: #eeeeee;
    --bg-medium: #cccccc;
    --text-dark: #333333;
    --text-medium: #555555;
    --text-light: #9a9a9a;
    --favourite-active: #DC143C;
    --copy-active: #4f0388;
    --tooltip-bg: #e6e2fff2;
    --splash-gradient: linear-gradient(135deg, #8A2BE2, #4B0082);
    --enter-btn: #FFD700;
    --enter-btn-hover: #FFC107;
    --white: #FFFFFF;
    --black: #000000;

    /* Chart Icon Colors */
    --chart-icon-default: #999999;
    --chart-icon-active: #555555;

    /* Default Chart Color Palette - Refined & Sophisticated */
    --chart-color-1: #6A5ACD;
    --chart-color-2: #FFDAB9;
    --chart-color-3: #66C0B4;
    --chart-color-4: #E6E6FA;
    --chart-color-5: #DDA0DD;
    --chart-color-6: #ADD8E6;
    --chart-color-7: #FAEBD7;
    --chart-color-8: #C0C0C0;

    /* Spacing - Tighter for mobile-first compact design */
    --spacing-xs: 0.375rem;
    --spacing-sm: 0.625rem;
    --spacing-md: 0.875rem;
    --spacing-lg: 1.25rem;
    --spacing-xl: 1.75rem;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-round: 50%;
}

/* ============================================
   GLOBAL RESET
   ============================================ */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SPLASH SCREEN
   ============================================ */
.splash {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--splash-gradient);
    color: var(--white);
    text-align: center;
    padding: var(--spacing-xl);
}

.splash img {
    width: 225px;
    height: auto;
    margin-bottom: var(--spacing-xl);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.splash h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: var(--spacing-md);
    letter-spacing: -0.5px;
}

.splash p {
    font-size: 1.2rem;
    margin-bottom: var(--spacing-xl);
    opacity: 0.95;
}

.btn-enter {
    background-color: var(--enter-btn);
    color: var(--text-dark);
    border: none;
    padding: 0.5rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    font-family: 'Inter', sans-serif;
}

.btn-enter:hover {
    background-color: var(--enter-btn-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-enter:active {
    transform: translateY(0);
}

/* ============================================
   MAIN APP CONTAINER
   ============================================ */
.app-container {
    max-width: 480px;
    margin: 0 auto;
    padding: var(--spacing-md);
    min-height: 100vh;
}

/* ============================================
   CHART TYPE SELECTOR
   ============================================ */
.chart-selector-container {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    min-height: 56px;
}

.chart-selector {
    display: flex;
    justify-content: space-around;
    align-items: center;
    gap: var(--spacing-xs);
}

.chart-icon {
    width: 64px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--chart-icon-default);
    padding: 0;
    background-color: transparent;
    border: none;
}

.chart-icon:hover {
    transform: scale(1.05);
}

.chart-icon.active {
    color: var(--chart-icon-active);
}

.chart-icon svg {
    width: 32px;
    height: 32px;
}

/* ============================================
   CHART DISPLAY
   ============================================ */
.chart-display-container {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.chart-canvas-wrapper {
    background-color: var(--white);
    padding: var(--spacing-xs);
    border-radius: var(--radius-md);
    text-align: center;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: var(--spacing-sm);
    /* Pushes the title down slightly */
    margin-bottom: var(--spacing-lg);
    color: var(--text-dark);
}

.chart-canvas-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
}

#chart-canvas {
    max-width: 100%;
}

.chart-caption {
    font-size: 0.95rem;
    color: var(--text-medium);
    margin-top: var(--spacing-lg);
    font-style: italic;
}

/* ============================================
   CONTROLS CONTAINER
   ============================================ */
.controls-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Control Sections (Dropdowns) */
.control-section {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border: none;
    min-height: 56px;
}

.control-section summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1rem;
    list-style: none;
    padding: 0;
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 32px;
}

.control-section summary::-webkit-details-marker {
    display: none;
}

.control-section summary::after {
    content: '';
    width: 24px;
    height: 24px;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23555555"><path d="M12 15.0006L7.75732 10.758L9.17154 9.34375L12 12.1722L14.8284 9.34375L16.2426 10.758L12 15.0006Z"></path></svg>');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.control-section[open] summary {
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.control-section[open] summary::after {
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23555555"><path d="M12 11.8284L9.17154 14.6569L7.75732 13.2426L12 9L16.2426 13.2426L14.8284 14.6569L12 11.8284Z"></path></svg>');
    width: 24px;
    height: 24px;
}

.control-content {
    padding: 0 0 var(--spacing-sm);
}

/* Inline Control Section (for smoothing slider) */
.control-section-inline {
    background-color: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--spacing-sm) var(--spacing-md);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    min-height: 56px;
}

.smoothing-toggles {
    display: flex;
    gap: var(--spacing-xs);
}

.smooth-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--bg-medium);
    background: transparent;
    color: #555555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    border-radius: var(--radius-sm);
}

.smooth-toggle svg {
    width: 20px;
    height: 20px;
}

.smooth-toggle.active {
    background: #555555;
    color: white;
    border-color: #555555;
}

.smooth-toggle:hover:not(.active) {
    background: #f0f0f0;
}

.control-section-inline input[type="range"] {
    flex: 1;
}

.legend-control-row {
    display: flex;
    gap: var(--spacing-xs);
    align-items: center;
}

.legend-size-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    color: var(--text-light);
}

.legend-size-icon svg {
    width: 18px;
    height: 18px;
}

/* ============================================
   DATA INPUT
   ============================================ */
.data-tabs {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-md);
}

.tab-btn {
    flex: 1;
    padding: var(--spacing-sm) var(--spacing-md);
    border: none;
    background-color: var(--bg-light);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
    color: var(--text-dark);
}

.tab-btn:hover {
    background-color: var(--bg-medium);
}

.tab-btn.active {
    background-color: #555555;
    color: var(--white);
    font-weight: 600;
}

.tab-content {
    display: none;
}

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

/* Manual Input Rows */
#manual-rows {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-md);
}

.manual-row {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.manual-row input {
    flex: 1;
    min-width: 0; /* Fix for flex item overflow on some mobile browsers */
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s ease;
    color: var(--text-dark);
}

.manual-row input:focus {
    outline: none;
    border-color: var(--text-medium);
}

/* Remove number input spinners */
.manual-row input[type="number"]::-webkit-inner-spin-button,
.manual-row input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.manual-row input[type="number"] {
    -moz-appearance: textfield;
}

.manual-row .row-label {
    flex: 2;
}

.manual-row .row-value {
    flex: 1;
}

.btn-remove {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: var(--spacing-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.btn-remove:hover {
    color: var(--favourite-active);
}

.btn-add {
    width: 100%;
    padding: var(--spacing-xs);
    background-color: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-add svg {
    width: 32px;
    height: 32px;
}

.btn-add:hover {
    color: var(--text-medium);
    transform: scale(1.1);
}

/* CSV Input */
#csv-textarea {
    width: 100%;
    min-height: 120px;
    padding: var(--spacing-md);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    margin-bottom: var(--spacing-sm);
}

#csv-textarea:focus {
    outline: none;
    border-color: var(--copy-active);
}

/* Bar chart orientation controls */
.bar-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
}

.bar-controls .tab-btn {
    flex: 1;
    margin: 0;
}

/* ============================================
   COLOR CONTROLS
   ============================================ */
#color-controls {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0;
}

.color-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid #e0e0e0;
    margin: 0;
}

.color-control:last-of-type:not(.bg-control) {
    border-bottom: 1px solid #e0e0e0;
}

.color-label {
    flex: 1;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.color-picker {
    width: 32px;
    height: 32px;
    border: 2px solid var(--bg-medium);
    border-radius: 50%;
    cursor: pointer;
    transition: border-color 0.2s ease;
    padding: 0;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-picker::-moz-color-swatch {
    border: none;
    border-radius: 50%;
}

/* Bar chart color controls grouping */
.bar-color-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

/* Bar chart reset button */
.bar-reset-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: #555555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease, transform 0.2s ease;
}

.bar-reset-btn:hover {
    color: var(--text-dark);
    transform: rotate(-45deg);
}

.bar-reset-btn:active {
    transform: rotate(-90deg);
}

.color-picker:hover {
    border-color: var(--text-medium);
}

/* Background Control */
.bg-control {
    padding: var(--spacing-sm) 0;
    border-bottom: none;
}

.bg-options {
    display: flex;
    gap: var(--spacing-sm);
}

.bg-option {
    background: none;
    border: 2px solid transparent;
    border-radius: 50%;
    padding: 2px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bg-option.active {
    border-color: var(--text-medium);
}

.bg-option:hover {
    transform: scale(1.1);
}

.bg-circle {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ddd;
}

.bg-white {
    background-color: #FFFFFF;
}

.bg-transparent {
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
}

.bg-rainbow {
    background: linear-gradient(to right,
            rgb(255, 0, 0) 0%,
            rgb(255, 154, 0) 10%,
            rgb(208, 222, 33) 20%,
            rgb(79, 220, 74) 30%,
            rgb(63, 218, 216) 40%,
            rgb(47, 201, 226) 50%,
            rgb(28, 127, 238) 60%,
            rgb(95, 21, 242) 70%,
            rgb(186, 12, 248) 80%,
            rgb(251, 7, 217) 90%,
            rgb(255, 0, 0) 100%);
}

/* ============================================
   TEXT CONTROLS
   ============================================ */
.text-subsection-header {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-medium);
    margin: 0 0 var(--spacing-sm) 0;
    padding: 0;
}

.text-subsection {
    margin-bottom: var(--spacing-sm);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid #e0e0e0;
}

.text-subsection:last-child {
    border-bottom: none;
}

.text-input-field {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    margin-bottom: var(--spacing-sm);
    color: var(--text-dark);
}

.text-input-field::placeholder {
    color: #bbb;
}

.text-input-field:focus {
    outline: none;
    border-color: var(--text-medium);
}

.font-control-row {
    display: flex;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-xs);
    align-items: center;
}

.font-select {
    flex: 1;
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    background: white;
    color: var(--text-dark);
    appearance: none;
    background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23555555"><path d="M12 15.0006L7.75732 10.758L9.17154 9.34375L12 12.1722L14.8284 9.34375L16.2426 10.758L12 15.0006Z"></path></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 20px;
    padding-right: 32px;
}

.font-select option {
    padding: var(--spacing-xs);
}

.font-select option[value="Inter"] {
    font-family: 'Inter', sans-serif;
}

.font-select option[value="Alfa Slab One"] {
    font-family: 'Alfa Slab One', cursive;
}

.font-select option[value="Lora"] {
    font-family: 'Lora', serif;
}

.font-select option[value="Playfair Display"] {
    font-family: 'Playfair Display', serif;
}

.font-select option[value="Saira Condensed"] {
    font-family: 'Saira Condensed', sans-serif;
}

.font-select option[value="Special Elite"] {
    font-family: 'Special Elite', cursive;
}

.text-controls {
    display: flex;
    gap: var(--spacing-xs);
    flex-wrap: wrap;
    align-items: center;
}

.text-control-group {
    display: flex;
    gap: 0;
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
}

.text-control-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--bg-medium);
    background: white;
    color: #555555;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding: 0;
    border-radius: var(--radius-sm);
}



.text-control-btn svg {
    width: 18px;
    height: 18px;
}

.text-control-btn.active {
    background: #555555;
    color: white;
    border-color: #555555;
}

.text-control-btn:hover:not(.active) {
    background: var(--bg-light);
}

.text-slider {
    flex: 1;
    margin: 0 var(--spacing-sm);
}

.text-toggle-group {
    display: flex;
    gap: var(--spacing-xs);
}

/* ============================================
   INPUT GROUPS
   ============================================ */
.input-group {
    margin-bottom: var(--spacing-md);
}

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

.input-group label {
    display: block;
    margin-bottom: var(--spacing-xs);
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-dark);
}

.input-group input[type="text"],
.input-group input[type="color"] {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
    transition: border-color 0.2s ease;
}

.input-group input[type="text"]:focus {
    outline: none;
    border-color: var(--copy-active);
}

.input-group input[type="color"] {
    height: 44px;
    cursor: pointer;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: #ccc;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #555555;
    cursor: pointer;
    transition: all 0.2s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #555555;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.15);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

.btn-secondary {
    background-color: var(--bg-medium);
    color: var(--text-dark);
    width: 100%;
}

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

.btn-primary {
    background-color: #e0e0e0;
    color: var(--text-dark);
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-size: 1.1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-radius: var(--radius-lg);
}

.btn-primary:hover {
    background-color: #d0d0d0;
}

.btn-primary:active {
    transform: scale(1.02);
    background-color: #c8c8c8;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 480px) {
    .app-container {
        padding: var(--spacing-sm);
    }

    .splash h1 {
        font-size: 2rem;
    }

    .splash p {
        font-size: 1rem;
    }

    .splash img {
        width: 200px;
    }

    .chart-icon {
        width: 70px;
        height: 70px;
    }

    .chart-icon svg {
        width: 32px;
        height: 32px;
    }

    .chart-title {
        font-size: 1.3rem;
    }
}

@media (min-width: 768px) {
    .app-container {
        box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
        background-color: var(--bg-light);
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.app-container {
    animation: fadeIn 0.3s ease-out;
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

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

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

.mt-1 {
    margin-top: var(--spacing-md);
}

.mb-1 {
    margin-bottom: var(--spacing-md);
}

.mt-2 {
    margin-top: var(--spacing-lg);
}

.mb-2 {
    margin-bottom: var(--spacing-lg);
}

/* ============================================
   FEEDBACK MESSAGES
   ============================================ */
.feedback-message {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background-color: var(--text-dark);
    color: var(--white);
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 90%;
    text-align: center;
    font-weight: 500;
}

.feedback-message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.feedback-message.feedback-success {
    background-color: #10b981;
}

.feedback-message.feedback-error {
    background-color: var(--favourite-active);
}

.feedback-message.feedback-info {
    background-color: var(--copy-active);
}



/* ============================================
   INPUT VALIDATION STATES
   ============================================ */
.input-error {
    border-color: var(--favourite-active) !important;
    background-color: rgba(220, 20, 60, 0.05);
}

.input-error:focus {
    outline: 2px solid var(--favourite-active);
    outline-offset: 2px;
}

.input-hint {
    display: block;
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: var(--spacing-xs);
}

/* ============================================
   FOCUS INDICATORS
   ============================================ */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
details summary:focus-visible {
    outline: 2px solid var(--copy-active);
    outline-offset: 2px;
}

.chart-icon:focus-visible {
    outline: 3px solid var(--copy-active);
    outline-offset: 3px;
}

/* ============================================
   LOADING STATES
   ============================================ */
button[aria-busy="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

button[aria-busy="true"]::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 3px solid var(--white);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   IMPROVED ACCESSIBILITY
   ============================================ */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-icon {
        border-width: 3px;
    }

    input,
    textarea {
        border-width: 2px;
    }
}

/* ============================================
   COLORIS CUSTOMIZATION
   ============================================ */

/* Style the color picker inputs directly */
input.color-picker[data-coloris] {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    border: 2px solid var(--bg-medium) !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    transition: border-color 0.2s ease !important;
    /* Hide text content */
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-indent: -9999px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

input.color-picker[data-coloris]:hover {
    border-color: var(--text-medium) !important;
}

/* Coloris wrapper (if it gets created) */
.clr-field {
    border: none !important;
    border-radius: 50% !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
    margin: 0 !important;
    display: inline-block !important;
    position: relative !important;
}

/* Coloris button - shows the color swatch */
.clr-field button {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    border-radius: 50% !important;
    border: 2px solid var(--bg-medium) !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    transition: border-color 0.2s ease !important;
    position: relative !important;
    /* Hide text content */
    font-size: 0 !important;
    line-height: 0 !important;
    color: transparent !important;
    text-indent: -9999px !important;
    overflow: hidden !important;
    white-space: nowrap !important;
}

.clr-field button:hover {
    border-color: var(--text-medium) !important;
}

/* Hide the actual input field when wrapped */
.clr-field input {
    position: absolute !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    pointer-events: none !important;
}

/* ============================================
   PICTOGRAM COMPONENTS
   ============================================ */

/* Pictogram input boxes - square and same size */
.pictogram-input-box {
    width: 44px;
    height: 44px;
    padding: var(--spacing-xs);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 0.95rem;
}

/* Remove number input spinners for pictogram boxes */
.pictogram-input-box[type="number"]::-webkit-inner-spin-button,
.pictogram-input-box[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.pictogram-input-box[type="number"] {
    -moz-appearance: textfield;
}

#icon-search-drawer {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    bottom: 0;
    background-color: var(--white);
    z-index: 10000;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(100%);
    }

    to {
        transform: translateX(-50%) translateY(0);
    }
}

.drawer-header {
    position: sticky;
    top: 0;
    background-color: var(--white);
    padding: var(--spacing-md);
    border-bottom: 2px solid var(--bg-light);
    z-index: 100;
}

.btn-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-xs);
    color: var(--text-medium);
    transition: color 0.2s ease;
}

.btn-close:hover {
    color: var(--text-dark);
}

.category-dropdown {
    margin-top: var(--spacing-xl);
}

.category-dropdown label {
    display: block;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--text-dark);
}

.category-dropdown select {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--bg-medium);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    background: white;
    color: var(--text-dark);
}

.drawer-content {
    padding: var(--spacing-md);
}

.icon-category-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: var(--spacing-xl);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-xs);
    border-bottom: 2px solid var(--bg-medium);
}

.icon-category-header:first-child {
    margin-top: 0;
}

.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
}

.icon-item {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: 2px solid var(--bg-light);
    border-radius: var(--radius-sm);
    background-color: var(--white);
    transition: all 0.2s ease;
    padding: var(--spacing-xs);
}

.icon-item svg {
    width: 36px;
    height: 36px;
    color: var(--text-medium);
}

.icon-item:hover {
    border-color: var(--copy-active);
    background-color: var(--tooltip-bg);
    transform: scale(1.05);
}

.icon-item:active {
    transform: scale(0.95);
}

@media (max-width: 480px) {
    .icon-grid {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    }

    .icon-item {
        width: 50px;
        height: 50px;
    }

    .icon-item svg {
        width: 30px;
        height: 30px;
    }
}