/**
 * XiaoDaoYa - 小道·校园心理健康筛查系统
 * Design: Organic Sanctuary - A calm, nurturing space
 * Mobile-first responsive design
 */

/* === Fonts - System fonts for fast loading === */
/* Using system fonts instead of Google Fonts for China accessibility */

/* === Skip Link (accessibility) === */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--color-primary, #7d9b76);
    color: #fff;
    text-decoration: none;
    border-radius: 0 0 8px 0;
}
.skip-link:focus {
    top: 0;
}

/* === CSS Custom Properties === */
:root {
    /* Color Palette - Organic Sanctuary */
    --color-sage: #7d9b76;
    --color-sage-light: #a8c4a2;
    --color-sage-dark: #5a7a54;
    --color-sage-pale: #e8f0e6;

    --color-terracotta: #c4846c;
    --color-terracotta-light: #daa18e;
    --color-terracotta-dark: #a66b57;
    --color-terracotta-pale: #faf0eb;

    --color-cream: #faf8f4;
    --color-cream-dark: #f0ede6;
    --color-warm-white: #fffefb;

    --color-earth: #6b5c4d;
    --color-earth-light: #8a7b6a;
    --color-earth-pale: #c4b8a9;

    /* Semantic Colors */
    --color-primary: var(--color-sage);
    --color-primary-light: var(--color-sage-light);
    --color-primary-dark: var(--color-sage-dark);
    --color-primary-pale: var(--color-sage-pale);

    --color-accent: var(--color-terracotta);
    --color-accent-light: var(--color-terracotta-light);
    --color-accent-pale: var(--color-terracotta-pale);

    --color-success: #6b9b6b;
    --color-success-pale: #e8f4e8;
    --color-warning: #c9a96c;
    --color-warning-pale: #fdf6e8;
    --color-orange: #d4896b;
    --color-orange-pale: #fef0e8;
    --color-amber: #b45309;
    --color-amber-pale: #fef3c7;
    --color-danger: #c46b6b;
    --color-danger-pale: #fdf0f0;

    /* Neutrals */
    --color-bg: var(--color-cream);
    --color-bg-elevated: var(--color-warm-white);
    --color-card: var(--color-warm-white);
    --color-text: #3d3d3d;
    --color-text-secondary: #6b6b6b;
    --color-text-muted: #808080;
    --color-border: #e5e0d8;
    --color-border-light: #f0ebe3;

    /* Shadows - Soft, natural light feel */
    --shadow-xs: 0 1px 2px rgba(107, 92, 77, 0.04);
    --shadow-sm: 0 2px 8px rgba(107, 92, 77, 0.06);
    --shadow-md: 0 4px 16px rgba(107, 92, 77, 0.08);
    --shadow-lg: 0 8px 32px rgba(107, 92, 77, 0.10);
    --shadow-xl: 0 16px 48px rgba(107, 92, 77, 0.12);
    --shadow-inner: inset 0 2px 4px rgba(107, 92, 77, 0.04);

    /* Radii - Organic, rounded */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Typography - System fonts for fast loading */
    --font-display: 'LXGW WenKai', 'Noto Serif SC', 'Songti SC', SimSun, serif;
    --font-body: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    /* Font Sizes - Fluid scaling */
    --text-xs: clamp(0.7rem, 0.65rem + 0.25vw, 0.75rem);
    --text-sm: clamp(0.8rem, 0.75rem + 0.25vw, 0.875rem);
    --text-base: clamp(0.9rem, 0.85rem + 0.25vw, 1rem);
    --text-lg: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
    --text-xl: clamp(1.15rem, 1.05rem + 0.5vw, 1.25rem);
    --text-2xl: clamp(1.35rem, 1.2rem + 0.75vw, 1.5rem);
    --text-3xl: clamp(1.6rem, 1.4rem + 1vw, 1.875rem);
    --text-4xl: clamp(1.9rem, 1.6rem + 1.5vw, 2.25rem);

    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Transitions */
    --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;

    /* Z-index scale */
    --z-base: 0;
    --z-elevated: 10;
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 500;
    --z-toast: 700;

    /* Font Weights */
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;
    --font-weight-bold: 700;

    /* Line Heights */
    --leading-tight: 1.3;
    --leading-normal: 1.5;
    --leading-relaxed: 1.8;
}

/* === Chinese Font loaded via HTML link tag === */

