/* =====================================================
 *  TTC DESIGN TOKENS — Unified Design System v1.0
 *  Single source of truth for ALL visual constants.
 *  This file MUST be loaded BEFORE all other TTC CSS.
 * ===================================================== */

/* ── FONTS ── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

:root {
    /* ── Typography ── */
    --ttc-font-heading: 'Outfit', sans-serif;
    --ttc-font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --ttc-font-mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', monospace;

    /* Font Sizes — Modular Scale (1.25 ratio) */
    --ttc-fs-xs: 0.6875rem;   /* 11px */
    --ttc-fs-sm: 0.8125rem;   /* 13px */
    --ttc-fs-base: 0.9375rem; /* 15px */
    --ttc-fs-md: 1.125rem;    /* 18px */
    --ttc-fs-lg: 1.25rem;     /* 20px */
    --ttc-fs-xl: 1.5rem;      /* 24px */
    --ttc-fs-2xl: 2rem;       /* 32px */
    --ttc-fs-3xl: 2.5rem;     /* 40px */

    /* Font Weights */
    --ttc-fw-normal: 400;
    --ttc-fw-medium: 500;
    --ttc-fw-semibold: 600;
    --ttc-fw-bold: 700;
    --ttc-fw-extrabold: 800;

    /* ── Spacing Scale ── */
    --ttc-space-2xs: 4px;
    --ttc-space-xs: 8px;
    --ttc-space-sm: 12px;
    --ttc-space-md: 16px;
    --ttc-space-lg: 24px;
    --ttc-space-xl: 32px;
    --ttc-space-2xl: 48px;
    --ttc-space-3xl: 64px;

    /* ── Border Radius Scale ── */
    --ttc-radius-sm: 8px;
    --ttc-radius-md: 12px;
    --ttc-radius-lg: 16px;
    --ttc-radius-xl: 20px;
    --ttc-radius-2xl: 24px;
    --ttc-radius-pill: 999px;
    --ttc-radius-circle: 50%;

    /* Legacy alias */
    --ttc-radius: var(--ttc-radius-2xl);

    /* ── Transitions ── */
    --ttc-ease-out: cubic-bezier(0.4, 0, 0.2, 1);
    --ttc-ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ttc-transition-fast: all 0.15s var(--ttc-ease-out);
    --ttc-transition: all 0.3s var(--ttc-ease-out);
    --ttc-transition-slow: all 0.5s var(--ttc-ease-out);

    /* ── Shadows ── */
    --ttc-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --ttc-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --ttc-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --ttc-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --ttc-shadow-glow: 0 0 20px rgba(var(--ttc-primary-rgb), 0.15);

    /* Legacy alias */
    --ttc-shadow: var(--ttc-shadow-xl);

    /* ── Glassmorphism ── */
    --ttc-glass-blur: blur(12px);

    /* ── Semantic Colors (Static) ── */
    --ttc-success: #10b981;
    --ttc-success-rgb: 16, 185, 129;
    --ttc-warning: #f59e0b;
    --ttc-warning-rgb: 245, 158, 11;
    --ttc-danger: #ef4444;
    --ttc-danger-rgb: 239, 68, 68;
    --ttc-info: #3b82f6;
    --ttc-info-rgb: 59, 130, 246;

    /* ── Z-Index Scale ── */
    --ttc-z-dropdown: 100;
    --ttc-z-sticky: 200;
    --ttc-z-modal-backdrop: 900;
    --ttc-z-modal: 1000;
    --ttc-z-toast: 1100;
    --ttc-z-tooltip: 1200;
}


/* =====================================================
 *  DARK MODE (Platform Default)
 * ===================================================== */
:root,
.ttc-mode-dark,
.ttc-theme-dark {
    --ttc-bg-page: #0f172a;
    --ttc-card-bg: rgba(255, 255, 255, 0.03);
    --ttc-card-bg-solid: #1e293b;
    --ttc-glass-border: rgba(255, 255, 255, 0.08);
    --ttc-text-main: #f8fafc;
    --ttc-text-muted: #94a3b8;
    --ttc-text-inverse: #1e293b;
    --ttc-border: #334155;
    --ttc-border-subtle: rgba(255, 255, 255, 0.05);
    --ttc-grad-surface: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01));
    --ttc-input-bg: rgba(0, 0, 0, 0.2);
    --ttc-hover-bg: rgba(255, 255, 255, 0.05);
    --ttc-skeleton-base: rgba(255, 255, 255, 0.04);
    --ttc-skeleton-shine: rgba(255, 255, 255, 0.08);
}


