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

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6c757d;
    --primary: #4a6fa5;
    --primary-hover: #3d5d8a;
    --accent: #7eb8da;
    --border: #e2e8f0;
    --success: #38a169;
    --warning: #d69e2e;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

html { font-size: 16px; }

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

/* === Typography === */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.5rem; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
h3 { font-size: 1.1rem; font-weight: 600; }

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

.logo {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}

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

.layout {
    display: flex;
    min-height: calc(100vh - 52px);
}

.sidebar {
    width: 260px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 1rem 0;
    flex-shrink: 0;
}

.content {
    flex: 1;
    padding: 2rem;
    max-width: 900px;
}

/* === Sidebar Nav === */
.sidebar-header {
    padding: 0.5rem 1.25rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    font-weight: 600;
}

.module-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.25rem;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.15s;
}

.module-nav-item:hover { background: var(--bg); }
.module-nav-item.active { background: var(--bg); font-weight: 600; border-left: 3px solid var(--primary); }
.module-nav-item.completed { color: var(--success); }

.module-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.module-nav-item.completed .module-number { background: var(--success); color: white; }
.module-nav-item.active .module-number { background: var(--primary); color: white; }

.status-badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    margin-left: auto;
}

.status-badge.done { background: #c6f6d5; color: #276749; }
.status-badge.review { background: #fefcbf; color: #975a16; }
.status-badge.generating { background: #bee3f8; color: #2a4365; }

/* === Home Page === */
.home-container { max-width: 600px; margin: 0 auto; padding: 2rem 1rem; }

.hero { text-align: center; margin-bottom: 2rem; }
.hero h1 { font-size: 2rem; }
.subtitle { color: var(--text-muted); font-size: 1.1rem; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.create-form { display: flex; flex-direction: column; gap: 1rem; }

.workshop-list { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1rem; }

.workshop-item {
    display: block;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.workshop-item:hover { border-color: var(--primary); }
.workshop-name { font-weight: 600; }
.workshop-meta { font-size: 0.85rem; color: var(--text-muted); }

/* === Workshop Overview === */
.workshop-overview { max-width: 700px; }
.business-info { color: var(--text-muted); margin-bottom: 1.5rem; }

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

.module-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.module-card:hover { border-color: var(--primary); box-shadow: var(--shadow-lg); }
.module-card.completed { border-left: 3px solid var(--success); }
.module-card.in-review { border-left: 3px solid var(--warning); }

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

.module-number-large {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-muted);
    opacity: 0.5;
}

/* === Forms === */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.35rem;
    font-size: 0.95rem;
}

input[type="text"], textarea {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    line-height: 1.5;
    transition: border-color 0.15s;
    background: var(--surface);
}

input[type="text"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.1);
}

.radio-group { display: flex; flex-direction: column; gap: 0.5rem; }

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.radio-option:hover { border-color: var(--primary); }
.radio-option.selected { border-color: var(--primary); background: rgba(74, 111, 165, 0.05); }
.radio-option input[type="radio"] { margin-top: 0.2rem; }
.radio-label { font-size: 0.95rem; }

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.25rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }

/* === Module Steps === */
.module-container { max-width: 700px; }
.module-header { margin-bottom: 1.5rem; }
.module-description { color: var(--text-muted); }

.step-title { margin-bottom: 0.25rem; }
.step-indicator { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.25rem; }

.step-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

.dependency-warning {
    background: #fefcbf;
    border: 1px solid #f6e05e;
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

.dependency-warning ul { margin: 0.5rem 0 0.5rem 1.25rem; }

/* === Output Display === */
.generating-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    font-weight: 500;
    color: var(--primary);
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.output-preview {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-height: 600px;
    overflow-y: auto;
    line-height: 1.7;
}

.output-preview h1, .output-preview h2, .output-preview h3 { margin-top: 1.25rem; margin-bottom: 0.5rem; }
.output-preview h1:first-child, .output-preview h2:first-child { margin-top: 0; }
.output-preview p { margin-bottom: 0.75rem; }
.output-preview ul, .output-preview ol { margin: 0.5rem 0 0.75rem 1.5rem; }
.output-preview li { margin-bottom: 0.25rem; }
.output-preview strong { font-weight: 600; }
.output-preview hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
.output-preview blockquote { border-left: 3px solid var(--primary); padding-left: 1rem; color: var(--text-muted); margin: 0.75rem 0; }

/* === Review Phase === */
.review-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-muted);
    transition: color 0.15s, border-color 0.15s;
}

.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.edit-textarea {
    width: 100%;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
}

.review-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.regenerate-section {
    display: flex;
    gap: 0.5rem;
}

.regen-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.save-section { display: flex; justify-content: flex-end; }

/* === Saved Phase === */
.saved-message {
    text-align: center;
    padding: 1.5rem;
    margin-bottom: 1rem;
}

.checkmark {
    font-size: 2.5rem;
    color: var(--success);
    margin-bottom: 0.5rem;
}

.saved-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 1.5rem;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    .layout { flex-direction: column; }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border);
        padding: 0.5rem 0;
    }

    .module-nav {
        display: flex;
        overflow-x: auto;
        padding: 0 0.5rem;
        gap: 0;
    }

    .sidebar-header { display: none; }

    .module-nav-item {
        flex-shrink: 0;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        gap: 0.4rem;
    }

    .module-nav-item.active { border-left: none; border-bottom: 3px solid var(--primary); }
    .module-name { white-space: nowrap; }

    .content { padding: 1rem; }
    .home-container { padding: 1rem; }

    h1 { font-size: 1.5rem; }

    .module-grid { grid-template-columns: 1fr; }

    .regenerate-section { flex-direction: column; }

    .step-actions { flex-direction: column; }
    .step-actions .btn { width: 100%; }

    .saved-actions { flex-direction: column; }
    .saved-actions .btn, .saved-actions a { width: 100%; text-align: center; }
}

/* === Utility === */
[x-cloak] { display: none !important; }
/* === Copy Button === */
.btn-copy {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.btn-copy:hover { background: var(--border); color: var(--text); }
.btn-copy.copied { background: #c6f6d5; border-color: #38a169; color: #276749; }

/* === Review Toolbar === */
.review-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.review-toolbar .review-tabs {
    display: flex;
    gap: 0;
    border-bottom: none;
    margin-bottom: 0;
}

/* === Saved Phase Copy === */
.output-saved-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.75rem;
}

/* === Export Banner === */
.export-banner {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: rgba(74, 111, 165, 0.05);
    border: 1px solid rgba(74, 111, 165, 0.15);
    border-radius: var(--radius);
    display: flex;
    justify-content: center;
}