/* === CSS Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-body);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow-x: hidden;
}

/* Subtle grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    opacity: 0.02;
    pointer-events: none;
    z-index: -1;
}

/* === Focus Styles (Accessibility) === */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 3px;
    border-radius: var(--radius-sm);
}

/* === Global Input Transition Baseline === */
input, textarea, select {
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}

/* === Selection === */
::selection {
    background: var(--color-primary-pale);
    color: var(--color-primary-dark);
}

/* === Scrollbar Styling === */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--color-border-light);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--color-earth-pale);
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border-light);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-earth-light);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--color-earth-pale) var(--color-border-light);
}

/* === Drawer Navigation === */
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: background var(--duration-fast) var(--ease-out);
}

.menu-btn:hover {
    background: var(--color-primary-pale);
}

.menu-btn svg {
    color: var(--color-text);
}

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration-normal) var(--ease-out),
                visibility var(--duration-normal) var(--ease-out);
    z-index: 998;
}

.drawer-overlay.open {
    opacity: 1;
    visibility: visible;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    max-width: 85vw;
    height: 100%;
    background: var(--color-bg-elevated);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
    transform: translateX(100%);
    transition: transform var(--duration-normal) ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-primary);
    color: white;
}

.drawer-header .drawer-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: var(--font-weight-medium);
    display: flex;
    align-items: center;
    gap: 8px;
}

.drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: white;
    transition: background var(--duration-fast) var(--ease-out);
}

.drawer-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.drawer-user {
    padding: 20px;
    background: var(--color-cream);
    border-bottom: 1px solid var(--color-border-light);
}

.drawer-user-name {
    font-weight: var(--font-weight-semibold);
    font-size: 16px;
    color: var(--color-text);
}

.drawer-user-role {
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.drawer-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.drawer-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 15px;
    transition: background var(--duration-fast) var(--ease-out);
}

.drawer-nav a:hover {
    background: var(--color-cream);
}

.drawer-nav a.active {
    background: var(--color-primary-pale);
    color: var(--color-primary-dark);
    font-weight: var(--font-weight-medium);
}

.drawer-nav a svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    opacity: 0.7;
}

.drawer-divider {
    height: 1px;
    background: var(--color-border-light);
    margin: 8px 20px;
}

.drawer-nav a.logout {
    color: var(--color-text-muted);
}

/* Hide default nav on header (using drawer instead) */
.header .nav {
    display: none;
}

/* Body scroll lock when drawer is open */
body.drawer-open {
    overflow: hidden;
}

/* === Header === */
.header {
    background: var(--color-bg-elevated);
    border-bottom: 1px solid var(--color-border-light);
    padding: var(--space-md) var(--space-lg);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-md);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    text-decoration: none;
    color: var(--color-text);
    transition: transform var(--duration-normal) var(--ease-out);
}

.logo:hover {
    transform: translateY(-1px);
}

.logo-icon {
    font-size: 1.75rem;
    filter: drop-shadow(0 2px 4px rgba(125, 155, 118, 0.2));
    animation: gentle-float 4s ease-in-out infinite;
}

