/* FORGECAST shared design system
   Load this file before page-specific styles. */
:root {
    color-scheme: dark;

    /* Typography */
    --fc-font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;
    --fc-font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    --fc-text-xs: 0.75rem;
    --fc-text-sm: 0.875rem;
    --fc-text-md: 1rem;
    --fc-text-lg: 1.125rem;
    --fc-text-xl: 1.25rem;
    --fc-text-2xl: 1.5rem;
    --fc-text-3xl: 2rem;
    --fc-leading-tight: 1.25;
    --fc-leading-normal: 1.5;
    --fc-weight-regular: 400;
    --fc-weight-medium: 500;
    --fc-weight-semibold: 600;
    --fc-weight-bold: 700;

    /* Spacing: 4px base scale */
    --fc-space-0: 0;
    --fc-space-1: 0.25rem;
    --fc-space-2: 0.5rem;
    --fc-space-3: 0.75rem;
    --fc-space-4: 1rem;
    --fc-space-5: 1.25rem;
    --fc-space-6: 1.5rem;
    --fc-space-8: 2rem;
    --fc-space-10: 2.5rem;
    --fc-space-12: 3rem;
    --fc-space-16: 4rem;

    /* Shape */
    --fc-radius-sm: 0.5rem;
    --fc-radius-md: 0.75rem;
    --fc-radius-lg: 1rem;
    --fc-radius-xl: 1.25rem;
    --fc-radius-pill: 999px;

    /* Brand and semantic colors */
    --fc-brand: #0ea5e9;
    --fc-brand-hover: #0284c7;
    --fc-brand-active: #0369a1;
    --fc-success: #22c55e;
    --fc-warning: #f59e0b;
    --fc-danger: #f87171;
    --fc-info: #38bdf8;

    /* Dark surfaces */
    --fc-bg: #0b1120;
    --fc-sidebar: #16233a;
    --fc-surface: #0f172a;
    --fc-surface-raised: #162033;
    --fc-field: #111c31;
    --fc-border: #1e293b;
    --fc-border-strong: #334155;
    --fc-text: #ffffff;
    --fc-text-secondary: #94a3b8;
    --fc-text-muted: #64748b;
    --fc-overlay: rgba(2, 6, 23, 0.72);

    /* Elevation and interaction */
    --fc-shadow-sm: 0 4px 12px rgba(2, 6, 23, 0.18);
    --fc-shadow-md: 0 16px 38px rgba(2, 6, 23, 0.28);
    --fc-shadow-lg: 0 24px 60px rgba(2, 6, 23, 0.38);
    --fc-focus-ring: 0 0 0 3px rgba(14, 165, 233, 0.18);
    --fc-duration-fast: 150ms;
    --fc-duration-normal: 220ms;
    --fc-ease-standard: cubic-bezier(0.2, 0, 0, 1);

    /* Layering */
    --fc-z-dropdown: 100;
    --fc-z-sticky: 200;
    --fc-z-modal: 1000;
    --fc-z-toast: 1100;

    /* Component sizing */
    --fc-control-height-sm: 2.25rem;
    --fc-control-height: 2.75rem;
    --fc-control-height-lg: 3rem;
    --fc-content-max: 90rem;
}

body.light-mode,
body.cashier-light-theme,
[data-theme="light"] {
    color-scheme: light;
    --fc-bg: #f7f7f8;
    --fc-sidebar: #ffffff;
    --fc-surface: #ffffff;
    --fc-surface-raised: #ffffff;
    --fc-field: #ffffff;
    --fc-border: #dedee3;
    --fc-border-strong: #c9cbd1;
    --fc-text: #111827;
    --fc-text-secondary: #4b5563;
    --fc-text-muted: #7a8491;
    --fc-success: #16a34a;
    --fc-danger: #dc2626;
    --fc-overlay: rgba(15, 23, 42, 0.5);
    --fc-shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.08);
    --fc-shadow-md: 0 16px 38px rgba(15, 23, 42, 0.12);
    --fc-shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.16);
}

:where(html) {
    text-size-adjust: 100%;
}

:where(body, button, input, select, textarea) {
    font-family: var(--fc-font-sans);
}

:where(button, input, select, textarea) {
    font: inherit;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--fc-brand);
    outline-offset: 2px;
}

:where(button, [role="button"]):not(:disabled) {
    cursor: pointer;
}

