/* ═══════════════════════════════════════════
   World Map Generator — Premium Dark Theme
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0a0a1a;
    --bg-secondary: #12122a;
    --bg-card: rgba(20, 20, 50, 0.7);
    --bg-hover: rgba(30, 30, 60, 0.9);
    --border: rgba(100, 100, 200, 0.15);
    --border-focus: rgba(124, 58, 237, 0.5);
    --text-primary: #e8e8f0;
    --text-secondary: #8888aa;
    --text-muted: #555577;
    --accent-purple: #7c3aed;
    --accent-cyan: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #7c3aed, #06b6d4);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(16px);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.5;
}

/* ── Ambient background glow ────────────── */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: #7c3aed;
    top: -200px;
    left: -200px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: #06b6d4;
    bottom: -150px;
    right: -150px;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background: #e91e63;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0.06;
}

/* ── Header ─────────────────────────────── */
header {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 40px 20px 20px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    margin-top: 8px;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ── Main Layout ────────────────────────── */
main {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    align-items: start;
}

/* ── Glass Panel ────────────────────────── */
.panel {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: border-color var(--transition);
}

.panel:hover {
    border-color: rgba(100, 100, 200, 0.25);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.panel-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.panel-actions {
    display: flex;
    gap: 6px;
}

/* ── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn:hover {
    background: var(--bg-hover);
    border-color: rgba(100, 100, 200, 0.3);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-primary {
    background: var(--accent-gradient);
    border: none;
    color: white;
    font-weight: 600;
    padding: 14px 28px;
    font-size: 1rem;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.45);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-generate {
    width: 100%;
    margin-top: 16px;
    justify-content: center;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.1);
    color: var(--accent-cyan);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-download:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.5);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ── Textarea ───────────────────────────── */
textarea {
    width: 100%;
    min-height: 420px;
    max-height: 70vh;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(10, 10, 30, 0.6);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.82rem;
    line-height: 1.6;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

textarea::placeholder {
    color: var(--text-muted);
}

/* ── Settings Row ───────────────────────── */
.settings-row {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.input-group {
    flex: 1;
}

.input-group label {
    display: block;
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    font-weight: 500;
}

.input-group input[type="text"],
.input-group input[type="number"] {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: rgba(10, 10, 30, 0.6);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition);
}

.input-group input:focus {
    border-color: var(--border-focus);
}

/* ── Sector details ─────────────────────── */
.sector-details {
    margin-top: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    background: rgba(10, 10, 30, 0.3);
}

.sector-details summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    user-select: none;
}

.sector-details summary:hover {
    color: var(--text-primary);
}

.sector-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}

/* ── Help Overlay ───────────────────────── */
.help-overlay {
    display: none;
    margin-bottom: 12px;
    border: 1px solid rgba(124, 58, 237, 0.3);
    border-radius: var(--radius-sm);
    background: rgba(124, 58, 237, 0.05);
    padding: 16px;
    animation: fadeIn 0.2s ease;
}

.help-overlay.visible {
    display: block;
}

.help-overlay h3 {
    font-size: 0.95rem;
    margin-bottom: 10px;
    color: var(--accent-purple);
}

.help-overlay pre {
    background: rgba(10, 10, 30, 0.5);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.8rem;
    margin-bottom: 10px;
}

.help-overlay code {
    font-family: 'JetBrains Mono', monospace;
    color: var(--accent-cyan);
}

.help-overlay ul {
    list-style: none;
    padding: 0;
}

.help-overlay li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 3px 0;
    padding-left: 16px;
    position: relative;
}

.help-overlay li::before {
    content: '→';
    position: absolute;
    left: 0;
    color: var(--accent-cyan);
}

.help-overlay li code {
    font-size: 0.78rem;
}

/* ── Legend ──────────────────────────────── */
.legend {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.legend h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    font-size: 0.78rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.legend-name {
    color: var(--text-primary);
    font-weight: 500;
}

.legend-count {
    color: var(--text-muted);
    font-size: 0.72rem;
}

/* ── Preview Container ──────────────────── */
.preview-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
}

/* ── Map Card ───────────────────────────── */
.map-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: rgba(10, 10, 30, 0.3);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.map-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 30, 0.5);
}

.map-card-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.map-card img {
    width: 100%;
    height: auto;
    display: block;
    cursor: zoom-in;
    transition: transform var(--transition);
}

.map-card img:hover {
    transform: scale(1.005);
}

.btn-download-single {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid rgba(6, 182, 212, 0.3);
    background: rgba(6, 182, 212, 0.08);
    color: var(--accent-cyan);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-download-single:hover {
    background: rgba(6, 182, 212, 0.2);
    border-color: rgba(6, 182, 212, 0.5);
}

/* ── Sector Info Badge ──────────────────── */
.sector-info {
    margin-top: 10px;
}

.sector-badge {
    font-size: 0.8rem;
    color: var(--accent-cyan);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(6, 182, 212, 0.2);
    background: rgba(6, 182, 212, 0.05);
    line-height: 1.8;
}

.sector-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 2px 4px;
    border-radius: 12px;
    background: rgba(6, 182, 212, 0.15);
    font-size: 0.75rem;
    font-weight: 500;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 40px;
}

.empty-state svg {
    margin-bottom: 16px;
    color: var(--text-muted);
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.empty-state .hint {
    font-size: 0.8rem;
}

/* ── Spinner ────────────────────────────── */
.spinner {
    animation: spin 0.8s linear infinite;
}

.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Footer ─────────────────────────────── */
footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 30px 20px;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ── Responsive ─────────────────────────── */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    header {
        padding: 24px 16px 12px;
    }

    .logo h1 {
        font-size: 1.4rem;
    }

    main {
        padding: 12px;
    }

    .panel {
        padding: 16px;
    }

    textarea {
        min-height: 300px;
        font-size: 0.75rem;
    }
}

/* ── Scrollbar ──────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(100, 100, 200, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 100, 200, 0.35);
}