/* =====================================================
 *  LIGHT MODE
 * ===================================================== */
.ttc-mode-light,
.ttc-theme-light {
    --ttc-bg-page: #f8fafc;
    --ttc-card-bg: #ffffff;
    --ttc-card-bg-solid: #ffffff;
    --ttc-glass-border: #e2e8f0;
    --ttc-text-main: #1e293b;
    --ttc-text-muted: #64748b;
    --ttc-text-inverse: #f8fafc;
    --ttc-border: #e2e8f0;
    --ttc-border-subtle: #f1f5f9;
    --ttc-grad-surface: linear-gradient(135deg, #f1f5f9, #ffffff);
    --ttc-input-bg: #f9fafb;
    --ttc-hover-bg: rgba(0, 0, 0, 0.03);
    --ttc-shadow-xl: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --ttc-skeleton-base: rgba(0, 0, 0, 0.04);
    --ttc-skeleton-shine: rgba(0, 0, 0, 0.08);
}


/* =====================================================
 *  ROLE-BASED ACCENT OVERRIDES
 *  Applied via body class or container class
 * ===================================================== */
.ttc-role-teacher {
    --ttc-role-accent: #10b981;
    --ttc-role-accent-rgb: 16, 185, 129;
}

.ttc-role-parent {
    --ttc-role-accent: #f59e0b;
    --ttc-role-accent-rgb: 245, 158, 11;
}

.ttc-role-school {
    --ttc-role-accent: #06b6d4;
    --ttc-role-accent-rgb: 6, 182, 212;
}

.ttc-role-institution {
    --ttc-role-accent: #8b5cf6;
    --ttc-role-accent-rgb: 139, 92, 246;
}


/* =====================================================
 *  UNIFIED BUTTON SYSTEM
 *  Replaces: .ttc-btn-primary, .ttc-btn-wow, .ttc-reg-btn,
 *  .ttc-purchase-btn, .ttc-cta-btn, .ttc-button-primary
 * ===================================================== */

/* Base Button */
.ttc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--ttc-space-xs);
    padding: var(--ttc-space-sm) var(--ttc-space-lg);
    border-radius: var(--ttc-radius-md);
    font-family: var(--ttc-font-body);
    font-size: var(--ttc-fs-sm);
    font-weight: var(--ttc-fw-semibold);
    line-height: 1;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--ttc-transition-fast);
    white-space: nowrap;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
}

.ttc-btn:focus-visible {
    box-shadow: 0 0 0 3px rgba(var(--ttc-primary-rgb, 99, 102, 241), 0.3);
}

