/* ═══════════════════════════════════════════════════════════════════════
   Phoenix Growth OS — Design System
   Aesthetic: Dark command-center with ember/fire accents.
   Typography: Outfit (display) + DM Sans (body)
   ═══════════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

/* ── CSS Variables ───────────────────────────────────────────────────── */

:root {
    --phoenix-ember: #e65100;
    --phoenix-flame: #ff6d00;
    --phoenix-glow: #ff9e40;
    --phoenix-deep: #bf360c;
    --phoenix-ash: #3e2723;

    --bg-primary: #fcfcfb;
    --bg-card: #ffffff;
    --bg-card-hover: #faf7f3;
    --bg-elevated: #f6f3ef;
    --bg-input: #fffdf9;
    --bg-surface: rgba(17, 24, 39, 0.04);

    --text-primary: #16181d;
    --text-secondary: #3e4550;
    --text-muted: #6a7280;
    --text-accent: var(--phoenix-flame);

    --border-subtle: rgba(17, 24, 39, 0.12);
    --border-medium: rgba(17, 24, 39, 0.2);
    --border-accent: var(--phoenix-ember);

    --success: #2e7d32;
    --success-bg: rgba(46, 125, 50, 0.12);
    --warning: #f9a825;
    --warning-bg: rgba(249, 168, 37, 0.12);
    --error: #d32f2f;
    --error-bg: rgba(211, 47, 47, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.06), 0 0 0 1px var(--border-subtle);
    --shadow-hover: 0 8px 30px rgba(230, 81, 0, 0.08), 0 0 0 1px rgba(230, 81, 0, 0.15);
    --shadow-glow: 0 0 20px rgba(230, 81, 0, 0.15);

    --font-display: 'Outfit', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ────────────────────────────────────────────────────── */

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

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(230, 81, 0, 0.06), transparent),
        radial-gradient(circle at 80% 80%, rgba(191, 54, 12, 0.03), transparent);
}

a {
    color: var(--phoenix-flame);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--phoenix-glow);
}

img { max-width: 100%; }

/* ── Typography ──────────────────────────────────────────────────────── */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

h1 { font-size: 2.2rem; font-weight: 800; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.05rem; font-weight: 600; }

p { margin-bottom: 0.75rem; color: var(--text-secondary); }

small { font-size: 0.8rem; color: var(--text-muted); }

/* ── Layout ──────────────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

main.container {
    flex: 1;
    padding-top: 2rem;
    padding-bottom: 4rem;
    position: relative;
    z-index: 1;
}

/* ── Navigation ──────────────────────────────────────────────────────── */

nav {
    background: rgba(252, 252, 251, 0.92);
    backdrop-filter: blur(20px) saturate(1.2);
    -webkit-backdrop-filter: blur(20px) saturate(1.2);
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 0 1.5rem;
}

nav .nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

nav .nav-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}

nav .nav-brand .brand-icon {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--phoenix-ember), var(--phoenix-flame));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 0 12px rgba(230, 81, 0, 0.3);
}

nav .nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

nav .nav-links a {
    display: block;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    text-decoration: none;
}

nav .nav-links a:hover,
nav .nav-links a.active {
    color: var(--text-primary);
    background: var(--bg-surface);
}

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

.page-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
}

.page-header h1 {
    margin-bottom: 0.25rem;
}

.page-header .subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.page-header .header-actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ── Cards / Articles ────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: all var(--transition-smooth);
}

.card:hover {
    border-color: rgba(230, 81, 0, 0.2);
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.card h3 {
    margin-bottom: 0.5rem;
}

.card p {
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

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

.card-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, rgba(230, 81, 0, 0.15), rgba(255, 109, 0, 0.05));
    border: 1px solid rgba(230, 81, 0, 0.2);
    color: var(--phoenix-flame);
}

/* ── Home Hero ───────────────────────────────────────────────────────── */

