/**
 * TherapyFlow — global design tokens + legacy aliases for main.css.
 * Loaded before main.css from base.html.
 */

:root {
    /* —— Brand (canonical names) —— */
    --color-primary: #0f766e;
    --color-primary-light: #14b8a6;
    --color-primary-hover: #115e59;

    /* —— Background —— */
    --color-bg: #f8fafc;
    --color-card: #ffffff;

    /* —— Text —— */
    --color-text: #111827;
    --color-text-secondary: #6b7280;

    /* —— Border —— */
    --color-border: #e5e7eb;

    /* —— Status —— */
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;

    /* —— App tokens (aliases used across main.css / templates) —— */
    --primary: var(--color-primary);
    --primary-hover: var(--color-primary-hover);
    /* Soft tint for chips / subtle fills (not the same as --color-primary-light accent) */
    --primary-light: #e6f4f3;

    --bg-main: var(--color-bg);
    --bg-card: var(--color-card);
    --bg-hover: #f1f5f7;

    --text-primary: var(--color-text);
    --text-secondary: var(--color-text-secondary);
    --text-muted: #9ca3af;

    --border-color: var(--color-border);

    --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 6px 18px rgba(0, 0, 0, 0.08);

    /* —— Legacy / compatibility —— */
    --topbar-height: 64px;
    --color-primary-soft: var(--primary-light);
    --primary-soft: var(--primary-light);
    --text-on-primary: #ffffff;

    --accent-primary: var(--primary);
    --accent-hover: var(--primary-hover);

    --color-background: var(--bg-card);
    --color-surface: var(--bg-main);
    --color-surface-alt: var(--bg-hover);
    --color-text-main: var(--text-primary);
    --color-text-muted: var(--text-secondary);
    --color-text-subtle: var(--text-muted);

    --color-border-subtle: var(--border-color);

    --bg-surface: var(--bg-hover);

    --success: var(--color-success);
    --warning: var(--color-warning);
    --danger: var(--color-danger);

    --input-bg: #ffffff;
    --input-border: var(--border-color);
    --input-text: var(--text-primary);
    --table-header-bg: var(--bg-hover);
    --table-row-bg: var(--bg-card);
    --table-row-hover: var(--bg-hover);

    --sidebar-bg: #0f3f3d;
    --sidebar-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.12);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.1);

    --topbar-bg: #ffffff;
    --topbar-border-bottom: 1px solid var(--border-color);

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 2px 4px 0 rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 8px 0 rgba(0, 0, 0, 0.1);

    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --radius-xl: 12px;

    --transition-fast: 150ms ease;
    --transition-normal: 200ms ease;
    --transition-slow: 300ms ease;

    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 0.9375rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.75rem;

    --line-height-tight: 1.3;
    --line-height-normal: 1.5;
    --line-height-relaxed: 1.6;
    --line-height-loose: 1.75;

    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    --button-height-sm: 32px;
    --button-height-md: 40px;
    --button-height-lg: 48px;
}

@media (max-width: 768px) {
    :root {
        --topbar-height: 56px;
    }
}

[data-theme="dark"] {
    --primary: #2dd4bf;
    --primary-hover: #5eead4;
    --primary-light: rgba(45, 212, 191, 0.15);

    --bg-main: #1f2326;
    --bg-surface: #262b2f;
    --bg-card: #2c3237;
    --bg-hover: #31373d;

    --text-primary: #e8eaed;
    --text-secondary: #b0b6bc;
    --text-muted: #8a9197;

    --border-color: #3a4046;

    --color-bg: var(--bg-main);
    --color-card: var(--bg-card);
    --color-text: var(--text-primary);
    --color-text-secondary: var(--text-secondary);

    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.35);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.45);

    --color-primary: var(--primary);
    --color-primary-hover: var(--primary-hover);
    --color-primary-light: var(--primary-hover);
    --color-primary-soft: var(--primary-light);
    --accent-primary: var(--primary);
    --accent-hover: var(--primary-hover);

    --color-background: var(--bg-main);
    --color-surface: var(--bg-surface);
    --color-surface-alt: var(--bg-hover);
    --color-text-main: var(--text-primary);
    --color-text-muted: var(--text-secondary);
    --color-text-subtle: var(--text-muted);
    --color-border: var(--border-color);
    --color-border-subtle: var(--border-color);

    --input-bg: #2b3136;
    --input-border: #3a4046;
    --input-text: #e8eaed;
    --table-header-bg: #2a2f34;
    --table-row-bg: #262b2f;
    --table-row-hover: #31373d;

    --sidebar-bg: #0f3f3d;
    --sidebar-text: #e8f4f3;
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-hover-bg: rgba(255, 255, 255, 0.08);

    --topbar-bg: var(--bg-surface);
    --topbar-border-bottom: 1px solid var(--border-color);
}

