/* =========================================================================
   Zzyzx Design System — Theme-Aware Premium SaaS UI
   ========================================================================= */

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

/* ---- Shared (non-color) tokens ---- */
:root {
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;

    /* Fixed accent colors (same in both themes) */
    --color-primary: #7c5cfc;
    --color-primary-hover: #6a4aee;
    --color-primary-glow: rgba(124, 92, 252, 0.25);
    --color-accent: #22d3ee;
    --color-success: #34d399;
    --color-warning: #fbbf24;
    --color-error: #f87171;
}

/* =========================================================================
   LIGHT THEME (default)
   ========================================================================= */
:root,
[data-theme="light"] {
    --color-bg: #f8f9fc;
    --color-bg-raised: #ffffff;
    --color-bg-card: #ffffff;
    --color-bg-hover: #f0f1f5;
    --color-bg-input: #f3f4f8;
    --color-border: #e0e2ea;
    --color-border-subtle: #ecedf2;

    --color-text: #1a1a2e;
    --color-text-secondary: #5a5b72;
    --color-text-muted: #9495a8;

    --color-navbar-bg: rgba(248, 249, 252, 0.85);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
    --shadow-glow: 0 0 40px rgba(124, 92, 252, 0.1);

    --login-gradient-1: rgba(124, 92, 252, 0.06);
    --login-gradient-2: rgba(34, 211, 238, 0.04);

    color-scheme: light;
}

/* =========================================================================
   DARK THEME
   ========================================================================= */
[data-theme="dark"] {
    --color-bg: #0a0a0f;
    --color-bg-raised: #12121a;
    --color-bg-card: #16161f;
    --color-bg-hover: #1e1e2a;
    --color-bg-input: #1a1a25;
    --color-border: #2a2a3a;
    --color-border-subtle: #1e1e2e;

    --color-text: #e8e8f0;
    --color-text-secondary: #8888a0;
    --color-text-muted: #55556a;

    --color-navbar-bg: rgba(10, 10, 15, 0.85);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(124, 92, 252, 0.25);

    --login-gradient-1: rgba(124, 92, 252, 0.12);
    --login-gradient-2: rgba(34, 211, 238, 0.06);

    color-scheme: dark;
}

/* System preference auto-detection (only when no data-theme is set) */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --color-bg: #0a0a0f;
        --color-bg-raised: #12121a;
        --color-bg-card: #16161f;
        --color-bg-hover: #1e1e2a;
        --color-bg-input: #1a1a25;
        --color-border: #2a2a3a;
        --color-border-subtle: #1e1e2e;

        --color-text: #e8e8f0;
        --color-text-secondary: #8888a0;
        --color-text-muted: #55556a;

        --color-navbar-bg: rgba(10, 10, 15, 0.85);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
        --shadow-glow: 0 0 40px rgba(124, 92, 252, 0.25);

        --login-gradient-1: rgba(124, 92, 252, 0.12);
        --login-gradient-2: rgba(34, 211, 238, 0.06);

        color-scheme: dark;
    }
}

/* ---- Smooth theme transition ---- */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition:
        background-color 0.3s ease,
        color 0.3s ease,
        border-color 0.3s ease,
        box-shadow 0.3s ease,
        fill 0.3s ease !important;
}

/* ---- Base ---- */
html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ---- Utility ---- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* =========================================================================
   Navbar
   ========================================================================= */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--color-navbar-bg);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-bottom: 1px solid var(--color-border-subtle);
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-weight: 700;
    font-size: 1.2rem;
    transition: opacity var(--duration-fast) var(--ease-out);
}

.nav-brand:hover {
    opacity: 0.8;
}

.brand-icon {
    font-size: 1.4rem;
    color: var(--color-primary);
    filter: drop-shadow(0 0 6px var(--color-primary-glow));
}

.brand-text {
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.nav-user-name {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
}

/* ---- Theme Toggle ---- */
.theme-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    padding: 0;
    transition: all var(--duration-fast) var(--ease-out);
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    border-color: var(--color-primary);
}

.theme-toggle-thumb {
    position: absolute;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    transition: transform var(--duration-normal) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
}

/* When dark mode is active, slide thumb to right */
[data-theme="dark"] .theme-toggle-thumb {
    transform: translateX(20px);
}