@keyframes gentle-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Navigation */
.nav {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.nav-link {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: var(--text-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
}

.nav-link:hover {
    color: var(--color-primary-dark);
    background: var(--color-primary-pale);
}

.nav-user {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

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

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

.user-info {
    color: var(--color-text);
    font-size: var(--text-sm);
    font-weight: 500;
    padding: var(--space-sm) var(--space-md);
    background: linear-gradient(135deg, var(--color-primary-pale) 0%, var(--color-cream) 100%);
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
}

/* === Main Content === */
.main {
    flex: 1;
    padding: var(--space-xl) var(--space-lg);
    animation: fade-in 0.5s var(--ease-out);
}

@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.container {
    max-width: 720px;
    margin: 0 auto;
}

/* Wide container for admin pages */
.container-wide {
    max-width: 1100px;
    margin: 0 auto;
}

/* === Footer === */
.footer {
    background: var(--color-bg-elevated);
    border-top: 1px solid var(--color-border-light);
    padding: var(--space-xl) var(--space-lg);
    text-align: center;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer p {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.footer-note {
    font-size: var(--text-xs);
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.emergency-footer {
    margin-top: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--color-border-light);
    font-size: var(--text-sm);
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

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

.emergency-footer a {
    color: var(--color-danger);
    text-decoration: none;
    font-weight: 600;
    padding: var(--space-xs) var(--space-sm);
    background: var(--color-danger-pale);
    border-radius: var(--radius-sm);
    transition: all var(--duration-fast) var(--ease-out);
}

.emergency-footer a:hover {
    background: var(--color-danger);
    color: white;
}

/* === Cards === */
.card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--color-border-light);
    position: relative;
    overflow: hidden;
    animation: card-enter 0.4s var(--ease-out);
    transition: transform var(--duration-normal) var(--ease-out),
                box-shadow var(--duration-normal) var(--ease-out);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

@keyframes card-enter {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Decorative card accents */
.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary-light), var(--color-primary), var(--color-primary-light));
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.card:hover::before {
    opacity: 0.6;
}

/* === Typography === */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    color: var(--color-text);
    line-height: 1.3;
    font-weight: 600;
}

h1 {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.02em;
}

h2 {
    font-size: var(--text-xl);
    margin-bottom: var(--space-md);
    margin-top: var(--space-xl);
    position: relative;
    padding-left: var(--space-md);
}

h2::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 70%;
    background: linear-gradient(to bottom, var(--color-primary), var(--color-primary-light));
    border-radius: var(--radius-full);
}

h2:first-child {
    margin-top: 0;
}

h3 {
    font-size: var(--text-lg);
    margin-bottom: var(--space-sm);
}

.subtitle {
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    font-size: var(--text-base);
}

.page-title {
    font-size: var(--text-3xl);
    margin-bottom: var(--space-lg);
    text-align: center;
}

/* === Progress Bar === */
.progress-bar {
    height: 6px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    margin-bottom: var(--space-md);
    overflow: hidden;
    box-shadow: var(--shadow-inner);
}

.progress {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary-light) 0%, var(--color-primary) 50%, var(--color-primary-dark) 100%);
    border-radius: var(--radius-full);
    transition: width 0.5s var(--ease-out);
    position: relative;
}

.progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.3) 50%, transparent 100%);
    animation: shimmer 2s infinite;
}

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

.step-indicator {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    margin-bottom: var(--space-lg);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 0.875rem 1.75rem;
    border-radius: var(--radius-lg);
    font-family: var(--font-body);
    font-size: var(--text-base);
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all var(--duration-normal) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    opacity: 0;
    transition: opacity var(--duration-fast);
}

.btn:hover::before {
    opacity: 1;
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    filter: grayscale(0.3);
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(125, 155, 118, 0.3);
}

.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 20px rgba(125, 155, 118, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: var(--color-cream-dark);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--color-border);
    border-color: var(--color-earth-pale);
}

.btn-accent {
    background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-terracotta-light) 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(196, 132, 108, 0.3);
}

.btn-link {
    background: none;
    color: var(--color-text-secondary);
    padding: var(--space-sm) var(--space-md);
}

.btn-link:hover {
    color: var(--color-primary-dark);
    background: var(--color-primary-pale);
}

.btn-large {
    padding: 1.125rem 2.25rem;
    font-size: var(--text-lg);
    border-radius: var(--radius-xl);
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: var(--text-sm);
    border-radius: var(--radius-md);
}

/* === Forms === */
.form {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.form-group label {
    font-weight: 500;
    font-size: var(--text-sm);
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 0.875rem 1.125rem;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-base);
    background: var(--color-bg-elevated);
    color: var(--color-text);
    transition: all var(--duration-normal) var(--ease-out);
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--color-primary-light);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-pale);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-muted);
}

.form-group small,
.form-hint {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

.form-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-md);
}

.form-message {
    font-size: var(--text-sm);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    margin-left: var(--space-sm);
}

.form-message.success {
    color: var(--color-success);
    background: var(--color-success-pale);
}

.form-message.error {
    color: var(--color-danger);
    background: var(--color-danger-pale);
}

.required {
    color: var(--color-danger);
}

/* === Account Page === */
.account-page {
    max-width: 600px;
    margin: 0 auto;
}

.account-section {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    margin-bottom: var(--space-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
}

.section-title {
    font-size: var(--text-lg);
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-light);
}

.profile-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-sm) 0;
}

.info-label {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
}

.info-value {
    font-weight: 500;
}

.account-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.account-form .form-group {
    margin-bottom: 0;
}

/* Balance Display */
.balance-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-xl);
    background: linear-gradient(135deg, var(--color-primary-pale) 0%, var(--color-cream) 100%);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-md);
}

.balance-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--space-xs);
}

.balance-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-primary-dark);
    font-family: var(--font-display);
}

