/* ===========================================================
   Luna Chem Lab — Design Tokens + Component Primitives (Step 6)
   Additive layer; does NOT override existing styles.
   Use: <link rel="stylesheet" href="chem-lab/css/tokens.css" />
   =========================================================== */

:root {
    /* Colors — 3 brand + neutrals (Step 6 canonical tokens) */
    --c-primary: #22d3ee;      /* same value as legacy --cyan-bright */
    --c-primary-dim: #06b6d4;  /* same as legacy --cyan */
    --c-warn: #f59e0b;         /* same as legacy --amber / --orange */
    --c-warn-dim: #d97706;
    --c-danger: #ef4444;       /* same as legacy --red */
    --c-danger-dim: #dc2626;
    --c-success: #22c55e;      /* same as legacy --green */

    --c-bg: #0a0a14;
    --c-panel: rgba(12,14,32,0.92);
    --c-panel-alt: rgba(18,20,40,0.85);
    --c-border: rgba(34,211,238,0.22);
    --c-border-strong: rgba(34,211,238,0.5);

    --c-text: #e6e9ef;
    --c-text-dim: #8a95a6;
    --c-text-muted: #556070;

    /* Fonts */
    --f-ui: 'Jua', 'Malgun Gothic', sans-serif;
    --f-mono: 'JetBrains Mono', monospace;
    --f-hud: 'Orbitron', monospace;

    /* Font sizes */
    --fs-xs: 10px;
    --fs-sm: 12px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 20px;

    /* Spacing 8px grid */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-6: 24px;
    --s-8: 32px;

    /* Radius */
    --r-sm: 4px;
    --r-md: 8px;
    --r-lg: 12px;
    --r-xl: 16px;
    --r-full: 9999px;

    /* Shadows */
    --sh-sm: 0 2px 6px rgba(0,0,0,0.3);
    --sh-md: 0 4px 14px rgba(0,0,0,0.4);
    --sh-lg: 0 8px 32px rgba(0,0,0,0.5);
    --sh-glow-primary: 0 0 16px rgba(34,211,238,0.3);
    --sh-glow-warn: 0 0 16px rgba(245,158,11,0.4);
    --sh-glow-danger: 0 0 16px rgba(239,68,68,0.4);

    /* Motion */
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* =========== Button primitives (4 styles + sizes) =========== */
.btn {
    padding: var(--s-2) var(--s-4);
    font-family: var(--f-ui);
    font-size: var(--fs-sm);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    line-height: 1.2;
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--c-primary); outline-offset: 2px; }

.btn-primary {
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dim));
    color: #fff;
    box-shadow: var(--sh-sm);
}
.btn-primary:hover { box-shadow: var(--sh-md), var(--sh-glow-primary); }

.btn-secondary {
    background: transparent;
    border-color: var(--c-border-strong);
    color: var(--c-text);
}
.btn-secondary:hover { background: rgba(34,211,238,0.1); }

.btn-danger {
    background: linear-gradient(135deg, var(--c-danger), var(--c-danger-dim));
    color: #fff;
    box-shadow: var(--sh-sm);
}
.btn-danger:hover { box-shadow: var(--sh-md), var(--sh-glow-danger); }

.btn-ghost {
    background: rgba(0,0,0,0.3);
    border-color: transparent;
    color: var(--c-text);
}
.btn-ghost:hover { background: rgba(34,211,238,0.15); border-color: var(--c-border); }

.btn-sm { padding: var(--s-1) var(--s-3); font-size: var(--fs-xs); }
.btn-lg { padding: var(--s-3) var(--s-6); font-size: var(--fs-md); }

/* =========== Modal shell (unified header) =========== */
.modal-shell {
    background: linear-gradient(135deg, #0d1220, #161a32);
    border: 1.5px solid var(--c-border-strong);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--sh-lg), 0 0 40px rgba(34,211,238,0.15);
    display: flex;
    flex-direction: column;
}
.modal-shell.is-danger { border-color: var(--c-danger); box-shadow: var(--sh-lg), var(--sh-glow-danger); }
.modal-shell.is-warn { border-color: var(--c-warn); box-shadow: var(--sh-lg), var(--sh-glow-warn); }

