/* Neo-OMS v2 Design Tokens + Base Layout
 * docs/neo-oms/05_design_system.md 참조
 */

:root {
    /* Neutral */
    --color-bg: #ffffff;
    --color-bg-soft: #f8fafc;
    --color-bg-sunken: #f1f5f9;
    --color-border: #e2e8f0;
    --color-border-strong: #cbd5e1;
    --color-divider: #edf2f7;
    --color-text: #0f172a;
    --color-text-muted: #475569;
    --color-text-faint: #94a3b8;
    --color-text-on-dark: #f8fafc;
    --color-focus-ring: rgba(59, 130, 246, 0.35);

    /* Semantic */
    --color-success: #10b981;
    --color-success-bg: #ecfdf5;
    --color-warning: #f59e0b;
    --color-warning-bg: #fffbeb;
    --color-danger: #ef4444;
    --color-danger-bg: #fef2f2;
    --color-info: #06b6d4;
    --color-info-bg: #ecfeff;
    --color-neutral-badge: #64748b;

    /* Workspace */
    --ws-center: #10b981;
    --ws-sales: #3b82f6;
    --ws-cs: #f59e0b;
    --ws-ops: #8b5cf6;
    --ws-finance: #f97316;
    --ws-insight: #06b6d4;
    --ws-system: #ef4444;
    --ws-accent: var(--ws-sales); /* default fallback */

    /* Typography */
    --font-sans: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", "SF Mono", Menlo, Monaco, "Noto Sans Mono", monospace;

    --text-xs: 11px;
    --text-sm: 12px;
    --text-md: 13px;
    --text-base: 14px;
    --text-lg: 15px;
    --text-xl: 17px;
    --text-2xl: 20px;
    --text-3xl: 24px;
    --text-4xl: 28px;

    --fw-regular: 400;
    --fw-medium: 500;
    --fw-semibold: 600;
    --fw-bold: 700;

    /* Spacing (4px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 10px;
    --radius-pill: 999px;

    /* Shadow */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 12px 24px -8px rgba(15, 23, 42, 0.15);
    --shadow-focus: 0 0 0 3px rgba(59, 130, 246, 0.35);

    /* Motion */
    --dur-fast: 120ms;
    --dur-base: 200ms;
    --dur-slow: 320ms;
    --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* Workspace accent 주입 */
body[data-ws="center"]  { --ws-accent: var(--ws-center); }
body[data-ws="sales"]   { --ws-accent: var(--ws-sales); }
body[data-ws="cs"]      { --ws-accent: var(--ws-cs); }
body[data-ws="ops"]     { --ws-accent: var(--ws-ops); }
body[data-ws="finance"] { --ws-accent: var(--ws-finance); }
body[data-ws="insight"] { --ws-accent: var(--ws-insight); }
body[data-ws="system"]  { --ws-accent: var(--ws-system); }

/* Reset / base */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--font-sans);
    font-size: var(--text-md);
    color: var(--color-text);
    background: var(--color-bg-soft);
    line-height: 1.5;
}

a { color: var(--ws-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
    border-radius: var(--radius-sm);
}

/* AppShell */
.shell {
    display: grid;
    grid-template-rows: 56px 1fr;
    grid-template-columns: 240px 1fr;
    grid-template-areas:
        "header header"
        "sidebar main";
    min-height: 100vh;
}

.shell-header {
    grid-area: header;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 var(--space-4);
    gap: var(--space-4);
    position: sticky;
    top: 0;
    z-index: 10;
}

.shell-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: var(--fw-semibold);
    font-size: var(--text-base);
}

.shell-brand .dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--ws-accent);
}

.shell-spacer { flex: 1; }

.shell-header .user {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}

.shell-header .user .avatar {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    background: var(--color-bg-sunken);
    display: grid;
    place-items: center;
    font-weight: var(--fw-semibold);
    color: var(--color-text);
}

.shell-sidebar {
    grid-area: sidebar;
    background: var(--color-bg);
    border-right: 1px solid var(--color-border);
    padding: var(--space-3) 0;
    overflow-y: auto;
}

.shell-sidebar .ws-label {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--fw-semibold);
    color: var(--color-text);
    border-left: 3px solid var(--ws-accent);
    margin-bottom: var(--space-2);
}

.shell-sidebar .ws-label small {
    display: block;
    color: var(--color-text-faint);
    font-weight: var(--fw-regular);
    font-size: var(--text-xs);
    margin-top: 2px;
}

.shell-sidebar .section {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-transform: uppercase;
    padding: var(--space-3) var(--space-4) var(--space-1);
    letter-spacing: 0.04em;
}

