/* ===== Infographic Studio =====
   Scoped to the Infographics section. Inherits the app's theme tokens from
   style.css and adds nothing global except the section switch and panels. */

/* Section switch (Research / Infographics) */
.section-switch {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.section-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

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

.section-btn.active {
    background: var(--accent-dim);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent-glow);
}

.section-panel {
    display: none;
    flex: 1;
    min-height: 0;
    flex-direction: column;
}

.section-panel.active {
    display: flex;
}

/* Deliberately not named `.hidden`: the sidebar already owns that class and
   hides itself with a transform so it can animate. */
.ig-hidden {
    display: none !important;
}

/* ===== Layout ===== */
.ig-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.ig-controls {
    width: 420px;
    min-width: 420px;
    overflow-y: auto;
    padding: 20px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.ig-output {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    padding: 24px;
}

.ig-controls::-webkit-scrollbar,
.ig-output::-webkit-scrollbar {
    width: 6px;
}

.ig-controls::-webkit-scrollbar-thumb,
.ig-output::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 6px;
}

/* ===== Steps ===== */
.ig-step {
    padding-bottom: 22px;
    margin-bottom: 22px;
    border-bottom: 1px solid var(--border-color);
}

.ig-step:last-child {
    border-bottom: none;
}

.ig-step-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.ig-step-head h3 {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.ig-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 11px;
    font-weight: 700;
}

/* ===== Form controls ===== */
.ig-label {
    display: block;
    margin: 14px 0 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.ig-optional {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 400;
    opacity: 0.7;
}

.ig-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    transition: border-color var(--transition);
}

.ig-input:focus {
    outline: none;
    border-color: var(--accent);
}

.ig-input::placeholder {
    color: var(--text-muted);
    opacity: 0.7;
}

.ig-input-sm {
    padding: 7px 10px;
    font-size: 12px;
    margin-bottom: 6px;
}

.ig-input-flag {
    border-color: rgba(251, 113, 133, 0.5);
}

.ig-textarea {
    resize: vertical;
    line-height: 1.5;
}

.ig-select {
    appearance: none;
    cursor: pointer;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
        linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.ig-select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.ig-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.ig-hint {
    margin-top: 6px;
    font-size: 11px;
    line-height: 1.5;
    color: var(--text-muted);
}

.ig-hint-empty {
    padding: 10px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
}

/* ===== Buttons ===== */
.ig-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 14px;
    padding: 11px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.ig-btn:hover:not(:disabled) {
    background: var(--bg-glass-hover);
    border-color: var(--border-light);
}

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

.ig-btn-primary {
    background: var(--accent-dim);
    border-color: var(--accent-glow);
    color: var(--accent);
}

.ig-btn-accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

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

.ig-btn-ghost {
    margin-top: 8px;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
}

.ig-mini-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition);
}

.ig-mini-btn:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

.ig-mini-btn.ig-danger:hover {
    color: var(--error);
    border-color: rgba(251, 113, 133, 0.4);
}

.ig-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    flex-wrap: wrap;
}

.ig-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.ig-toggle.active {
    background: var(--accent-dim);
    border-color: var(--accent-glow);
    color: var(--accent);
}

.ig-toggle-row .ig-hint {
    flex: 1;
    margin-top: 0;
}

/* ===== Repeaters (sections / stats) ===== */
.ig-sublabel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 18px 0 8px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.ig-repeater {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ig-repeat-item {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
}

.ig-repeat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.ig-repeat-num {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
}

.ig-remove {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    transition: color var(--transition);
}

.ig-remove:hover {
    color: var(--error);
}

.ig-repeat-item .ig-input-sm:last-child {
    margin-bottom: 0;
}

/* ===== Word budget & warnings ===== */
.ig-wordcount {
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--bg-glass);
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
}

.ig-wordcount.warn {
    background: rgba(255, 211, 182, 0.12);
    color: var(--warning);
}

.ig-wordcount.over {
    background: rgba(251, 113, 133, 0.15);
    color: var(--error);
}

.ig-warnings:not(:empty) {
    margin-bottom: 12px;
}

.ig-warning {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-left: 2px solid var(--warning);
    border-radius: 0 4px 4px 0;
    background: rgba(255, 211, 182, 0.08);
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* ===== Palette picker ===== */
.ig-chip-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.ig-palette {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    font-family: var(--font);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
}

.ig-palette:hover {
    background: var(--bg-glass-hover);
}

.ig-palette.active {
    border-color: var(--accent);
    background: var(--accent-dim);
}

.ig-swatches {
    display: flex;
    gap: 3px;
}

.ig-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.ig-palette-name {
    font-size: 11px;
    font-weight: 600;
    line-height: 1.3;
}

/* ===== Banners ===== */
.ig-banner {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    margin-bottom: 18px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    line-height: 1.55;
}

.ig-banner code {
    padding: 1px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
}

.ig-banner-warn {
    border: 1px solid rgba(255, 211, 182, 0.3);
    background: rgba(255, 211, 182, 0.08);
    color: var(--text-secondary);
}

.ig-banner-error {
    border: 1px solid rgba(251, 113, 133, 0.35);
    background: rgba(251, 113, 133, 0.1);
    color: #fca5a5;
    animation: fadeInUp 0.25s ease;
}

/* ===== Output side ===== */
.ig-progress {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-glass);
}

.ig-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 60%;
    padding: 40px 24px;
    text-align: center;
    color: var(--text-muted);
}

.ig-empty h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.ig-empty p {
    max-width: 460px;
    font-size: 13px;
    line-height: 1.6;
}

.ig-caveat {
    padding: 12px 14px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 12px !important;
}

/* ===== Gallery ===== */
.ig-gallery {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.ig-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background: var(--bg-secondary);
    overflow: hidden;
    animation: fadeInUp 0.3s ease;
}

.ig-card-image {
    display: block;
    background: #ffffff;
    line-height: 0;
}

.ig-card-image img {
    width: 100%;
    height: auto;
    display: block;
}

.ig-card-body {
    padding: 16px 18px 18px;
}

.ig-card-body h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.ig-caption {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-secondary);
}

.ig-source-line {
    margin-top: 6px;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-muted);
}

.ig-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
}

.ig-chip {
    padding: 3px 8px;
    border-radius: 20px;
    background: var(--bg-glass);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted);
}

.ig-chip-accent {
    background: var(--accent-dim);
    color: var(--accent);
}

.ig-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
}

/* ===== Prompt modal body ===== */
.ig-prompt-text {
    padding: 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 11.5px;
    line-height: 1.65;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .ig-layout {
        flex-direction: column;
        overflow-y: auto;
    }

    .ig-controls {
        width: 100%;
        min-width: 0;
        overflow: visible;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .ig-output {
        overflow: visible;
    }
}

@media (max-width: 640px) {
    .section-btn {
        padding: 6px 9px;
        font-size: 11px;
    }

    .section-btn svg {
        display: none;
    }

    .ig-chip-grid {
        grid-template-columns: 1fr;
    }

    .ig-field-row {
        grid-template-columns: 1fr;
    }
}
