/* Semantic theme tokens — Summer (default workshop) and Ocean (coastal) in light + dark */

:root,
[data-theme="summer"][data-mode="light"] {
    --app-bg: #f8fafc;
    --app-text: #0f172a;
    --app-text-muted: #475569;
    --app-text-subtle: #64748b;
    --nav-bg: #0f172a;
    --nav-text: #ffffff;
    --nav-link-hover: #fcd34d;
    --nav-link-active: #fcd34d;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    --surface-muted: #f1f5f9;
    --surface-hover: #f8fafc;
    --accent: #f59e0b;
    --accent-hover: #d97706;
    --accent-text: #0f172a;
    --link: #b45309;
    --link-hover: #92400e;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --focus-ring: #f59e0b;
    --shadow-color: rgba(15, 23, 42, 0.08);
}

[data-theme="summer"][data-mode="dark"] {
    --app-bg: #0f172a;
    --app-text: #f1f5f9;
    --app-text-muted: #cbd5e1;
    --app-text-subtle: #94a3b8;
    --nav-bg: #020617;
    --nav-text: #f8fafc;
    --nav-link-hover: #fcd34d;
    --nav-link-active: #fcd34d;
    --card-bg: #1e293b;
    --card-border: #334155;
    --surface-muted: #1e293b;
    --surface-hover: #334155;
    --accent: #f59e0b;
    --accent-hover: #fbbf24;
    --accent-text: #0f172a;
    --link: #fcd34d;
    --link-hover: #fde68a;
    --input-bg: #1e293b;
    --input-border: #475569;
    --focus-ring: #fbbf24;
    --shadow-color: rgba(0, 0, 0, 0.35);
}

[data-theme="ocean"][data-mode="light"] {
    --app-bg: #f0fdfa;
    --app-text: #134e4a;
    --app-text-muted: #0f766e;
    --app-text-subtle: #14b8a6;
    --nav-bg: #115e59;
    --nav-text: #f0fdfa;
    --nav-link-hover: #99f6e4;
    --nav-link-active: #5eead4;
    --card-bg: #ffffff;
    --card-border: #99f6e4;
    --surface-muted: #ccfbf1;
    --surface-hover: #f0fdfa;
    --accent: #14b8a6;
    --accent-hover: #0d9488;
    --accent-text: #042f2e;
    --link: #0f766e;
    --link-hover: #115e59;
    --input-bg: #ffffff;
    --input-border: #5eead4;
    --focus-ring: #14b8a6;
    --shadow-color: rgba(17, 94, 89, 0.12);
}

[data-theme="ocean"][data-mode="dark"] {
    --app-bg: #042f2e;
    --app-text: #ccfbf1;
    --app-text-muted: #99f6e4;
    --app-text-subtle: #5eead4;
    --nav-bg: #134e4a;
    --nav-text: #f0fdfa;
    --nav-link-hover: #5eead4;
    --nav-link-active: #2dd4bf;
    --card-bg: #115e59;
    --card-border: #0f766e;
    --surface-muted: #134e4a;
    --surface-hover: #0f766e;
    --accent: #2dd4bf;
    --accent-hover: #5eead4;
    --accent-text: #042f2e;
    --link: #5eead4;
    --link-hover: #99f6e4;
    --input-bg: #115e59;
    --input-border: #0f766e;
    --focus-ring: #2dd4bf;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

/* Base application surfaces */
body {
    background-color: var(--app-bg) !important;
    color: var(--app-text) !important;
}

nav.bg-slate-900,
.bg-slate-900 {
    background-color: var(--nav-bg) !important;
    color: var(--nav-text) !important;
}

.nav-link {
    color: var(--nav-text);
}

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

.nav-link-active {
    color: var(--nav-link-active);
}

/* Tailwind utility overrides for dark mode (and themed light) */
.bg-white {
    background-color: var(--card-bg) !important;
}

.bg-slate-50 {
    background-color: var(--app-bg) !important;
}

.bg-slate-100,
.hover\:bg-slate-50:hover,
.hover\:bg-slate-100:hover {
    background-color: var(--surface-muted) !important;
}

.text-slate-900,
.text-slate-800 {
    color: var(--app-text) !important;
}

.text-slate-600,
.text-slate-700 {
    color: var(--app-text-muted) !important;
}

.text-slate-500 {
    color: var(--app-text-subtle) !important;
}

.border,
.border-slate-200,
.border-slate-300 {
    border-color: var(--card-border) !important;
}

.shadow-sm {
    box-shadow: 0 1px 2px 0 var(--shadow-color) !important;
}

.bg-amber-500,
.hover\:bg-amber-500:hover {
    background-color: var(--accent) !important;
}

.hover\:bg-amber-600:hover {
    background-color: var(--accent-hover) !important;
}

.text-amber-700,
.text-amber-800 {
    color: var(--link) !important;
}

a.text-amber-700:hover {
    color: var(--link-hover) !important;
}

.form-input {
    background-color: var(--input-bg);
    border-color: var(--input-border);
    color: var(--app-text);
}

.form-input:focus,
.form-input:focus-visible {
    outline-color: var(--focus-ring);
}

button:focus-visible,
a:focus-visible,
.nav-link:focus-visible {
    outline-color: var(--focus-ring);
}

.skip-link {
    background: var(--nav-bg);
    color: var(--nav-text);
}

/* Message alerts — keep semantic colors but soften in dark mode */
[data-mode="dark"] .bg-red-100 {
    background-color: #450a0a !important;
}

[data-mode="dark"] .text-red-800,
[data-mode="dark"] .text-red-700 {
    color: #fecaca !important;
}

[data-mode="dark"] .bg-amber-100 {
    background-color: #451a03 !important;
}

[data-mode="dark"] .text-amber-900 {
    color: #fde68a !important;
}

[data-mode="dark"] .bg-emerald-100 {
    background-color: #052e16 !important;
}

[data-mode="dark"] .text-emerald-800 {
    color: #bbf7d0 !important;
}

/* Theme picker on account settings */
.theme-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: 0.75rem;
}