/* Auto-detect system dark for thumb position when no explicit theme set */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle-thumb {
        transform: translateX(20px);
    }
}

.theme-toggle-icon {
    pointer-events: none;
    user-select: none;
}

/* =========================================================================
   Buttons
   ========================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.875rem;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #6a4aee);
    color: #fff;
    box-shadow: 0 2px 8px var(--color-primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--color-primary-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

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

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

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-xs {
    padding: 4px 10px;
    font-size: 0.75rem;
}

/* =========================================================================
   Login Page
   ========================================================================= */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(ellipse 60% 50% at 50% 0%, var(--login-gradient-1), transparent),
        radial-gradient(ellipse 40% 40% at 80% 80%, var(--login-gradient-2), transparent),
        var(--color-bg);
}

.login-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-xl);
    background: var(--color-bg-raised);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    max-width: 420px;
    width: 100%;
    animation: fadeInUp 0.6s var(--ease-out);
}

/* Theme toggle on login page */
.login-theme-toggle {
    position: fixed;
    top: var(--space-lg);
    right: var(--space-lg);
    z-index: 50;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-brand {
    margin-bottom: var(--space-xl);
}

.login-logo-icon {
    font-size: 3rem;
    color: var(--color-primary);
    filter: drop-shadow(0 0 12px var(--color-primary-glow));
}

.login-logo-text {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-top: var(--space-sm);
}

.login-subtitle {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    margin-top: var(--space-xs);
}

.login-form-area {
    width: 100%;
    margin-top: var(--space-lg);
}

.login-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.login-hint {
    color: var(--color-text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-lg);
}

.login-google-btn {
    display: flex;
    justify-content: center;
}

.login-footer {
    margin-top: var(--space-2xl);
}

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

/* Dev Login enhancements */
.login-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: var(--space-lg) 0;
    width: 100%;
    color: var(--color-border);
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--color-border);
}

.login-divider-text {
    padding: 0 var(--space-md);
    color: var(--color-text-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.login-dev-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
    max-width: 300px;
    margin: 0 auto;
}

.login-input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.9rem;
    outline: none;
    transition: all var(--duration-fast);
}

.login-input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.login-submit-btn {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: transparent;
    color: var(--color-text-secondary);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--duration-fast);
}

.login-submit-btn:hover {
    background: var(--color-bg-hover);
    color: var(--color-primary);
    border-color: var(--color-primary);
    border-style: solid;
}

/* =========================================================================
   Main Content
   ========================================================================= */
.main-content {
    padding-top: var(--space-xl);
    padding-bottom: var(--space-2xl);
    min-height: calc(100vh - 60px);
}

.main-content-full {
    padding: 0;
    height: calc(100vh - 60px);
    overflow: hidden;
}

/* =========================================================================
   Dashboard
   ========================================================================= */
.dashboard-section {
    animation: fadeInUp 0.4s var(--ease-out);
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
}

/* ---- Model Cards Grid ---- */
.models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-lg);
}

.model-card {
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-out);
    cursor: pointer;
}

.model-card:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-md);
    transform: translateY(-2px);
}

.model-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.model-card-icon {
    font-size: 1.5rem;
    color: var(--color-primary);
}

.model-card-badge {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    background: var(--color-bg-hover);
    color: var(--color-text-secondary);
    border: 1px solid var(--color-border);
}

.model-card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: var(--space-xs);
}

.model-card-desc {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    flex: 1;
}

.model-card-footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-subtle);
}

.model-card-date {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* ---- Empty State ---- */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-2xl) var(--space-lg);
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    opacity: 0.6;
}

.empty-heading {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--space-sm);
}

.empty-description {
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: var(--space-lg);
    max-width: 320px;
}

/* =========================================================================
   Model Editor — Split Pane
   ========================================================================= */
.editor-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    height: calc(100vh - 60px);
}

.editor-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-chat {
    background: var(--color-bg-raised);
    border-right: 1px solid var(--color-border);
}

.editor-graph {
    background: var(--color-bg);
}

/* ---- Panel Header ---- */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--color-border-subtle);
    min-height: 56px;
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
}

.back-link {
    color: var(--color-text-secondary);
    font-size: 0.8rem;
    margin-right: var(--space-md);
    transition: color var(--duration-fast);
}

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

