/* =====================================================
   TakeChrg App - Design System
   Dark / Light mode + brand tokens
   ===================================================== */

/* ---------- Light mode (default) ---------- */
:root {
    color-scheme: light;
    --surface-bg: #f8fafb;
    --surface-card: rgba(255,255,255,0.8);
    --surface-card-solid: #f9fafb;
    --surface-card-hover: rgba(240,253,249,0.9);
    --surface-input: rgba(255,255,255,0.9);
    --surface-nav: rgba(255,255,255,0.72);
    --surface-mobile-nav: rgba(255,255,255,0.82);
    --border-color: rgba(0,0,0,0.06);
    --border-subtle: rgba(0,0,0,0.03);
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --text-on-brand: #ffffff;
    --brand: #4ECDC4;
    --brand-dark: #44a08d;
    --brand-light: #a8e6cf;
    --brand-glow: rgba(78, 205, 196, 0.18);
    --coral: #FF6B6B;
    --gradient-brand: linear-gradient(135deg, #4ECDC4 0%, #44a08d 100%);
    --gradient-hero: linear-gradient(135deg, rgba(78,205,196,0.08) 0%, rgba(168,230,207,0.06) 50%, rgba(255,107,107,0.04) 100%);
    --shadow-card: 0 1px 2px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
    --shadow-card-hover: 0 8px 32px rgba(78,205,196,0.14), 0 2px 8px rgba(0,0,0,0.06);
    --shadow-nav: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-elevated: 0 12px 40px rgba(0,0,0,0.08);
    --na-bg: rgba(0,0,0,0.05);
    --na-border: rgba(0,0,0,0.2);
    --reactivate-bg: rgba(217,119,6,0.15);
    --reactivate-text: #b45309;
    --toggle-active: linear-gradient(135deg, #35978a 0%, #2d7a6a 100%);
}

/* ---------- Dark mode ---------- */
:root.dark {
    color-scheme: dark;
    --surface-bg: #0c1222;
    --surface-card: rgba(255,255,255,0.04);
    --surface-card-solid: #0f1629;
    --surface-card-hover: rgba(255,255,255,0.07);
    --surface-input: rgba(255,255,255,0.06);
    --surface-nav: rgba(12,18,34,0.78);
    --surface-mobile-nav: rgba(12,18,34,0.88);
    --border-color: rgba(255,255,255,0.08);
    --border-subtle: rgba(255,255,255,0.04);
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-on-brand: #ffffff;
    --brand: #4ECDC4;
    --brand-dark: #5ce0d8;
    --brand-light: #2a6f6a;
    --brand-glow: rgba(78, 205, 196, 0.12);
    --gradient-brand: linear-gradient(135deg, #4ECDC4 0%, #44a08d 100%);
    --gradient-hero: linear-gradient(135deg, rgba(78,205,196,0.06) 0%, rgba(168,230,207,0.03) 50%, rgba(255,107,107,0.02) 100%);
    --shadow-card: 0 1px 2px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15);
    --shadow-card-hover: 0 8px 32px rgba(78,205,196,0.1), 0 2px 8px rgba(0,0,0,0.2);
    --shadow-nav: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-elevated: 0 12px 40px rgba(0,0,0,0.3);
    --na-bg: rgba(255,255,255,0.06);
    --na-border: rgba(255,255,255,0.15);
    --reactivate-bg: rgba(245,158,11,0.2);
    --reactivate-text: #fbbf24;
    --toggle-active: var(--gradient-brand);
}

/* Respect system preference when no explicit class */
@media (prefers-color-scheme: dark) {
    :root:not(.light) {
        color-scheme: dark;
        --surface-bg: #0c1222;
        --surface-card: rgba(255,255,255,0.04);
        --surface-card-solid: #0f1629;
        --surface-card-hover: rgba(255,255,255,0.07);
        --surface-input: rgba(255,255,255,0.06);
        --surface-nav: rgba(12,18,34,0.78);
        --surface-mobile-nav: rgba(12,18,34,0.88);
        --border-color: rgba(255,255,255,0.08);
        --border-subtle: rgba(255,255,255,0.04);
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --text-on-brand: #ffffff;
        --brand: #4ECDC4;
        --brand-dark: #5ce0d8;
        --brand-light: #2a6f6a;
        --brand-glow: rgba(78, 205, 196, 0.12);
        --gradient-brand: linear-gradient(135deg, #4ECDC4 0%, #44a08d 100%);
        --gradient-hero: linear-gradient(135deg, rgba(78,205,196,0.06) 0%, rgba(168,230,207,0.03) 50%, rgba(255,107,107,0.02) 100%);
        --shadow-card: 0 1px 2px rgba(0,0,0,0.2), 0 4px 16px rgba(0,0,0,0.15);
        --shadow-card-hover: 0 8px 32px rgba(78,205,196,0.1), 0 2px 8px rgba(0,0,0,0.2);
        --shadow-nav: 0 1px 2px rgba(0,0,0,0.3);
        --shadow-elevated: 0 12px 40px rgba(0,0,0,0.3);
        --na-bg: rgba(255,255,255,0.06);
        --na-border: rgba(255,255,255,0.15);
        --reactivate-bg: rgba(245,158,11,0.2);
        --reactivate-text: #fbbf24;
        --toggle-active: var(--gradient-brand);
    }
}

/* ---------- Base resets ---------- */
body {
    background: var(--surface-bg);
    color: var(--text-primary);
    font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---------- Utility classes for the design system ---------- */
.tc-card {
    background: var(--surface-card);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: box-shadow 0.3s ease, transform 0.3s ease, border-color 0.3s ease;
}
.tc-card:hover {
    box-shadow: var(--shadow-card-hover);
}
.tc-card-interactive:hover {
    transform: translateY(-2px);
    border-color: var(--brand-glow);
}

.tc-input {
    background: var(--surface-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 0.875rem;
    padding: 0.8rem 1.1rem;
    width: 100%;
    font-size: 0.95rem;
    backdrop-filter: blur(8px);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.tc-input::placeholder {
    color: var(--text-muted);
}
.tc-input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow), 0 4px 12px rgba(78,205,196,0.08);
    background: var(--surface-card);
}
select.tc-input {
    background-color: var(--surface-input);
    color: var(--text-primary);
}
select.tc-input option {
    background-color: var(--surface-card-solid);
    color: var(--text-primary);
}

.tc-btn-primary {
    background: var(--gradient-brand);
    color: var(--text-on-brand);
    border: none;
    border-radius: 50px;
    padding: 0.8rem 1.75rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform 0.25s ease, box-shadow 0.25s ease, filter 0.25s ease;
    box-shadow: 0 4px 15px rgba(78,205,196,0.3);
}
.tc-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(78,205,196,0.4);
    filter: brightness(1.05);
}
.tc-btn-primary:active {
    transform: translateY(0);
}
.tc-btn-primary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

.tc-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 0.6rem 1.25rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.25s ease;
}
.tc-btn-ghost:hover {
    background: var(--brand-glow);
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 2px 8px rgba(78,205,196,0.12);
}

.tc-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.025em;
    text-transform: uppercase;
}

.tc-text-brand {
    color: var(--brand);
}

.tc-bg-brand {
    background: var(--gradient-brand);
}

/* ---------- Navigation ---------- */
.tc-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface-nav);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
    box-shadow: var(--shadow-nav);
}

