/* Captain Claw — Playbook Wizard */

:root {
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --border: #30363d;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #6e7681;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --green: #3fb950;
    --red: #f85149;
    --yellow: #d29922;
    --orange: #f78166;
    --purple: #bc8cff;
    --radius: 8px;
    --radius-sm: 6px;
    --header-height: 48px;
    --input-height: 72px;
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
    --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
}

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

html, body {
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* ─── Header ──────────────────────────────────────────── */

.wiz-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    flex-shrink: 0;
}

.wiz-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wiz-header-left h1 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.wiz-logo-link {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.wiz-header-center {
    display: flex;
    align-items: center;
}

.wiz-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.wiz-nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: color 0.15s, background 0.15s;
}

.wiz-nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

/* ─── Phase indicator ─────────────────────────────────── */

.wiz-phases {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wiz-phase {
    font-size: 12px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 12px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    transition: all 0.2s;
}

.wiz-phase.active {
    color: var(--bg-primary);
    background: var(--accent);
    font-weight: 600;
}

.wiz-phase.done {
    color: var(--bg-primary);
    background: var(--green);
}

.wiz-phase-arrow {
    color: var(--text-muted);
    font-size: 12px;
}

/* ─── Main conversation area ──────────────────────────── */

.wiz-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: calc(100vh - var(--header-height) - var(--input-height));
}

.wiz-conversation {
    width: 100%;
    max-width: 720px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ─── Message bubbles ─────────────────────────────────── */

.wiz-msg {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    animation: wizFadeIn 0.25s ease-out;
}

@keyframes wizFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.wiz-msg.assistant {
    align-self: flex-start;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

.wiz-msg.user {
    align-self: flex-end;
    background: #1a3a5c;
    border: 1px solid #264b73;
    color: var(--text-primary);
}

.wiz-msg.assistant p,
.wiz-msg.user p {
    margin-bottom: 8px;
}

.wiz-msg.assistant p:last-child,
.wiz-msg.user p:last-child {
    margin-bottom: 0;
}

/* Typing indicator */
.wiz-typing {
    align-self: flex-start;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    gap: 4px;
    animation: wizFadeIn 0.2s ease-out;
}

.wiz-typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: wizBounce 1.4s infinite ease-in-out both;
}

.wiz-typing-dot:nth-child(1) { animation-delay: 0s; }
.wiz-typing-dot:nth-child(2) { animation-delay: 0.16s; }
.wiz-typing-dot:nth-child(3) { animation-delay: 0.32s; }

@keyframes wizBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ─── Preview card ────────────────────────────────────── */

.wiz-preview-card {
    width: 100%;
    max-width: 720px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 16px;
    animation: wizFadeIn 0.3s ease-out;
}

.wiz-preview-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.wiz-preview-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.wiz-preview-sub {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.wiz-preview-fields {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.wiz-preview-row {
    display: flex;
    gap: 12px;
}

.wiz-preview-row > .wiz-preview-group {
    flex: 1;
}

.wiz-preview-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wiz-preview-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wiz-preview-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ─── Form elements ───────────────────────────────────── */

.wiz-input, .wiz-select, .wiz-textarea {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 13px;
    padding: 8px 10px;
    transition: border-color 0.15s;
}

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

.wiz-textarea.wiz-code {
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
    resize: vertical;
}

.wiz-select {
    cursor: pointer;
}

/* ─── Buttons ─────────────────────────────────────────── */

.wiz-btn {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    font-family: var(--font);
}

.wiz-btn.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.wiz-btn.primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.wiz-btn.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wiz-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-color: var(--border);
}

.wiz-btn.secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ─── Input area (sticky bottom) ──────────────────────── */

.wiz-input-area {
    height: var(--input-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    flex-shrink: 0;
}

.wiz-input-area.hidden {
    display: none;
}

.wiz-input-wrap {
    width: 100%;
    max-width: 720px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    position: relative;
}

.wiz-user-input {
    flex: 1;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 14px;
    padding: 10px 14px;
    resize: none;
    line-height: 1.5;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.15s;
}

.wiz-user-input:focus {
    outline: none;
    border-color: var(--accent);
}

.wiz-user-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wiz-send-btn {
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
}

.wiz-send-btn:hover {
    background: var(--accent-hover);
}

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

/* ─── Toast ───────────────────────────────────────────── */

.wiz-toast {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
    z-index: 1000;
}

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

.wiz-toast.success {
    border-color: var(--green);
}

.wiz-toast.error {
    border-color: var(--red);
}

/* ─── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
    .wiz-header-center {
        display: none;
    }

    .wiz-msg {
        max-width: 95%;
    }

    .wiz-preview-row {
        flex-direction: column;
    }

    .wiz-preview-card {
        padding: 16px;
    }
}