.hero {
    text-align: center;
    padding: 4rem 0 3rem;
    position: relative;
}

.hero::before {
    content: '';
    position: absolute;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(230, 81, 0, 0.1) 0%, transparent 70%);
    pointer-events: none;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -0.04em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--phoenix-glow) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-weight: 400;
    max-width: 500px;
    margin: 0 auto 2.5rem;
}

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

.btn, button[type="submit"], a[role="button"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.25rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn-primary, button[type="submit"], a[role="button"]:not(.btn-outline):not(.btn-ghost):not(.btn-danger) {
    background: linear-gradient(135deg, var(--phoenix-ember), var(--phoenix-flame));
    color: #fff;
    box-shadow: 0 2px 8px rgba(230, 81, 0, 0.25);
}

.btn-primary:hover, button[type="submit"]:hover, a[role="button"]:not(.btn-outline):not(.btn-ghost):not(.btn-danger):hover {
    box-shadow: 0 4px 16px rgba(230, 81, 0, 0.35);
    transform: translateY(-1px);
    color: #fff;
}

.btn-outline, a[role="button"].btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-medium);
}

.btn-outline:hover, a[role="button"].btn-outline:hover {
    border-color: var(--phoenix-ember);
    color: var(--phoenix-flame);
    background: rgba(230, 81, 0, 0.05);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
}

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

.btn-danger {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid rgba(211, 47, 47, 0.2);
}

.btn-danger:hover {
    background: rgba(211, 47, 47, 0.2);
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ── Tables ──────────────────────────────────────────────────────────── */

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

thead {
    border-bottom: 1px solid var(--border-medium);
}

th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    vertical-align: middle;
}

tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-surface);
}

td a {
    font-weight: 500;
}

.table-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-wrapper table {
    margin: 0;
}

/* ── Forms ────────────────────────────────────────────────────────────── */

label {
    display: block;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"],
select,
textarea {
    display: block;
    width: 100%;
    padding: 0.65rem 0.85rem;
    margin-top: 0.35rem;
    background: var(--bg-input);
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--phoenix-ember);
    box-shadow: 0 0 0 3px rgba(230, 81, 0, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    min-height: 100px;
    resize: vertical;
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238e8e9a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
}

select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--phoenix-ember);
    margin-right: 0.5rem;
    vertical-align: middle;
}

fieldset {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

fieldset legend {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    padding: 0 0.5rem;
}

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

@media (max-width: 640px) {
    .form-grid { grid-template-columns: 1fr; }
}

/* ── Status Badges ───────────────────────────────────────────────────── */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-running {
    background: var(--warning-bg);
    color: var(--warning);
}
.status-running::before { background: var(--warning); }

.status-completed {
    background: var(--success-bg);
    color: var(--success);
}
.status-completed::before { background: var(--success); }

.status-failed {
    background: var(--error-bg);
    color: var(--error);
}
.status-failed::before { background: var(--error); }

.status-pending {
    background: rgba(17, 24, 39, 0.06);
    color: var(--text-muted);
}
.status-pending::before { background: var(--text-muted); }

/* ── Progress Log (Terminal) ─────────────────────────────────────────── */

.progress-log {
    background: #fffaf4;
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-mono);
    font-size: 0.8rem;
    max-height: 420px;
    overflow-y: auto;
    line-height: 1.8;
}

.progress-log .step {
    margin: 0;
    padding: 0.15rem 0;
    opacity: 0.7;
}

.progress-log .step:last-child {
    opacity: 1;
}

.progress-log .step.active {
    color: var(--phoenix-flame);
    font-weight: 600;
    opacity: 1;
}

.progress-log::-webkit-scrollbar {
    width: 4px;
}

.progress-log::-webkit-scrollbar-track {
    background: transparent;
}

.progress-log::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 2px;
}

/* ── Definition Lists ────────────────────────────────────────────────── */

dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.5rem 1.25rem;
    font-size: 0.9rem;
}