.tc-mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--surface-mobile-nav);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(20px) saturate(1.4);
    -webkit-backdrop-filter: blur(20px) saturate(1.4);
}

.tc-nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: all 0.25s ease;
    text-decoration: none;
}
.tc-nav-link:hover {
    background: var(--brand-glow);
    color: var(--brand);
}
.tc-nav-link.active {
    background: var(--gradient-brand);
    color: var(--text-on-brand);
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(78,205,196,0.3);
}

.tc-mobile-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    color: var(--text-muted);
    font-size: 0.625rem;
    font-weight: 500;
    padding: 0.25rem 0;
    transition: color 0.2s ease, transform 0.2s ease;
    text-decoration: none;
}
.tc-mobile-link:hover,
.tc-mobile-link.active {
    color: var(--brand);
}
.tc-mobile-link.active {
    transform: scale(1.08);
}

/* Theme toggle */
.tc-theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--surface-card);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.25s ease;
}
.tc-theme-toggle:hover {
    border-color: var(--brand);
    color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}

/* Checkbox for tasks */
.tc-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.65rem;
    height: 1.65rem;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}
.tc-checkbox:hover {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-glow);
}
.tc-checkbox.checked {
    background: var(--gradient-brand);
    border-color: transparent;
    color: white;
    box-shadow: 0 2px 8px rgba(78,205,196,0.35);
    transform: scale(1.05);
}