.shell-sidebar .nav-item {
    display: block;
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-md);
    color: var(--color-text);
    border-left: 3px solid transparent;
    transition: background var(--dur-fast) var(--ease-out);
}
.shell-sidebar .nav-item:hover {
    background: var(--color-bg-sunken);
    text-decoration: none;
}
.shell-sidebar .nav-item.active {
    background: var(--color-bg-sunken);
    border-left-color: var(--ws-accent);
    color: var(--color-text);
    font-weight: var(--fw-medium);
}

.shell-main {
    grid-area: main;
    padding: var(--space-6);
    overflow-x: auto;
}

.shell-main h1 { font-size: var(--text-xl); font-weight: var(--fw-semibold); margin: 0 0 var(--space-2) 0; }
.shell-main h2 { font-size: var(--text-lg); font-weight: var(--fw-semibold); margin: 0 0 var(--space-2) 0; }
.shell-main .subtitle { color: var(--color-text-muted); font-size: var(--text-md); margin-bottom: var(--space-5); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 32px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-md);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--dur-fast) var(--ease-out),
                border-color var(--dur-fast) var(--ease-out);
}
.btn:hover { background: var(--color-bg-sunken); }
.btn-primary {
    background: var(--ws-accent);
    border-color: var(--ws-accent);
    color: #fff;
}
.btn-primary:hover { filter: brightness(0.95); background: var(--ws-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ws-accent); }
.btn-ghost:hover { background: var(--color-bg-sunken); }
.btn-block { width: 100%; height: 40px; font-size: var(--text-base); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Form inputs */
.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: var(--fw-medium);
    color: var(--color-text);
    margin-bottom: var(--space-1);
}
.form-input {
    width: 100%;
    height: 36px;
    padding: 0 var(--space-3);
    border: 1px solid var(--color-border-strong);
    background: var(--color-bg);
    color: var(--color-text);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    border-radius: var(--radius-md);
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out);
}
.form-input:focus { outline: none; border-color: var(--ws-accent); box-shadow: var(--shadow-focus); }
.form-help { font-size: var(--text-xs); color: var(--color-text-muted); margin-top: var(--space-1); }
.form-error { font-size: var(--text-xs); color: var(--color-danger); margin-top: var(--space-1); }

/* Card */
.card {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
}

/* Badge / Status Chip */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    height: 20px;
    padding: 0 var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--fw-medium);
    border-radius: var(--radius-pill);
    background: var(--color-bg-sunken);
    color: var(--color-text-muted);
}
.badge .dot {
    width: 6px;
    height: 6px;
    border-radius: var(--radius-pill);
    background: currentColor;
}
.badge-success { color: var(--color-success); background: var(--color-success-bg); }
.badge-warning { color: var(--color-warning); background: var(--color-warning-bg); }
.badge-danger  { color: var(--color-danger);  background: var(--color-danger-bg); }
.badge-info    { color: var(--color-info);    background: var(--color-info-bg); }

/* Auth center layout (로그인 화면 전용) */
.auth-center {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: var(--color-bg-soft);
    padding: var(--space-6);
}
.auth-card {
    width: 400px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-8);
    box-shadow: var(--shadow-md);
}
.auth-brand {
    text-align: center;
    margin-bottom: var(--space-6);
}
.auth-brand .logo-dot {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-pill);
    background: var(--ws-accent);
    display: inline-block;
    margin-right: var(--space-2);
    vertical-align: middle;
}
.auth-brand .brand-name {
    font-size: var(--text-xl);
    font-weight: var(--fw-semibold);
    display: inline-block;
}
.auth-brand .brand-sub {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.auth-form .form-row { margin-bottom: var(--space-4); }
.auth-footer {
    margin-top: var(--space-5);
    text-align: center;
    font-size: var(--text-xs);
    color: var(--color-text-faint);
}

/* Workspace grid (dashboard) */
.ws-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-4);
    margin-top: var(--space-5);
}
.ws-tile {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    cursor: pointer;
    transition: border-color var(--dur-fast) var(--ease-out),
                box-shadow var(--dur-fast) var(--ease-out),
                transform var(--dur-fast) var(--ease-out);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    text-decoration: none;
    color: inherit;
}
.ws-tile:hover {
    border-color: var(--tile-color, var(--ws-accent));
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
    text-decoration: none;
}
.ws-tile .tile-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-pill);
    background: var(--tile-color, var(--ws-accent));
    margin-bottom: var(--space-2);
}
.ws-tile .tile-name {
    font-size: var(--text-base);
    font-weight: var(--fw-semibold);
}
.ws-tile .tile-desc {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
.ws-tile .tile-meta {
    margin-top: auto;
    font-size: var(--text-xs);
    color: var(--color-text-faint);
}
