/**
 * NHFTB Design System CSS
 * Core styles using design tokens
 */

/* CSS Variables from Design Tokens */
:root {
    /* Default Theme */
    --theme-background: #ffffff;
    --theme-surface: #f8fafc;
    --theme-text: #0f172a;
    --theme-textSecondary: #64748b;
    --theme-border: #e2e8f0;
    
    /* Text Scale */
    --text-scale: 1;
    
    /* Primary Font */
    --font-primary: var(--font-sans);
    
    /* Animation Duration */
    --animation-duration: 300ms;
}

/* No Animations */
.no-animations * {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}

/* Base Styles */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-primary);
    font-size: calc(1rem * var(--text-scale));
    line-height: 1.6;
    color: var(--theme-text);
    background-color: var(--theme-background);
    transition: background-color var(--animation-duration) ease,
                color var(--animation-duration) ease;
}

/* Typography Scale */
.text-xs { font-size: calc(0.75rem * var(--text-scale)); }
.text-sm { font-size: calc(0.875rem * var(--text-scale)); }
.text-base { font-size: calc(1rem * var(--text-scale)); }
.text-lg { font-size: calc(1.125rem * var(--text-scale)); }
.text-xl { font-size: calc(1.25rem * var(--text-scale)); }
.text-2xl { font-size: calc(1.5rem * var(--text-scale)); }
.text-3xl { font-size: calc(1.875rem * var(--text-scale)); }
.text-4xl { font-size: calc(2.25rem * var(--text-scale)); }
.text-5xl { font-size: calc(3rem * var(--text-scale)); }

/* Component Library */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-2) var(--spacing-4);
    font-size: calc(1rem * var(--text-scale));
    font-weight: 500;
    line-height: 1.5;
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--animation-duration) ease;
    position: relative;
    overflow: hidden;
}

.btn:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--neutral-100);
}

.btn-ghost {
    background: transparent;
    color: var(--theme-text);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--theme-surface);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: var(--spacing-1) var(--spacing-3);
    font-size: calc(0.875rem * var(--text-scale));
}

.btn-lg {
    padding: var(--spacing-3) var(--spacing-6);
    font-size: calc(1.125rem * var(--text-scale));
}

/* Cards */
.card {
    background: var(--theme-surface);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-6);
    box-shadow: var(--shadow-base);
    transition: all var(--animation-duration) ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-glass);
}

/* Alerts */
.alert {
    padding: var(--spacing-4);
    border-radius: var(--radius-lg);
    margin-bottom: var(--spacing-4);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-3);
}

.alert-info {
    background: var(--info-50);
    color: var(--info-900);
    border: 1px solid var(--info-200);
}

.alert-success {
    background: var(--success-50);
    color: var(--success-900);
    border: 1px solid var(--success-200);
}

.alert-warning {
    background: var(--warning-50);
    color: var(--warning-900);
    border: 1px solid var(--warning-200);
}

.alert-error {
    background: var(--error-50);
    color: var(--error-900);
    border: 1px solid var(--error-200);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--animation-duration) ease;
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--theme-background);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-2xl);
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform var(--animation-duration) ease;
}

.modal-backdrop.active .modal {
    transform: scale(1);
}

.modal-header {
    padding: var(--spacing-6);
    border-bottom: 1px solid var(--theme-border);
}

.modal-body {
    padding: var(--spacing-6);
}

.modal-footer {
    padding: var(--spacing-6);
    border-top: 1px solid var(--theme-border);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-3);
}

/* Steppers */
.stepper {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-8);
}

.stepper-item {
    flex: 1;
    text-align: center;
    position: relative;
}

.stepper-item::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 50%;
    right: -50%;
    height: 2px;
    background: var(--theme-border);
    z-index: -1;
}

.stepper-item:last-child::before {
    display: none;
}

.stepper-item.active::before {
    background: var(--primary-500);
}

.stepper-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--theme-surface);
    border: 2px solid var(--theme-border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: var(--spacing-2);
}

.stepper-item.active .stepper-number {
    background: var(--primary-500);
    color: white;
    border-color: var(--primary-500);
}

.stepper-item.completed .stepper-number {
    background: var(--success-500);
    color: white;
    border-color: var(--success-500);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--theme-border);
    margin-bottom: var(--spacing-6);
}

.tab {
    padding: var(--spacing-3) var(--spacing-6);
    border: none;
    background: none;
    color: var(--theme-textSecondary);
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: color var(--animation-duration) ease;
}

.tab:hover {
    color: var(--theme-text);
}

.tab.active {
    color: var(--primary-600);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-600);
}

/* Form Controls */
.form-group {
    margin-bottom: var(--spacing-6);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-2);
    font-weight: 500;
    color: var(--theme-text);
}

.form-control {
    width: 100%;
    padding: var(--spacing-3) var(--spacing-4);
    font-size: calc(1rem * var(--text-scale));
    line-height: 1.5;
    color: var(--theme-text);
    background: var(--theme-background);
    border: 1px solid var(--theme-border);
    border-radius: var(--radius-lg);
    transition: all var(--animation-duration) ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(var(--primary-500-rgb), 0.1);
}

.form-control:disabled {
    background: var(--theme-surface);
    opacity: 0.7;
    cursor: not-allowed;
}

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

/* Focus Indicators */
*:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Skip Links */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-600);
    color: white;
    padding: var(--spacing-2) var(--spacing-4);
    text-decoration: none;
    border-radius: var(--radius-md);
    z-index: 100;
}

.skip-link:focus {
    top: var(--spacing-4);
}

/* Theme-specific styles */
.theme-dark {
    color-scheme: dark;
}

.theme-dark .card {
    background: var(--theme-surface);
    border-color: var(--theme-border);
}

.theme-highContrast {
    /* High contrast overrides */
}

.theme-highContrast *:focus {
    outline: 3px solid currentColor;
    outline-offset: 2px;
}

.theme-dyslexiaFriendly {
    letter-spacing: 0.05em;
    word-spacing: 0.1em;
    line-height: 1.8;
}

/* Responsive utilities */
@media (max-width: 768px) {
    .hide-mobile { display: none !important; }
}

@media (min-width: 769px) {
    .hide-desktop { display: none !important; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fadeIn {
    animation: fadeIn var(--animation-duration) ease;
}

.animate-slideInUp {
    animation: slideInUp var(--animation-duration) ease;
}