.ttc-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary — Gradient CTA */
.ttc-btn--primary {
    background: var(--ttc-grad-main, linear-gradient(135deg, var(--ttc-primary, #6366f1), var(--ttc-secondary, #8b5cf6)));
    color: #fff;
    box-shadow: 0 4px 14px -3px rgba(var(--ttc-primary-rgb, 99, 102, 241), 0.4);
}

.ttc-btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px rgba(var(--ttc-primary-rgb, 99, 102, 241), 0.5);
    filter: brightness(1.08);
    color: #fff;
}

.ttc-btn--primary:active {
    transform: translateY(0);
}

/* Secondary — Outlined / Ghost */
.ttc-btn--secondary {
    background: var(--ttc-card-bg);
    color: var(--ttc-text-main);
    border-color: var(--ttc-glass-border);
}

.ttc-btn--secondary:hover {
    background: var(--ttc-hover-bg);
    border-color: var(--ttc-primary, #6366f1);
    transform: translateY(-1px);
    color: var(--ttc-text-main);
}

/* Ghost — No border, minimal */
.ttc-btn--ghost {
    background: transparent;
    color: var(--ttc-text-muted);
    border-color: transparent;
}

.ttc-btn--ghost:hover {
    background: var(--ttc-hover-bg);
    color: var(--ttc-text-main);
}

/* Danger — Destructive */
.ttc-btn--danger {
    background: rgba(var(--ttc-danger-rgb), 0.1);
    color: var(--ttc-danger);
    border-color: rgba(var(--ttc-danger-rgb), 0.2);
}

.ttc-btn--danger:hover {
    background: var(--ttc-danger);
    color: #fff;
    transform: translateY(-1px);
}

/* Success — Positive action */
.ttc-btn--success {
    background: var(--ttc-success);
    color: #fff;
    box-shadow: 0 4px 14px -3px rgba(var(--ttc-success-rgb), 0.4);
}

.ttc-btn--success:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    color: #fff;
}

/* Size Variants */
.ttc-btn--sm {
    padding: var(--ttc-space-xs) var(--ttc-space-md);
    font-size: var(--ttc-fs-xs);
    border-radius: var(--ttc-radius-sm);
}

.ttc-btn--lg {
    padding: var(--ttc-space-md) var(--ttc-space-xl);
    font-size: var(--ttc-fs-base);
    border-radius: var(--ttc-radius-lg);
}

.ttc-btn--full {
    width: 100%;
}

.ttc-btn--pill {
    border-radius: var(--ttc-radius-pill);
}


/* =====================================================
 *  UNIFIED INPUT SYSTEM
 * ===================================================== */
.ttc-input {
    width: 100%;
    padding: var(--ttc-space-sm) var(--ttc-space-md);
    background: var(--ttc-input-bg);
    border: 1px solid var(--ttc-glass-border);
    border-radius: var(--ttc-radius-sm);
    color: var(--ttc-text-main);
    font-family: var(--ttc-font-body);
    font-size: var(--ttc-fs-sm);
    transition: var(--ttc-transition-fast);
    outline: none;
    box-sizing: border-box;
}

.ttc-input:focus {
    border-color: var(--ttc-primary, #6366f1);
    box-shadow: 0 0 0 3px rgba(var(--ttc-primary-rgb, 99, 102, 241), 0.1);
}

.ttc-input::placeholder {
    color: var(--ttc-text-muted);
    opacity: 0.7;
}

.ttc-input--error {
    border-color: var(--ttc-danger);
}

.ttc-label {
    display: block;
    font-size: var(--ttc-fs-xs);
    font-weight: var(--ttc-fw-bold);
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ttc-text-muted);
    margin-bottom: var(--ttc-space-xs);
}


/* =====================================================
 *  TOAST NOTIFICATION SYSTEM
 *  Replaces all alert() calls
 * ===================================================== */
.ttc-toast-container {
    position: fixed;
    top: var(--ttc-space-lg);
    right: var(--ttc-space-lg);
    z-index: var(--ttc-z-toast);
    display: flex;
    flex-direction: column;
    gap: var(--ttc-space-sm);
    pointer-events: none;
}

.ttc-toast {
    display: flex;
    align-items: center;
    gap: var(--ttc-space-sm);
    padding: var(--ttc-space-md) var(--ttc-space-lg);
    background: var(--ttc-card-bg-solid);
    border: 1px solid var(--ttc-glass-border);
    border-radius: var(--ttc-radius-md);
    box-shadow: var(--ttc-shadow-lg);
    color: var(--ttc-text-main);
    font-family: var(--ttc-font-body);
    font-size: var(--ttc-fs-sm);
    font-weight: var(--ttc-fw-medium);
    pointer-events: all;
    animation: ttcToastIn 0.35s var(--ttc-ease-spring) forwards;
    max-width: 400px;
    min-width: 280px;
    -webkit-backdrop-filter: var(--ttc-glass-blur);
    backdrop-filter: var(--ttc-glass-blur);
}

.ttc-toast--success { border-left: 4px solid var(--ttc-success); }
.ttc-toast--error   { border-left: 4px solid var(--ttc-danger); }
.ttc-toast--warning { border-left: 4px solid var(--ttc-warning); }
.ttc-toast--info    { border-left: 4px solid var(--ttc-info); }

.ttc-toast__icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.ttc-toast__message {
    flex: 1;
    line-height: 1.4;
}

.ttc-toast__close {
    background: none;
    border: none;
    color: var(--ttc-text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.ttc-toast__close:hover {
    opacity: 1;
}

.ttc-toast--exit {
    animation: ttcToastOut 0.25s var(--ttc-ease-out) forwards;
}

@keyframes ttcToastIn {
    from { opacity: 0; transform: translateX(100%); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes ttcToastOut {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(100%); }
}


/* =====================================================
 *  SKELETON LOADING ANIMATIONS
 * ===================================================== */
.ttc-skeleton {
    background: var(--ttc-skeleton-base);
    border-radius: var(--ttc-radius-sm);
    position: relative;
    overflow: hidden;
}

.ttc-skeleton::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--ttc-skeleton-shine) 50%,
        transparent 100%
    );
    animation: ttcShimmer 1.5s infinite;
}

.ttc-skeleton--text {
    height: 14px;
    width: 80%;
    margin-bottom: var(--ttc-space-xs);
}

.ttc-skeleton--title {
    height: 24px;
    width: 60%;
    margin-bottom: var(--ttc-space-md);
}

.ttc-skeleton--avatar {
    width: 48px;
    height: 48px;
    border-radius: var(--ttc-radius-circle);
}

.ttc-skeleton--card {
    height: 120px;
    width: 100%;
    border-radius: var(--ttc-radius-lg);
}

.ttc-skeleton--stat {
    height: 80px;
    width: 100%;
    border-radius: var(--ttc-radius-xl);
}

@keyframes ttcShimmer {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}


/* =====================================================
 *  EMPTY STATE COMPONENT
 * ===================================================== */
.ttc-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--ttc-space-3xl) var(--ttc-space-lg);
    text-align: center;
    color: var(--ttc-text-muted);
}