/* Progress ring */
.tc-progress-ring {
    --progress: 0;
    transform: rotate(-90deg);
}

/* Stat card */
.tc-stat {
    text-align: center;
    padding: 1.5rem 1.25rem;
    position: relative;
    overflow: hidden;
}
.tc-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-brand);
    border-radius: 3px 3px 0 0;
    opacity: 0.6;
}
.tc-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--brand);
    line-height: 1.2;
    letter-spacing: -0.02em;
}
.tc-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Page headings */
.tc-page-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.75rem, 4vw, 2.75rem);
    color: var(--text-primary);
    line-height: 1.15;
    letter-spacing: -0.02em;
}

/* Page hero section */
.tc-page-hero {
    position: relative;
    padding: 2.5rem 1rem 2rem;
    text-align: center;
    overflow: hidden;
}
.tc-page-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-hero);
    border-radius: 0 0 2rem 2rem;
    z-index: -1;
}
.tc-page-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

/* Section heading */
.tc-section-heading {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}
.tc-section-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    background: var(--brand-glow);
    color: var(--brand);
    flex-shrink: 0;
}

/* Item row */
.tc-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border-radius: 1rem;
    border: 1.5px solid var(--border-color);
    background: var(--surface-card);
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    transition: all 0.25s ease;
    cursor: pointer;
}
@media (min-width: 640px) {
    .tc-item {
        gap: 1rem;
        padding: 1rem 1.25rem;
    }
}
.tc-item:hover {
    background: var(--surface-card-hover);
    border-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.tc-item.selected {
    border-color: var(--brand);
    background: var(--brand-glow);
    box-shadow: 0 0 0 3px rgba(78,205,196,0.08);
}
.tc-item.completed {
    opacity: 0.55;
}
.tc-item.dragging {
    opacity: 0.4;
}
.tc-item.drag-over {
    border-color: var(--brand);
    background: var(--brand-glow);
}

/* Drag handle */
.tc-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    border-radius: 0.375rem;
    opacity: 0.3;
    transition: opacity 0.2s ease;
}
.tc-item:hover .tc-drag-handle {
    opacity: 0.7;
}

/* Heat map cells */
.tc-heat-done {
    width: 1.5rem; height: 1.5rem;
    border-radius: 0.375rem;
    background: var(--brand);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tc-heat-done:hover { transform: scale(1.25); box-shadow: 0 2px 8px rgba(78,205,196,0.4); }
.tc-heat-miss {
    width: 1.5rem; height: 1.5rem;
    border-radius: 0.375rem;
    background: var(--coral);
    opacity: 0.65;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.tc-heat-miss:hover { transform: scale(1.25); box-shadow: 0 2px 8px rgba(255,107,107,0.3); }
.tc-heat-na {
    width: 1.5rem; height: 1.5rem;
    border-radius: 0.375rem;
    background: var(--border-color);
}

/* Heat map intensity levels (calendar) */
.tc-heat-empty { background: var(--surface-hover, var(--border-color)); opacity: 0.4; }
.tc-heat-0    { background: var(--brand); opacity: 0.12; }
.tc-heat-1    { background: var(--brand); opacity: 0.28; }
.tc-heat-2    { background: var(--brand); opacity: 0.5;  }
.tc-heat-3    { background: var(--brand); opacity: 0.75; }
.tc-heat-4    { background: var(--brand); opacity: 1;    }

/* ---------- Entrance animations ---------- */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.tc-animate-in {
    animation: fadeInUp 0.4s ease-out both;
}
.tc-animate-in-delay-1 { animation-delay: 0.06s; }
.tc-animate-in-delay-2 { animation-delay: 0.12s; }
.tc-animate-in-delay-3 { animation-delay: 0.18s; }
.tc-animate-in-delay-4 { animation-delay: 0.24s; }

/* ---------- Decorative gradient orb ---------- */
.tc-gradient-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    pointer-events: none;
    z-index: -1;
}

/* Form validation */
.valid.modified:not([type=checkbox]) {
    outline: none;
}
.invalid {
    outline: 1px solid var(--coral);
}
.validation-message {
    color: var(--coral);
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* Blazor error boundary */
.blazor-error-boundary {
    background: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}
.blazor-error-boundary::after {
    content: "An error has occurred.";
}
.darker-border-checkbox.form-check-input {
    border-color: #929292;
}