dt {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

dd {
    color: var(--text-primary);
}

/* ── Details / Accordion ─────────────────────────────────────────────── */

details {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

details summary {
    padding: 0.85rem 1rem;
    cursor: pointer;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

details summary:hover {
    color: var(--text-primary);
}

details[open] summary {
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

details > *:not(summary) {
    padding: 1rem;
}

/* ── Sections / Articles ─────────────────────────────────────────────── */

article, .section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1rem;
}

article header {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

article pre {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ── Report rendered content ─────────────────────────────────────────── */

.report-content h1 { font-size: 1.6rem; margin: 2rem 0 0.75rem; }
.report-content h2 { font-size: 1.3rem; margin: 1.5rem 0 0.5rem; color: var(--phoenix-flame); }
.report-content h3 { font-size: 1.1rem; margin: 1.25rem 0 0.5rem; }
.report-content p { color: var(--text-secondary); }
.report-content ul, .report-content ol { padding-left: 1.5rem; margin-bottom: 1rem; color: var(--text-secondary); }
.report-content li { margin-bottom: 0.35rem; }
.report-content strong { color: var(--text-primary); }
.report-content table { margin: 1rem 0; }

/* ── Footer ──────────────────────────────────────────────────────────── */

footer {
    border-top: 1px solid var(--border-subtle);
    padding: 1.5rem 0;
    text-align: center;
    position: relative;
    z-index: 1;
}

footer small {
    color: var(--text-muted);
    font-size: 0.75rem;
}

/* ── Utility ─────────────────────────────────────────────────────────── */

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 640px) { .grid { grid-template-columns: 1fr; } }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 768px) { .grid-3 { grid-template-columns: 1fr; } }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-sm { gap: 0.5rem; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* ── Divider ─────────────────────────────────────────────────────────── */

hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 1.5rem 0;
}

/* ── Breadcrumb / Back link ──────────────────────────────────────────── */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
    transition: color var(--transition-fast);
}

.back-link:hover {
    color: var(--phoenix-flame);
}

/* ── HTMX indicators ────────────────────────────────────────────────── */

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    display: inline-block;
}

/* ── Tech Grid Background (Phoenix Hub Style) ─────────────────────── */

.tech-grid {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.09) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.09) 1px, transparent 1px);
    background-size: 80px 80px;
}

.tech-grid-fine {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
    background-image:
        linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* ── Data Flow Lines ───────────────────────────────────────────────── */

.data-flow-line {
    position: relative;
    height: 1px;
    background: var(--border-subtle);
    overflow: hidden;
}

.data-flow-line::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100px;
    background: linear-gradient(90deg, transparent, var(--phoenix-flame), transparent);
    animation: dataFlow 5s linear infinite;
}

@keyframes dataFlow {
    0%   { transform: translateX(-100px); }
    100% { transform: translateX(calc(100vw + 100px)); }
}

/* ── System Status Labels ──────────────────────────────────────────── */

.system-status {
    font-family: var(--font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    opacity: 0.6;
    user-select: none;
}

/* ── Gradient Accent Lines ─────────────────────────────────────────── */

.accent-line-left,
.accent-line-right {
    position: fixed;
    top: 0;
    bottom: 0;
    width: 1px;
    background: linear-gradient(to bottom, transparent, var(--phoenix-ember), transparent);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.accent-line-left  { left: 10%; }
.accent-line-right { right: 10%; }

/* ── Animations ──────────────────────────────────────────────────────── */

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

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 8px rgba(230, 81, 0, 0.2); }
    50% { box-shadow: 0 0 20px rgba(230, 81, 0, 0.35); }
}

.card, article, .section-card, .table-wrapper {
    animation: fadeInUp 0.4s ease both;
}

.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }
.card:nth-child(5) { animation-delay: 0.2s; }

/* Running badge pulse */
.status-running::before {
    animation: pulse-glow 2s ease infinite;
}