.ttc-empty-state__icon {
    font-size: 3rem;
    margin-bottom: var(--ttc-space-md);
    opacity: 0.5;
}

.ttc-empty-state__title {
    font-family: var(--ttc-font-heading);
    font-size: var(--ttc-fs-md);
    font-weight: var(--ttc-fw-bold);
    color: var(--ttc-text-main);
    margin-bottom: var(--ttc-space-xs);
}

.ttc-empty-state__text {
    font-size: var(--ttc-fs-sm);
    max-width: 320px;
    line-height: 1.6;
    margin-bottom: var(--ttc-space-lg);
}


/* =====================================================
 *  STATUS BADGES (Unified)
 * ===================================================== */
.ttc-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--ttc-radius-pill);
    font-size: var(--ttc-fs-xs);
    font-weight: var(--ttc-fw-bold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
}

.ttc-badge--success {
    background: rgba(var(--ttc-success-rgb), 0.12);
    color: var(--ttc-success);
}

.ttc-badge--warning {
    background: rgba(var(--ttc-warning-rgb), 0.12);
    color: var(--ttc-warning);
}

.ttc-badge--danger {
    background: rgba(var(--ttc-danger-rgb), 0.12);
    color: var(--ttc-danger);
}

.ttc-badge--info {
    background: rgba(var(--ttc-info-rgb), 0.12);
    color: var(--ttc-info);
}

.ttc-badge--neutral {
    background: var(--ttc-border-subtle);
    color: var(--ttc-text-muted);
}


/* =====================================================
 *  MICRO-ANIMATIONS
 * ===================================================== */
@keyframes ttcFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ttcFadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes ttcScaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes ttcPulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

@keyframes ttcBounceIn {
    0%   { opacity: 0; transform: scale(0.3); }
    50%  { transform: scale(1.05); }
    70%  { transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

.ttc-animate-fade-in    { animation: ttcFadeIn 0.35s var(--ttc-ease-out) forwards; }
.ttc-animate-fade-in-up { animation: ttcFadeInUp 0.5s var(--ttc-ease-out) forwards; }
.ttc-animate-scale-in   { animation: ttcScaleIn 0.3s var(--ttc-ease-spring) forwards; }
.ttc-animate-pulse      { animation: ttcPulse 2s var(--ttc-ease-out) infinite; }


/* =====================================================
 *  ACCESSIBILITY HELPERS
 * ===================================================== */
.ttc-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;
}

/* Focus-visible ring for all interactive elements */
*:focus-visible {
    outline: 2px solid var(--ttc-primary, #6366f1);
    outline-offset: 2px;
}

/* Respect user's reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* =====================================================
 *  RESPONSIVE BREAKPOINTS (Utility Classes)
 * ===================================================== */
@media (max-width: 768px) {
    :root {
        --ttc-fs-2xl: 1.5rem;
        --ttc-fs-3xl: 2rem;
        --ttc-space-2xl: 32px;
        --ttc-space-3xl: 48px;
    }
}

@media (max-width: 480px) {
    :root {
        --ttc-fs-xl: 1.25rem;
        --ttc-fs-2xl: 1.375rem;
        --ttc-fs-3xl: 1.75rem;
        --ttc-space-lg: 16px;
        --ttc-space-xl: 24px;
    }
}
