/* ═══════════════════════════════════════════════════════════
   JungleMidiForge — Dark Studio Theme
   ═══════════════════════════════════════════════════════════ */

:root {
    --bg-dark: #0d0d0f;
    --bg-panel: #161619;
    --bg-card: #1c1c21;
    --bg-input: #222228;
    --bg-hover: #2a2a32;
    --border: #2e2e38;
    --border-focus: #6366f1;
    --text: #e4e4e7;
    --text-dim: #8b8b96;
    --text-muted: #55555f;
    --accent: #6366f1;
    --accent-hover: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.25);
    --green: #22c55e;
    --green-dim: rgba(34, 197, 94, 0.15);
    --orange: #f59e0b;
    --red: #ef4444;
    --radius: 8px;
    --radius-sm: 5px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font);
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ═══════════════ HEADER ═══════════════ */

header {
    text-align: center;
    padding: 2rem 1rem 1rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(180deg, #111115, var(--bg-dark));
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text), var(--accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.tagline {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-top: 0.35rem;
}

/* ═══════════════ TABS ═══════════════ */

.tabs {
    display: flex;
    justify-content: center;
    gap: 0;
    padding: 0 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-panel);
}

.tab {
    padding: 0.85rem 2rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-dim);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover { color: var(--text); }
.tab.active {
    color: var(--accent-hover);
    border-bottom-color: var(--accent);
}

/* ═══════════════ MAIN LAYOUT ═══════════════ */

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

@media (max-width: 900px) {
    .panel-grid { grid-template-columns: 1fr; }
}

.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
}

.panel h2 {
    font-size: 0.9rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.panel h2:not(:first-child) {
    margin-top: 1.5rem;
}

/* ═══════════════ CONTROLS ═══════════════ */

.control-group {
    margin-bottom: 1rem;
}

.control-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 0.35rem;
}

.optional { color: var(--text-muted); font-weight: 400; }

select, input[type="number"], input[type="text"] {
    width: 100%;
    padding: 0.55rem 0.75rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 0.85rem;
    font-family: var(--font);
    transition: border-color 0.2s;
}

select:focus, input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

select { cursor: pointer; appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8b96'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

.chord-input {
    font-size: 1.1rem !important;
    font-family: var(--font-mono) !important;
    letter-spacing: 0.03em;
    padding: 0.75rem 1rem !important;
}

.row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* ═══════════════ TOGGLE ═══════════════ */

.toggle-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem !important;
    color: var(--text) !important;
}

.toggle-label input[type="checkbox"] {
    width: 18px; height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

/* ═══════════════ CHORD SHORTCUTS ═══════════════ */

.chord-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
    margin-bottom: 1.25rem;
    margin-top: 0.5rem;
}

.shortcut-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-right: 0.25rem;
}

.chip {
    padding: 0.3rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-dim);
    font-size: 0.72rem;
    font-family: var(--font-mono);
    cursor: pointer;
    transition: all 0.15s;
}

.chip:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
    color: var(--text);
}

/* ═══════════════ STAGE SELECTOR ═══════════════ */

.stage-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.stage-chip {
    display: inline-flex !important;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.7rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.78rem !important;
    color: var(--text-dim) !important;
}

.stage-chip input { display: none; }

.stage-chip.active {
    background: var(--accent-glow);
    border-color: var(--accent);
    color: var(--accent-hover) !important;
}

.stage-chip:hover { border-color: var(--accent); }

/* ═══════════════ BUTTONS ═══════════════ */

