/* ═══════════════════════════════════════
   VARIABLES & RESET
   ═══════════════════════════════════════ */
:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-hover: #1a1a28;
    --border: #2a2a3a;
    --text: #e4e4ef;
    --text-muted: #8888a0;
    --primary: #6c5ce7;
    --primary-hover: #7d6ff0;
    --primary-glow: rgba(108, 92, 231, 0.3);
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --success: #2ecc71;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

/* ═══════════════════════════════════════
   HEADER
   ═══════════════════════════════════════ */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    color: var(--primary);
    display: flex;
    align-items: center;
}

.header h1 {
    font-size: 1.3rem;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.badge {
    font-size: 0.65rem;
    background: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
    vertical-align: middle;
    margin-left: 4px;
}

.account-info {
    font-size: 0.8rem;
    color: var(--text-muted);
    background: var(--bg);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

/* ═══════════════════════════════════════
   MAIN LAYOUT
   ═══════════════════════════════════════ */
.main {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 0;
    max-width: 1400px;
    margin: 0 auto;
    min-height: calc(100vh - 65px);
}

.panel {
    padding: 32px;
}

.panel h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

/* ═══════════════════════════════════════
   GENERATE PANEL
   ═══════════════════════════════════════ */
.generate-panel {
    border-right: 1px solid var(--border);
    max-width: 800px;
}

/* Form elements */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border var(--transition);
    outline: none;
}

select:focus,
textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
    resize: vertical;
    min-height: 140px;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

.char-count {
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
}

.char-count.warning {
    color: #f39c12;
}

.char-count.danger {
    color: var(--danger);
}

/* Advanced settings */
.advanced-settings {
    margin-bottom: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.advanced-settings summary {
    padding: 12px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    background: var(--bg);
    font-weight: 500;
    user-select: none;
}

.advanced-settings summary:hover {
    color: var(--text);
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 16px;
    background: var(--bg);
}

/* Sliders */
input[type="range"] {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 6px var(--primary-glow);
}

.slider-value {
    font-size: 0.75rem;
    background: var(--bg-card);
    padding: 1px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    color: var(--primary);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    opacity: 0.7;
}

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-ghost:hover {
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
}

.btn-large {
    width: 100%;
    justify-content: center;
    padding: 14px 24px;
    font-size: 1rem;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.8rem;
}

/* ═══════════════════════════════════════
   LOADING & STATES
   ═══════════════════════════════════════ */
.loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-top: 16px;
    font-size: 0.85rem;
}

.alert-error {
    background: rgba(231, 76, 60, 0.1);
    border: 1px solid rgba(231, 76, 60, 0.3);
    color: #e74c3c;
}

/* ═══════════════════════════════════════
   PLAYER
   ═══════════════════════════════════════ */
.player-section {
    margin-top: 24px;
    padding: 20px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.player-section h3 {
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 12px;
    color: var(--text-muted);
}

audio {
    width: 100%;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
}

audio::-webkit-media-controls-panel {
    background: var(--bg-card);
}

.player-actions {
    display: flex;
    gap: 8px;
}

/* ═══════════════════════════════════════
   HISTORY PANEL
   ═══════════════════════════════════════ */
.history-panel {
    background: var(--bg-card);
    overflow-y: auto;
    max-height: calc(100vh - 65px);
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.history-header h2 {
    margin-bottom: 0;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-empty {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
    padding: 40px 0;
}

.history-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    transition: all var(--transition);
    cursor: pointer;
}

.history-item:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.history-item-text {
    font-size: 0.82rem;
    color: var(--text);
    margin-bottom: 8px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.history-item-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.history-item-actions {
    display: flex;
    gap: 4px;
}

.history-item-actions button {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all var(--transition);
}

.history-item-actions button:hover {
    color: var(--text);
    background: var(--bg-hover);
}

.history-item-actions button.delete:hover {
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
}

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 900px) {
    .main {
        grid-template-columns: 1fr;
    }

    .generate-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-width: 100%;
    }

    .history-panel {
        max-height: none;
    }

    .header {
        padding: 12px 16px;
    }

    .panel {
        padding: 20px 16px;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }
}