:where(button, input, select, textarea):disabled,
:where([aria-disabled="true"]) {
    cursor: not-allowed;
    opacity: 0.58;
}

/* Reusable component primitives for new and migrated screens. */
.fc-btn {
    min-height: var(--fc-control-height);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--fc-space-2);
    padding: 0 var(--fc-space-4);
    border: 1px solid transparent;
    border-radius: var(--fc-radius-md);
    font-weight: var(--fc-weight-semibold);
    line-height: 1;
    text-decoration: none;
    transition: background var(--fc-duration-normal) var(--fc-ease-standard),
        border-color var(--fc-duration-normal) var(--fc-ease-standard),
        color var(--fc-duration-normal) var(--fc-ease-standard),
        transform var(--fc-duration-fast) var(--fc-ease-standard);
}

.fc-btn:active:not(:disabled) {
    transform: translateY(1px);
}

.fc-btn--primary {
    background: var(--fc-brand);
    color: #ffffff;
}

.fc-btn--primary:hover:not(:disabled) {
    background: var(--fc-brand-hover);
}

.fc-btn--secondary {
    border-color: var(--fc-border);
    background: var(--fc-surface);
    color: var(--fc-text);
}

.fc-btn--secondary:hover:not(:disabled) {
    border-color: var(--fc-border-strong);
    background: var(--fc-surface-raised);
}

.fc-btn--danger {
    background: var(--fc-danger);
    color: #ffffff;
}

.fc-field {
    display: grid;
    gap: var(--fc-space-2);
}

.fc-field__label {
    color: var(--fc-text-secondary);
    font-size: var(--fc-text-sm);
    font-weight: var(--fc-weight-semibold);
}

.fc-input,
.fc-select,
.fc-textarea {
    width: 100%;
    min-height: var(--fc-control-height);
    padding: 0 var(--fc-space-3);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-md);
    background: var(--fc-field);
    color: var(--fc-text);
    transition: border-color var(--fc-duration-normal) var(--fc-ease-standard),
        box-shadow var(--fc-duration-normal) var(--fc-ease-standard);
}

.fc-textarea {
    min-height: 7rem;
    padding-block: var(--fc-space-3);
    resize: vertical;
}

.fc-input:focus,
.fc-select:focus,
.fc-textarea:focus {
    border-color: var(--fc-brand);
    outline: 0;
    box-shadow: var(--fc-focus-ring);
}

.fc-field__help,
.fc-field__error {
    margin: 0;
    font-size: var(--fc-text-sm);
    line-height: var(--fc-leading-normal);
}

.fc-field__help { color: var(--fc-text-muted); }
.fc-field__error { color: var(--fc-danger); }

.fc-modal {
    width: min(100% - 2rem, 34rem);
    border: 1px solid var(--fc-border);
    border-radius: var(--fc-radius-lg);
    background: var(--fc-surface);
    color: var(--fc-text);
    box-shadow: var(--fc-shadow-lg);
}

.fc-badge {
    min-height: 1.5rem;
    display: inline-flex;
    align-items: center;
    gap: var(--fc-space-1);
    padding: 0.2rem var(--fc-space-2);
    border-radius: var(--fc-radius-pill);
    font-size: var(--fc-text-xs);
    font-weight: var(--fc-weight-semibold);
    line-height: 1;
}

.fc-badge--success { background: color-mix(in srgb, var(--fc-success) 16%, transparent); color: var(--fc-success); }
.fc-badge--warning { background: color-mix(in srgb, var(--fc-warning) 16%, transparent); color: var(--fc-warning); }
.fc-badge--danger { background: color-mix(in srgb, var(--fc-danger) 16%, transparent); color: var(--fc-danger); }
.fc-badge--info { background: color-mix(in srgb, var(--fc-info) 16%, transparent); color: var(--fc-info); }

.fc-empty-state {
    display: grid;
    place-items: center;
    gap: var(--fc-space-3);
    min-height: 12rem;
    padding: var(--fc-space-8);
    color: var(--fc-text-secondary);
    text-align: center;
}

.fc-spinner {
    width: 1.25rem;
    aspect-ratio: 1;
    border: 2px solid color-mix(in srgb, var(--fc-brand) 24%, transparent);
    border-top-color: var(--fc-brand);
    border-radius: 50%;
    animation: fc-spin 0.75s linear infinite;
}

.fc-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@keyframes fc-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