[data-theme="light"] {
    --color-background: var(--bg-card);
    --color-surface: var(--bg-main);
    --color-surface-alt: var(--bg-hover);
    --color-text-main: var(--text-primary);
    --color-text-muted: var(--text-secondary);
    --color-text-subtle: var(--text-muted);
    --color-border: var(--border-color);
    --color-border-subtle: var(--border-color);
    --color-primary-soft: var(--primary-light);
}

/* --- Status pills (semantic; no forced white on children) --- */
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.2;
    box-sizing: border-box;
    white-space: nowrap;
}

.status-new {
    background: rgba(20, 184, 166, 0.1);
    color: #14b8a6;
}

.status-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
}

.status-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.status-success {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.status-badge a,
.status-badge a:link,
.status-badge a:visited,
.status-badge a:hover,
.status-badge a:active {
    color: inherit;
    text-decoration: none;
}

/* Utilities */
.bg-main {
    background-color: var(--bg-main);
}

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

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

.text-secondary {
    color: var(--text-secondary);
}

/* Global inputs / filters (SaaS baseline; main.css may refine per component) */
input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="image"]):not([type="reset"]),
select,
textarea {
    background: var(--input-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 10px;
    color: var(--input-text);
    box-sizing: border-box;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="image"]):not([type="reset"]):focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
    outline: none;
}

/*
 * Native date/time inputs — global dark mode
 * (!important wins over the broad input:not(...) baseline in this file.)
 */
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="time"],
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="month"],
body.dark-mode input[type="date"],
body.dark-mode input[type="time"],
body.dark-mode input[type="datetime-local"],
body.dark-mode input[type="month"] {
    color-scheme: dark;
    background: #111827 !important;
    color: #e5e7eb !important;
    border: 1px solid #243041 !important;
    border-radius: 10px;
    box-sizing: border-box;
    accent-color: #14b8a6;
}

html[data-theme="dark"] input[type="date"]:focus,
html[data-theme="dark"] input[type="time"]:focus,
html[data-theme="dark"] input[type="datetime-local"]:focus,
html[data-theme="dark"] input[type="month"]:focus,
body.dark-mode input[type="date"]:focus,
body.dark-mode input[type="time"]:focus,
body.dark-mode input[type="datetime-local"]:focus,
body.dark-mode input[type="month"]:focus {
    border-color: #14b8a6 !important;
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15) !important;
    outline: none !important;
}

html[data-theme="dark"] input[type="date"]::placeholder,
html[data-theme="dark"] input[type="time"]::placeholder,
html[data-theme="dark"] input[type="datetime-local"]::placeholder,
html[data-theme="dark"] input[type="month"]::placeholder,
body.dark-mode input[type="date"]::placeholder,
body.dark-mode input[type="time"]::placeholder,
body.dark-mode input[type="datetime-local"]::placeholder,
body.dark-mode input[type="month"]::placeholder {
    color: #94a3b8;
    opacity: 1;
}

/* Chromium / Safari: inner edit fields */
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="month"]::-webkit-datetime-edit,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="month"]::-webkit-datetime-edit-fields-wrapper,
html[data-theme="dark"] input[type="date"]::-webkit-datetime-edit-text,
html[data-theme="dark"] input[type="time"]::-webkit-datetime-edit-text,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-datetime-edit-text,
html[data-theme="dark"] input[type="month"]::-webkit-datetime-edit-text,
body.dark-mode input[type="date"]::-webkit-datetime-edit,
body.dark-mode input[type="time"]::-webkit-datetime-edit,
body.dark-mode input[type="datetime-local"]::-webkit-datetime-edit,
body.dark-mode input[type="month"]::-webkit-datetime-edit,
body.dark-mode input[type="date"]::-webkit-datetime-edit-fields-wrapper,
body.dark-mode input[type="time"]::-webkit-datetime-edit-fields-wrapper,
body.dark-mode input[type="datetime-local"]::-webkit-datetime-edit-fields-wrapper,
body.dark-mode input[type="month"]::-webkit-datetime-edit-fields-wrapper,
body.dark-mode input[type="date"]::-webkit-datetime-edit-text,
body.dark-mode input[type="time"]::-webkit-datetime-edit-text,
body.dark-mode input[type="datetime-local"]::-webkit-datetime-edit-text,
body.dark-mode input[type="month"]::-webkit-datetime-edit-text {
    color: #e5e7eb;
}

/* Calendar / clock icons (WebKit/Blink) */
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="month"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="date"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="datetime-local"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="month"]::-webkit-calendar-picker-indicator,
body.dark-mode input[type="time"]::-webkit-calendar-picker-indicator {
    opacity: 0.92;
    cursor: pointer;
    filter: invert(1) brightness(1.12);
}