.balance-note {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
}

/* Login History Table */
.login-history {
    overflow-x: auto;
}

.status-success {
    color: var(--color-success);
    font-weight: 500;
}

.status-fail {
    color: var(--color-danger);
    font-weight: 500;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
}

.badge-admin {
    background: var(--color-danger-pale);
    color: var(--color-danger);
}

.badge-counselor {
    background: var(--color-warning-pale);
    color: var(--color-warning);
}

.badge-operator {
    background: var(--color-primary-pale);
    color: var(--color-primary-dark);
}

/* === Consent Page === */
.consent-content {
    margin-bottom: var(--space-xl);
}

.consent-content section {
    margin-bottom: var(--space-lg);
}

.consent-content ul {
    margin-left: var(--space-lg);
    margin-top: var(--space-sm);
}

.consent-content li {
    margin-bottom: var(--space-xs);
    position: relative;
}

.consent-content li::marker {
    color: var(--color-primary);
}

.important-notice {
    background: linear-gradient(135deg, var(--color-danger-pale) 0%, #fff5f5 100%);
    border: 1px solid rgba(196, 107, 107, 0.3);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    position: relative;
    overflow: hidden;
}

.important-notice::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--color-danger);
}

.crisis-numbers {
    display: flex;
    gap: var(--space-md);
    margin-top: var(--space-md);
    flex-wrap: wrap;
}

.crisis-link, .crisis-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: linear-gradient(135deg, var(--color-danger) 0%, #b85c5c 100%);
    color: white;
    text-decoration: none;
    border-radius: var(--radius-lg);
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(196, 107, 107, 0.3);
    transition: all var(--duration-normal) var(--ease-out);
}

.crisis-link:hover, .crisis-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(196, 107, 107, 0.4);
}

.consent-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--color-border-light);
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    cursor: pointer;
    font-size: var(--text-base);
    padding: var(--space-md);
    background: var(--color-primary-pale);
    border-radius: var(--radius-lg);
    transition: all var(--duration-normal) var(--ease-out);
}

.checkbox-container:hover {
    background: var(--color-sage-light);
    background: rgba(125, 155, 118, 0.15);
}

.checkbox-container input[type="checkbox"] {
    width: 1.5rem;
    height: 1.5rem;
    accent-color: var(--color-primary);
    cursor: pointer;
}

/* === Legacy Screening/Risk/Result/Report styles removed ===
   These pages have been replaced by the v3 conversational workflow.
   See the v3 interview and reports_v2 components below. */

/* === Admin & Dashboard === */
.admin-page h1 {
    margin-bottom: var(--space-xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: var(--color-card);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border-light);
    transition: all var(--duration-normal) var(--ease-out);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: var(--text-4xl);
    font-weight: 700;
    color: var(--color-primary);
    font-family: var(--font-display);
}

.stat-card.warning .stat-value {
    color: var(--color-warning);
}

.stat-card.danger .stat-value {
    color: var(--color-danger);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-top: var(--space-xs);
}

.tier-stats {
    display: flex;
    gap: var(--space-md);
}

.tier-stat {
    flex: 1;
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    text-align: center;
    transition: all var(--duration-normal) var(--ease-out);
}

.tier-stat:hover {
    transform: scale(1.02);
}

.tier-stat.green { background: var(--color-success-pale); }
.tier-stat.yellow { background: var(--color-warning-pale); }
.tier-stat.orange { background: var(--color-orange-pale); }
.tier-stat.red { background: var(--color-danger-pale); }

.tier-name {
    display: block;
    font-size: var(--text-xs);
    font-weight: 600;
    letter-spacing: 0.05em;
    margin-bottom: var(--space-xs);
    text-transform: uppercase;
}

.tier-count {
    font-size: var(--text-2xl);
    font-weight: 700;
    font-family: var(--font-display);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: var(--space-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border-light);
}

.data-table th {
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    background: var(--color-cream-dark);
}

.data-table tr:hover td {
    background: var(--color-cream);
}

.empty-state, .empty-message {
    text-align: center;
    color: var(--color-text-muted);
    padding: var(--space-2xl);
    font-style: italic;
}

.admin-actions {
    margin-top: var(--space-xl);
    display: flex;
    justify-content: flex-end;
}

/* === Login Page === */
.login-card {
    max-width: 400px;
    margin: var(--space-2xl) auto;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
}

.login-logo {
    font-size: 3rem;
    margin-bottom: var(--space-md);
    animation: gentle-float 4s ease-in-out infinite;
}

