/* CSS Reset & Variables */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg: #0f172a;
    --bg-card: #1e293b;
    --bg-input: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --border: #475569;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* Navigation */
.nav {
    background: var(--bg-card);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
}

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

.nav-tabs {
    display: flex;
    gap: 0.5rem;
}

.nav-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.nav-tab:hover {
    border-color: var(--primary);
    color: var(--text);
}

.nav-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Views */
.view {
    display: none;
}

.view.active {
    display: block;
}

/* Forms */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.form-section h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--primary);
}

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

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

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

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

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

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
}

textarea {
    resize: vertical;
    font-family: 'Fira Code', 'Monaco', monospace;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    -webkit-appearance: none;
    background: var(--bg-input);
    border-radius: 4px;
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--bg-input);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-small {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* Songs List */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.filters {
    display: flex;
    gap: 0.5rem;
}

.filters select {
    width: auto;
    padding: 0.5rem 1rem;
}

.songs-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.song-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.song-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.song-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.song-card-title {
    font-weight: 600;
    font-size: 1rem;
}

.song-card-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
}

.status-draft { background: var(--bg-input); color: var(--text-muted); }
.status-generated { background: var(--warning); color: #000; }
.status-reviewed { background: var(--secondary); color: #000; }

.song-card-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.song-card-rating {
    color: var(--warning);
}

/* Analytics */
.analytics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.analytics-sections {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

.analytics-section h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--primary);
}

.analytics-table {
    overflow-x: auto;
}

.analytics-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.analytics-table th,
.analytics-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.analytics-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.analytics-table tr:hover {
    background: var(--bg-input);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    padding: 1rem;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 5vh;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 100%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    padding: 1.5rem;
}

/* Rating Stars */
.rating-input {
    display: flex;
    gap: 0.5rem;
}

.star-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--border);
    transition: color 0.2s;
}

.star-btn:hover,
.star-btn.active {
    color: var(--warning);
}

/* Tags */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tag {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.tag:hover,
.tag.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Toast */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    margin-top: 0.5rem;
    box-shadow: var(--shadow);
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid var(--danger); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

/* Detail View in Modal */
.detail-section {
    margin-bottom: 1.5rem;
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
}

.detail-section pre {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: var(--radius);
    overflow-x: auto;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
}

.slider-display {
    display: flex;
    gap: 1.5rem;
}

.slider-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.slider-bar {
    width: 100px;
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.slider-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
}

/* Feedback Form - Modern Man Testing */
.feedback-section {
    background: var(--bg);
    border-color: var(--primary);
    border-left: 3px solid var(--primary);
}

.feedback-section h4 {
    color: var(--primary);
    font-weight: 600;
}

/* 1-10 Scale Buttons */
.scale-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.scale-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.scale-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.scale-buttons {
    display: flex;
    gap: 0.25rem;
}

.scale-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text-muted);
    transition: all 0.15s;
}

.scale-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.scale-btn.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 600;
}

.scale-btn input[type="radio"] {
    display: none;
}

/* Read-only input styling */
input[readonly] {
    background: var(--bg);
    color: var(--text-muted);
    cursor: not-allowed;
}

/* Reference View - Metatags */
.reference-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.reference-filters select {
    width: auto;
    min-width: 150px;
}

.metatags-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

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

.category-title {
    color: var(--primary);
    font-size: 0.9rem;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.metatag-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.metatag-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 3px solid var(--border);
}

.metatag-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
}

.metatag-card.effectiveness-reliable {
    border-left-color: var(--secondary);
}

.metatag-card.effectiveness-inconsistent {
    border-left-color: var(--warning);
}

.metatag-card.effectiveness-unreliable {
    border-left-color: var(--danger);
}

.metatag-card.effectiveness-untested {
    border-left-color: var(--text-muted);
}

.metatag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.metatag-name {
    font-weight: 600;
    color: var(--text);
}

.metatag-effectiveness {
    font-size: 0.7rem;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    background: var(--bg-input);
    color: var(--text-muted);
}