/* ---- Chat ---- */
.chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md) var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.chat-msg {
    max-width: 85%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.5;
    animation: fadeInUp 0.3s var(--ease-out);
}

.chat-msg-ai {
    align-self: flex-start;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-subtle);
}

.chat-msg-user {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
}

.chat-msg-text {
    margin: 0;
}

/* ---- Chat Input ---- */
.chat-input-area {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--color-border-subtle);
}

.chat-input-row {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
}

.chat-textarea {
    flex: 1;
    resize: none;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 0.875rem;
    line-height: 1.5;
    outline: none;
    transition: border-color var(--duration-fast);
}

.chat-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.chat-textarea::placeholder {
    color: var(--color-text-muted);
}

/* ---- Graph ---- */
.graph-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
    /* positioning context for toolbar/legend/modals */
}

.graph-container {
    width: 100%;
    flex: 1;
    min-height: 0;
    position: relative;
}

.graph-container svg {
    width: 100%;
    height: 100%;
}

/* D3 graph styles */
.node-circle {
    stroke: var(--color-bg);
    stroke-width: 2;
    cursor: pointer;
    transition: filter var(--duration-fast);
}

.node-circle:hover {
    filter: brightness(1.25) drop-shadow(0 0 10px rgba(124, 92, 252, 0.5));
}

.node-label {
    fill: var(--color-text-secondary);
    font-size: 11px;
    text-anchor: middle;
    pointer-events: auto;
    cursor: pointer;
    font-family: var(--font-sans);
}

.edge-line {
    stroke-linecap: round;
}

.edge-label-bg {
    fill: var(--color-bg-card);
    stroke: var(--color-border-subtle);
    stroke-width: 1;
}

.edge-coeff-label {
    fill: var(--color-text-secondary);
    font-size: 10px;
    text-anchor: middle;
    font-family: var(--font-mono);
}

/* ---- Panel Tabs ---- */
.panel-tabs {
    display: flex;
    gap: 2px;
    background: var(--color-bg-input);
    border-radius: var(--radius-md);
    padding: 2px;
}

.panel-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

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

.panel-tab-btn.active {
    color: var(--color-text);
    background: var(--color-bg-raised);
    box-shadow: var(--shadow-sm);
}

.drafts-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    background: #ff5722;
    color: #fff;
    line-height: 1;
}

/* ---- Graph Legend ---- */
.graph-legend {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    background: var(--color-bg-raised);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-lg);
    z-index: 20;
    max-width: 400px;
    backdrop-filter: blur(8px);
    box-shadow: var(--shadow-md);
    font-size: 0.9rem;
}

.legend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xs);
}

.legend-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.legend-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 4px;
    line-height: 1;
    opacity: 0.7;
    transition: opacity var(--duration-fast);
}

.legend-toggle-btn:hover {
    opacity: 1;
}

.legend-compact {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.legend-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    line-height: 1.5;
}

.legend-text {
    color: var(--color-text-secondary);
    font-size: 0.85rem;
}

.legend-detail {
    margin-top: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-subtle);
}

.legend-detail-text {
    color: var(--color-text-muted);
    font-size: 0.82rem;
    margin: 3px 0;
    line-height: 1.5;
}