/* === Export Page === */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    transition: background var(--duration-fast);
}

.checkbox-label:hover {
    background: var(--color-cream-dark);
}

/* === Tier Colors === */
.tier-green, .tier-GREEN {
    background: linear-gradient(135deg, var(--color-success) 0%, #5a8a5a 100%);
}
.tier-yellow, .tier-YELLOW {
    background: linear-gradient(135deg, var(--color-warning) 0%, #b89a5c 100%);
}
.tier-orange, .tier-ORANGE {
    background: linear-gradient(135deg, var(--color-orange) 0%, #c47a5c 100%);
}
.tier-red, .tier-RED {
    background: linear-gradient(135deg, var(--color-danger) 0%, #a85c5c 100%);
}
.tier-unknown {
    background: var(--color-text-muted);
}

/* === Utilities === */
/* Screen-reader only (visually hidden) */
.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;
}

.sr-only:focus {
    position: static;
    width: auto;
    height: auto;
    padding: var(--space-sm) var(--space-md);
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--color-primary);
    color: white;
    z-index: var(--z-toast);
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-md); }
.mt-2 { margin-top: var(--space-lg); }
.mt-3 { margin-top: var(--space-xl); }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-md); }
.mb-2 { margin-bottom: var(--space-lg); }
.mb-3 { margin-bottom: var(--space-xl); }

/* === Responsive Design === */

/* Tablet (768px - 1200px) */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .container {
        max-width: 100%;
        padding: 0 var(--space-md);
    }
}

/* Mobile (max 768px) */
@media (max-width: 768px) {
    :root {
        --space-xl: 1.5rem;
        --space-2xl: 2rem;
    }

    .header {
        padding: var(--space-md);
    }

    .header-content {
        flex-wrap: wrap;
        gap: var(--space-sm);
    }

    .nav {
        width: 100%;
        justify-content: center;
        order: 3;
        padding-top: var(--space-sm);
        border-top: 1px solid var(--color-border-light);
        margin-top: var(--space-sm);
    }

    .nav-link {
        padding: var(--space-xs) var(--space-sm);
        font-size: var(--text-xs);
    }

    .main {
        padding: var(--space-lg) var(--space-md);
    }

    .card {
        padding: var(--space-lg);
        border-radius: var(--radius-md);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }

    .stat-card {
        padding: var(--space-md);
    }

    .stat-value {
        font-size: var(--text-2xl);
    }

    .tier-stats {
        flex-wrap: wrap;
    }

    .tier-stat {
        flex: 1 1 45%;
    }

    .data-table {
        display: block;
        overflow-x: auto;
    }

    h1 {
        font-size: var(--text-2xl);
    }

    h2 {
        font-size: var(--text-lg);
    }

    .crisis-numbers {
        flex-direction: column;
    }

    .emergency-footer {
        flex-direction: column;
        gap: var(--space-sm);
    }

}

/* Small Mobile (max 480px) */
@media (max-width: 480px) {
    :root {
        --space-lg: 1rem;
        --space-xl: 1.25rem;
    }

    .main {
        padding: var(--space-md);
    }

    .card {
        padding: var(--space-md);
    }

    .logo-text {
        font-size: var(--text-lg);
    }

    .domain-item {
        padding: var(--space-md);
    }

    .account-section {
        padding: var(--space-md);
    }

    .balance-display {
        padding: var(--space-lg);
    }

    .balance-value {
        font-size: var(--text-2xl);
    }
}

/* === Print Styles === */
@media print {
    body {
        background: white;
    }

    body::before {
        display: none;
    }

    .header, .footer, .nav, .btn, .chat-input-container,
    .drawer, .drawer-overlay, .menu-btn, .skip-link {
        display: none !important;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
        break-inside: avoid;
    }

    .main {
        padding: 0;
    }

    @page {
        margin: 2cm;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: var(--text-xs);
        color: #666;
    }

    a[href^="#"]::after,
    a[href^="javascript"]::after {
        content: "";
    }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* === Dark Mode Support (Optional) === */
@media (prefers-color-scheme: dark) {
    /* Uncomment to enable dark mode
    :root {
        --color-bg: #1a1a1a;
        --color-bg-elevated: #242424;
        --color-card: #2a2a2a;
        --color-text: #e5e5e5;
        --color-text-secondary: #a0a0a0;
        --color-text-muted: #707070;
        --color-border: #3a3a3a;
        --color-border-light: #2f2f2f;
    }
    */
}

/* ============================================================
   Conversational Interview Components (v3)
   ============================================================ */

/* Quick Replies */
.quick-replies-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: var(--space-xs) 0;
    margin-left: 44px;
}