.metatag-syntax {
    display: block;
    background: var(--bg-input);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.metatag-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.metatag-notes {
    font-size: 0.8rem;
    color: var(--warning);
    margin: 0.5rem 0 0 0;
    font-style: italic;
}

/* Modal wider for feedback form */
.modal-content {
    max-width: 750px;
}

/* Reference Sub-tabs */
.reference-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.ref-tab {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.ref-tab:hover {
    border-color: var(--primary);
    color: var(--text);
}

.ref-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.ref-section {
    display: none;
}

.ref-section.active {
    display: block;
}

/* Artist Styles */
.search-input {
    flex: 1;
    min-width: 200px;
}

.artists-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.artist-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    cursor: pointer;
    transition: all 0.2s;
}

.artist-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.artist-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.artist-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary);
}

.artist-vocal-type {
    font-size: 0.75rem;
    text-transform: uppercase;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    background: var(--bg-input);
    color: var(--text-muted);
}

.artist-prompt {
    background: var(--bg);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text);
    margin-bottom: 0.75rem;
    border-left: 3px solid var(--secondary);
}

.artist-genres {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.genre-tag {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
}

.artist-characteristics {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}

.char-tag {
    background: var(--bg-input);
    color: var(--text-muted);
    padding: 0.2rem 0.5rem;
    border-radius: 3px;
    font-size: 0.75rem;
}

.artist-notes {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
    margin: 0;
}

/* Lyrics Builder */
.lyrics-builder-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mode-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.mode-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.mode-btn:hover {
    border-color: var(--primary);
    color: var(--text);
}

.mode-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.builder-mode {
    display: none;
}

.builder-mode.active {
    display: block;
}

.simple-mode {
    display: none;
}

.simple-mode.active {
    display: block;
}

.builder-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

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

.builder-panel h4 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.builder-panel textarea {
    min-height: 200px;
}

.builder-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

/* Section Cards */
.sections-container {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
}

.section-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.section-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.section-card-header select {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
}

.section-delete-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 0.2rem 0.4rem;
    transition: color 0.2s;
}

.section-delete-btn:hover {
    color: var(--danger);
}

.section-lyrics {
    background: var(--bg);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-muted);
    max-height: 60px;
    overflow-y: auto;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
    font-family: 'Fira Code', monospace;
}

/* Modifiers */
.modifiers-section {
    margin-bottom: 0.5rem;
}

.modifiers-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.35rem;
}

.modifiers-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.modifier-tag {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    color: var(--text-muted);
}

.modifier-tag:hover {
    border-color: var(--primary);
    color: var(--text);
}

.modifier-tag.selected {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.modifier-category {
    margin-bottom: 0.5rem;
}

.modifier-category-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

/* Custom modifier input */
.custom-modifier-input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Artist style dropdown */
.artist-select {
    width: 100%;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Section Preview */
.section-preview {
    background: var(--bg-input);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
    color: var(--secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

/* Generated Output */
.generated-output {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    margin-top: 1rem;
}

.generated-output h4 {
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.generated-output pre {
    background: var(--bg-input);
    padding: 0.75rem;
    border-radius: var(--radius);
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 300px;
    overflow-y: auto;
}

.copy-btn {
    background: var(--secondary);
    border: none;
    color: white;
    padding: 0.3rem 0.7rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: opacity 0.2s;
}

.copy-btn:hover {
    opacity: 0.85;
}

/* Variant Badge */
.variant-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

.variant-badge-icon {
    font-size: 0.8rem;
}

/* Duplicate button in modal */
.duplicate-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.duplicate-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Add section button */
.add-section-btn {
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.85rem;
    width: 100%;
}

.add-section-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Responsive */
@media (max-width: 600px) {
    .nav {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-tabs {
        width: 100%;
        justify-content: center;
    }

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

    .list-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .analytics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .builder-layout {
        grid-template-columns: 1fr;
    }
}