/* ---- Drafts Container (right panel overlay) ---- */
.drafts-container {
    display: none;
    max-height: 45%;
    overflow-y: auto;
    padding: var(--space-sm) var(--space-md);
    border-top: 2px solid #ff5722;
    background: var(--color-bg-raised);
    z-index: 10;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .editor-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .editor-chat {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

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

/* ---- Loading spinner (utility) ---- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

/* ---- Typing indicator ---- */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-text-muted, #888);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ---- Draft Panel & Cards ---- */
.draft-panel {
    margin: var(--space-sm) 0;
    padding: var(--space-md);
    background: var(--color-surface-raised, rgba(124, 92, 252, 0.06));
    border: 1px solid var(--color-primary-glow, rgba(124, 92, 252, 0.25));
    border-radius: var(--radius-md);
}

.draft-panel-header {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--color-primary, #7c5cfc);
    margin-bottom: var(--space-sm);
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.draft-panel-icon {
    font-size: 1rem;
}

.draft-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    margin-top: var(--space-xs);
    background: var(--color-bg, #1a1a2e);
    border: 1px solid var(--color-border, #2a2a4a);
    border-radius: var(--radius-sm);
    transition: border-color var(--duration-fast) var(--ease-out),
        background var(--duration-fast) var(--ease-out);
}

.draft-card:hover {
    border-color: var(--color-primary, #7c5cfc);
}

.draft-card-info {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex: 1;
    min-width: 0;
}

.draft-card-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.draft-badge-node {
    background: rgba(34, 211, 238, 0.15);
    color: var(--color-accent, #22d3ee);
}

.draft-badge-edge {
    background: rgba(251, 191, 36, 0.15);
    color: var(--color-warning, #fbbf24);
}

.draft-card-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text, #fff);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.draft-card-type {
    font-size: 0.75rem;
    color: var(--color-text-muted, #888);
}

.draft-card-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.btn-draft {
    font-family: var(--font-sans);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
}

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

.btn-draft-approve {
    background: rgba(52, 211, 153, 0.12);
    color: var(--color-success, #34d399);
    border-color: rgba(52, 211, 153, 0.3);
}

.btn-draft-approve:hover:not(:disabled) {
    background: rgba(52, 211, 153, 0.25);
}

.btn-draft-reject {
    background: rgba(248, 113, 113, 0.12);
    color: var(--color-error, #f87171);
    border-color: rgba(248, 113, 113, 0.3);
}

.btn-draft-reject:hover:not(:disabled) {
    background: rgba(248, 113, 113, 0.25);
}

/* Draft card states */
.draft-card-approved {
    border-color: var(--color-success, #34d399);
    background: rgba(52, 211, 153, 0.06);
}

.draft-card-rejected {
    border-color: var(--color-error, #f87171);
    background: rgba(248, 113, 113, 0.06);
    opacity: 0.6;
}

.draft-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
}

.draft-status-badge.approved {
    color: var(--color-success, #34d399);
}

.draft-status-badge.rejected {
    color: var(--color-error, #f87171);
}

/* ---- Graph Toolbar ---- */
.graph-toolbar {
    position: absolute;
    top: var(--space-md);
    left: var(--space-md);
    display: flex;
    gap: var(--space-xs);
    background: var(--color-bg-raised);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    z-index: 25;
}

.toolbar-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-secondary);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    font-weight: 600;
    transition: all var(--duration-fast);
    white-space: nowrap;
}

.toolbar-btn:hover {
    background: var(--color-bg-subtle);
    color: var(--color-text);
}

.toolbar-btn.active {
    background: var(--color-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* ---- Graph Modals ---- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.graph-modal {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    width: 320px;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.2s ease-out;
}

.graph-modal h3 {
    margin-top: 0;
    margin-bottom: var(--space-md);
    font-size: 1.1rem;
    color: var(--color-text);
}

.modal-desc {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-md);
}

.modal-input,
.modal-select {
    width: 100%;
    margin-bottom: var(--space-md);
    padding: 8px 12px;
    background: var(--color-bg-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-size: 0.9rem;
}

.modal-input:focus,
.modal-select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-transparent);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---- New Model Dialog ---- */
.new-model-dialog {
    background: var(--color-bg-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-xl) var(--space-lg);
    width: 480px;
    max-width: 92vw;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.25s ease-out;
}

.modal-heading {
    margin: 0 0 var(--space-xs);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
}

.modal-subtext {
    margin: 0 0 var(--space-lg);
    font-size: 0.9rem;
    color: var(--color-text-muted);
    line-height: 1.5;
}

.modal-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.modal-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-secondary);
    letter-spacing: 0.02em;

}

.btn-danger {

    background: #dc2626;
    color: white;
    font-size: 0.9rem;
}

.nav-link {
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 0.95rem;
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 1s var(--ease-out) forwards;
}

.animate-slide-up {
    opacity: 0;
    animation: slideUp 0.8s var(--ease-out) 0.2s forwards;
}

.animate-slide-up-delayed {
    opacity: 0;
    animation: slideUp 0.8s var(--ease-out) 0.4s forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.landing-footer {
    padding: 40px 0;
    border-top: 1px solid var(--color-border-subtle);
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}