.theme-preview-card {
    border: 2px solid var(--card-border);
    border-radius: 0.75rem;
    overflow: hidden;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-preview-card:hover {
    border-color: var(--accent);
}

.theme-preview-card.is-selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}

.theme-preview-card:focus-within {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

.theme-preview-swatch {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 4.5rem;
}

.theme-preview-half {
    padding: 0.5rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 0.25rem;
}

.theme-preview-nav {
    height: 0.55rem;
    border-radius: 9999px;
    opacity: 0.95;
}

.theme-preview-accent {
    height: 0.4rem;
    width: 55%;
    border-radius: 9999px;
}

.theme-preview-card-body {
    padding: 0.625rem 0.75rem;
    background: var(--card-bg);
    border-top: 1px solid var(--card-border);
}

.theme-preview-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--app-text);
}

.theme-preview-card-caption {
    font-size: 0.75rem;
    color: var(--app-text-subtle);
}

.mode-toggle {
    display: inline-flex;
    border: 1px solid var(--card-border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.mode-toggle label {
    margin: 0;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--app-text-muted);
    background: var(--card-bg);
}

.mode-toggle label:has(input:checked) {
    background: var(--accent);
    color: var(--accent-text);
}

.mode-toggle input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Swatch colors — Summer */
.theme-preview-card[data-theme-value="summer"] .theme-preview-half:first-child {
    background: #f8fafc;
}

.theme-preview-card[data-theme-value="summer"] .theme-preview-half:last-child {
    background: #0f172a;
}

.theme-preview-card[data-theme-value="summer"] .theme-preview-half:first-child .theme-preview-nav {
    background: #0f172a;
}

.theme-preview-card[data-theme-value="summer"] .theme-preview-half:first-child .theme-preview-accent {
    background: #f59e0b;
}

.theme-preview-card[data-theme-value="summer"] .theme-preview-half:last-child .theme-preview-nav {
    background: #020617;
}

.theme-preview-card[data-theme-value="summer"] .theme-preview-half:last-child .theme-preview-accent {
    background: #f59e0b;
}

/* Swatch colors — Ocean */
.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:first-child {
    background: #f0fdfa;
}

.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:last-child {
    background: #042f2e;
}

.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:first-child .theme-preview-nav {
    background: #115e59;
}

.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:first-child .theme-preview-accent {
    background: #14b8a6;
}

.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:last-child .theme-preview-nav {
    background: #134e4a;
}

.theme-preview-card[data-theme-value="ocean"] .theme-preview-half:last-child .theme-preview-accent {
    background: #2dd4bf;
}