.modal-shell-header {
    padding: var(--s-4) var(--s-6);
    background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(168,85,247,0.08));
    border-bottom: 1px solid var(--c-border);
    position: relative;
    min-height: 60px;
}
.modal-shell.is-danger .modal-shell-header { background: linear-gradient(135deg, rgba(239,68,68,0.25), rgba(245,158,11,0.12)); }

.modal-shell-title {
    font-family: var(--f-ui);
    font-size: var(--fs-xl);
    color: #fff;
    margin: 0;
    line-height: 1.2;
}
.modal-shell-sub {
    font-family: var(--f-mono);
    font-size: var(--fs-xs);
    color: var(--c-text-dim);
    margin: var(--s-1) 0 0 0;
}
.modal-shell-close {
    position: absolute;
    top: var(--s-3);
    right: var(--s-4);
    width: 28px; height: 28px;
    background: rgba(239,68,68,0.2);
    border: 1px solid rgba(239,68,68,0.5);
    color: #fff;
    border-radius: var(--r-sm);
    cursor: pointer;
    font-size: var(--fs-sm);
    font-weight: bold;
}
.modal-shell-close:hover { background: rgba(239,68,68,0.4); }

.modal-shell-body {
    padding: var(--s-4) var(--s-6);
    overflow-y: auto;
    flex: 1;
    color: var(--c-text);
}

.modal-shell-footer {
    padding: var(--s-3) var(--s-6);
    background: rgba(0,0,0,0.3);
    border-top: 1px solid var(--c-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
}

/* =========== Panel Upgrade (Step 6 — better resize/move UX) =========== */
/* Floating panel improvements */
.side-panel.floating {
    position: fixed !important;
    z-index: 50 !important;
    resize: both !important;
    min-width: 140px;
    min-height: 200px;
    max-width: 600px;
    max-height: 85vh;
    overflow: auto;
}

/* Bigger, clearer resize corner */
.side-panel.floating::after {
    content: '';
    position: absolute;
    right: 0; bottom: 0;
    width: 18px; height: 18px;
    background:
        linear-gradient(135deg, transparent 40%, var(--c-primary) 45%, var(--c-primary) 55%, transparent 60%),
        linear-gradient(135deg, transparent 55%, var(--c-primary) 60%, var(--c-primary) 70%, transparent 75%),
        linear-gradient(135deg, transparent 70%, var(--c-primary) 75%, var(--c-primary) 85%, transparent 90%);
    cursor: nwse-resize;
    pointer-events: none;
    opacity: 0.8;
}

/* More visible drag handle */
.side-panel.floating .panel-drag-handle {
    height: 28px !important;
    background: linear-gradient(90deg, rgba(34,211,238,0.35), rgba(168,85,247,0.2)) !important;
    border-bottom: 2px solid var(--c-primary) !important;
    cursor: move !important;
    font-family: var(--f-ui) !important;
    font-size: var(--fs-sm) !important;
    color: var(--c-primary) !important;
    letter-spacing: 0.5px !important;
    text-transform: none !important;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.3);
}
.side-panel.floating .panel-drag-handle::before {
    content: '⋮⋮';
    margin-right: var(--s-2);
    font-size: 14px;
    opacity: 0.7;
}
.side-panel.floating { padding-top: 34px !important; }

/* Dock button inside drag handle — clearer styling */
.panel-drag-handle .panel-dock-btn {
    background: linear-gradient(135deg, var(--c-primary), var(--c-primary-dim)) !important;
    color: #0a0a14 !important;
    border: none !important;
    padding: 3px 10px !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    border-radius: var(--r-sm) !important;
    cursor: pointer !important;
}
.panel-drag-handle .panel-dock-btn:hover {
    box-shadow: var(--sh-glow-primary);
}

/* Floating panel reset position button (returns to default dock spot) */
.panel-reset-btn {
    position: absolute;
    top: 4px;
    right: 60px;
    background: rgba(168,85,247,0.2);
    border: 1px solid rgba(168,85,247,0.5);
    color: #c084fc;
    border-radius: var(--r-sm);
    padding: 2px 8px;
    font-size: var(--fs-xs);
    cursor: pointer;
    z-index: 3;
    font-family: var(--f-ui);
    display: none;
}
.side-panel.floating .panel-reset-btn { display: inline-block; }
.panel-reset-btn:hover { background: rgba(168,85,247,0.35); }