.quick-reply {
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background: var(--color-cream-dark);
    color: var(--color-text);
    font-size: var(--text-sm);
    border: 1px solid var(--color-border-light);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    white-space: nowrap;
}

.quick-reply:hover {
    background: var(--color-primary-pale);
    border-color: var(--color-primary-light);
}

.quick-reply:active {
    transform: scale(0.95);
}

/* Ultra-thin Progress Bar */
.subtle-progress {
    height: 2px;
    background: var(--color-border-light);
    overflow: hidden;
}

.subtle-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
    transition: width 1s var(--ease-out);
    border-radius: 0 1px 1px 0;
}

/* Safety Hint (layered) */
.safety-hint {
    padding: var(--space-xs) var(--space-md);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: center;
    opacity: 0;
    transition: opacity 300ms ease;
    pointer-events: none;
}

.safety-hint.visible {
    opacity: 1;
    pointer-events: auto;
}

.safety-hint.level-3 {
    color: var(--color-terracotta);
}

.safety-hint .hotline-call {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-full);
    background: var(--color-terracotta);
    color: white;
    text-decoration: none;
    font-size: var(--text-xs);
    margin-left: var(--space-sm);
}

/* Professional Report */
.diagnosis-card {
    padding: var(--space-lg);
    background: var(--color-bg-elevated);
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--color-primary);
    margin-bottom: var(--space-md);
}

.diagnosis-card .dsm-code {
    font-family: monospace;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

.confidence-bar {
    height: 8px;
    background: var(--color-border-light);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: var(--space-sm) 0;
}

.confidence-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius-full);
}

.evidence-trail {
    margin-top: var(--space-md);
}

.evidence-item {
    padding: var(--space-md);
    background: var(--color-cream);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    font-size: var(--text-sm);
}

.evidence-item summary {
    cursor: pointer;
    font-weight: 500;
    color: var(--color-text-secondary);
}

/* BPS Triangle */
.bps-triangle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-md);
    margin: var(--space-lg) 0;
}

.bps-node {
    padding: var(--space-md);
    background: var(--color-bg-elevated);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.bps-node.bio { grid-column: 1 / -1; border-top: 3px solid #5b8c85; }
.bps-node.psycho { border-top: 3px solid #8b6fb0; }
.bps-node.social { border-top: 3px solid #c49a6c; }

.bps-node h4 {
    margin: 0 0 var(--space-sm) 0;
    font-size: var(--text-sm);
    font-weight: 600;
}

.bps-node ul {
    margin: 0;
    padding-left: var(--space-lg);
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
}

/* 4P Table */
.four-p-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: var(--text-sm);
}

.four-p-table th {
    background: var(--color-cream-dark);
    padding: var(--space-sm) var(--space-md);
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--color-border);
}

.four-p-table td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: top;
}

.four-p-row .factor-type {
    font-weight: 500;
    white-space: nowrap;
    width: 100px;
}

/* Phase Transition */
.phase-transition {
    text-align: center;
    padding: var(--space-md) 0;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    letter-spacing: 1px;
}

.phase-transition::before,
.phase-transition::after {
    content: '────── ';
}

.phase-transition::after {
    content: ' ──────';
}

/* Avatar Listening Pulse */
@keyframes listening-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(93, 124, 90, 0.2); }
    50% { box-shadow: 0 0 0 6px rgba(93, 124, 90, 0); }
}

.avatar-listening-pulse {
    animation: listening-pulse 2s ease-in-out infinite;
    border-radius: 50%;
}

/* Warm Completion */
.completion-gentle {
    text-align: center;
    padding: var(--space-3xl) var(--space-xl);
    animation: gentle-appear 0.8s var(--ease-out);
}

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

.completion-gentle .completion-icon {
    font-size: 3rem;
    margin-bottom: var(--space-lg);
}

.completion-gentle .completion-text {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    line-height: 1.8;
    margin-bottom: var(--space-xl);
}

.completion-gentle .btn-view-report {
    margin-bottom: var(--space-md);
}

.completion-gentle .later-link {
    display: block;
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    text-decoration: none;
}

.completion-gentle .later-link:hover {
    color: var(--color-text-secondary);
}