.btn-primary {
    width: 100%;
    padding: 0.85rem;
    margin-top: 1.25rem;
    background: var(--accent);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 16px var(--accent-glow);
    transform: translateY(-1px);
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-develop {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.btn-download {
    width: 100%;
    padding: 0.85rem;
    margin-top: 1rem;
    background: var(--green);
    border: none;
    border-radius: var(--radius);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-download:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 16px rgba(34, 197, 94, 0.25);
}

.btn-icon { font-size: 1.1rem; }

/* ═══════════════ RESULTS PANEL ═══════════════ */

.results-panel {
    display: flex;
    flex-direction: column;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    min-height: 300px;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.empty-state p { margin: 0.25rem 0; }

/* Result meta */
.result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.meta-tag {
    padding: 0.3rem 0.65rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
}

.meta-tag strong {
    color: var(--accent-hover);
    font-weight: 500;
}

/* Chord grid */
.chord-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.chord-cell {
    padding: 0.75rem 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-align: center;
    transition: all 0.15s;
}

.chord-cell:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.chord-bar {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.chord-name {
    font-size: 1.1rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
}

.chord-quality {
    font-size: 0.7rem;
    color: var(--accent-hover);
    margin-top: 0.15rem;
}

/* Development arc */
.dev-arc {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 1rem;
    overflow-x: auto;
    padding: 0.5rem 0;
}

.arc-stage {
    flex: 1;
    min-width: 80px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    position: relative;
}

.arc-stage:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.arc-stage:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.arc-stage-num {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-bottom: 0.15rem;
}

.arc-stage-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-hover);
}

.arc-stage-bar {
    height: 3px;
    background: var(--accent);
    border-radius: 2px;
    margin-top: 0.5rem;
    opacity: 0.5;
}

.arc-stage:nth-child(1) .arc-stage-bar { opacity: 0.3; }
.arc-stage:nth-child(2) .arc-stage-bar { opacity: 0.5; }
.arc-stage:nth-child(3) .arc-stage-bar { opacity: 0.75; }
.arc-stage:nth-child(4) .arc-stage-bar { opacity: 1.0; }
.arc-stage:nth-child(5) .arc-stage-bar { opacity: 0.6; }

/* Result stats */
.result-stats {
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
    font-family: var(--font-mono);
    color: var(--text-dim);
    line-height: 1.8;
}

.result-stats .stat {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    margin: 0.15rem 0.25rem;
    background: rgba(255, 255, 255, 0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.stat-label {
    color: var(--text-muted);
    margin-right: 0.35rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    color: var(--green);
    font-weight: 500;
}

.result-chords {
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.result-chords strong {
    color: var(--text-dim);
}

.result-actions {
    gap: 0.75rem;
    align-items: center;
    margin-top: 0.5rem;
}

.copy-seed-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    padding: 1px 5px;
    margin-left: 4px;
    color: var(--text-muted);
    vertical-align: middle;
    transition: color 0.2s;
}

.copy-seed-btn:hover {
    color: var(--green);
    border-color: var(--green);
}

.cubase-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.75rem;
    font-style: italic;
}

/* Development stages preview */
.dev-stages-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.stage-preview {
    text-align: center;
    padding: 0.6rem 0.8rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    min-width: 80px;
}

.stage-num {
    font-size: 0.6rem;
    color: var(--accent);
    font-weight: 600;
}

.stage-name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-dim);
}

.stage-desc {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.stage-arrow {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ═══════════════ TAB CONTENT ═══════════════ */

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

.hidden { display: none !important; }

/* ═══════════════ LOADING ═══════════════ */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 13, 15, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
}

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

.loading-overlay p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

/* ═══════════════ FOOTER ═══════════════ */

footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ═══════════════ TOAST ═══════════════ */

.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    padding: 0.75rem 1.5rem;
    background: var(--red);
    color: white;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 1001;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
}

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

.toast.success { background: var(--green); }

/* ═══════════════ DROP ZONE (Import Tab) ═══════════════ */

.drop-zone {
    position: relative;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: var(--bg-card);
    margin-bottom: 1rem;
}

.drop-zone:hover {
    border-color: var(--accent);
    background: var(--bg-hover);
}

.drop-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
    box-shadow: 0 0 30px var(--accent-glow);
}

.drop-zone.drag-over .drop-zone-inner { display: none; }
.drop-zone.drag-over .drop-zone-active { display: block; }
.drop-zone-active { display: none; }

.drop-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.drop-title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.drop-hint {
    color: var(--text-dim);
    font-size: 0.8rem;
}

.file-input-hidden {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.import-file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.file-badge {
    flex: 1;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-hover);
}

.btn-clear {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-clear:hover {
    color: var(--red);
    border-color: var(--red);
}

.btn-import {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.btn-import:hover:not(:disabled) {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
}

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

.result-subhead {
    font-size: 0.9rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}


/* ═══════════════════════════════════════════════════════════
   Arrangement Section Timeline
   ═══════════════════════════════════════════════════════════ */

.section-timeline {
    display: flex;
    width: 100%;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    gap: 2px;
    margin-bottom: 1rem;
}

.section-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.7rem;
    min-width: 36px;
    cursor: default;
    transition: filter 0.15s;
    border-radius: 3px;
}

.section-block:hover {
    filter: brightness(1.25);
}

.section-label {
    font-weight: 700;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
}

.section-bars {
    font-size: 0.6rem;
    opacity: 0.8;
    margin-top: 2px;
}

.section-details {
    margin-top: 0.5rem;
}

.section-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.section-table th {
    text-align: left;
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    color: var(--text-dim);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.section-table td {
    padding: 4px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    color: var(--text-primary);
}


/* ═══════════════ MOBILE RESPONSIVENESS ═══════════════ */

@media (max-width: 600px) {
    header { padding: 1.25rem 0.75rem 0.75rem; }

    header h1 { font-size: 1.25rem; }

    .logo-icon { font-size: 1.5rem; }

    .tagline { font-size: 0.75rem; }

    .tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0 0.25rem;
    }

    .tabs::-webkit-scrollbar { display: none; }

    .tab {
        padding: 0.65rem 0.9rem;
        font-size: 0.78rem;
        white-space: nowrap;
        flex-shrink: 0;
    }

    main { padding: 0.75rem; }

    .panel { padding: 1rem; }

    .panel h2 { font-size: 0.8rem; }

    .row-2 { grid-template-columns: 1fr; gap: 0.5rem; }

    .chord-grid { grid-template-columns: repeat(2, 1fr); gap: 0.35rem; }

    .chord-cell { padding: 0.5rem 0.35rem; }

    .chord-name { font-size: 0.95rem; }

    .btn-primary, .btn-download { padding: 0.75rem; font-size: 0.9rem; }

    .empty-state { min-height: 180px; padding: 1.25rem; }

    .empty-icon { font-size: 2rem; }

    .result-meta { gap: 0.35rem; }

    .meta-tag { font-size: 0.68rem; padding: 0.25rem 0.5rem; }

    .dev-arc { flex-wrap: wrap; gap: 2px; }

    .arc-stage { min-width: 60px; padding: 0.5rem 0.35rem; }

    .result-stats { font-size: 0.72rem; }

    .section-timeline { height: 42px; }

    .section-label { font-size: 0.55rem; }

    .section-table { font-size: 0.7rem; }

    .section-table th, .section-table td { padding: 3px 4px; }

    .drop-zone { padding: 1.5rem 1rem; }

    .drop-icon { font-size: 2rem; }

    .toast {
        left: 1rem;
        right: 1rem;
        transform: translateY(100px);
        text-align: center;
    }

    .toast.show {
        transform: translateY(0);
    }

    .dev-stages-preview { gap: 0.3rem; }

    .stage-preview { min-width: 60px; padding: 0.4rem 0.5rem; }

    .chord-shortcuts { gap: 0.25rem; }

    .chip { padding: 0.25rem 0.5rem; font-size: 0.65rem; }
}

/* Tablet tweaks */
@media (min-width: 601px) and (max-width: 900px) {
    .chord-grid { grid-template-columns: repeat(3, 1fr); }

    .tab { padding: 0.75rem 1.25rem; font-size: 0.85rem; }
}
