/* Premium Design System - 勵德線上試卷管理系統極簡科技蘋果風 */

:root {
    color-scheme: light; /* 宣告瀏覽器此網站為原生淺色主題，防範強制暗色反轉 */
    --font-primary: 'Outfit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    /* 極簡科技蘋果風色彩規格 (Warm Oatmeal Canvas & Clean Crisp Elements) */
    --bg-dark: #FDFBF7;           /* 全球畫布底色：燕麥暖米白 */
    --bg-card: #ffffff;           /* 卡片底色：純白巧克力 */
    --bg-sidebar: #ffffff;        /* 側邊欄底色：蘋果白 */
    --border-color: #f1f5f9;      /* 極細緻銀灰邊框 */
    --border-hover: #cbd5e1;      /* hover 時的邊框 */
    
    /* 核心科技藍與綠色 */
    --primary: #4f46e5;           /* 科技藍 (indigo-600) */
    --primary-hover: #4338ca;
    --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    
    --accent: #06b6d4;            /* 科技靛青 (cyan-600) */
    --accent-gradient: linear-gradient(135deg, #0891b2 0%, #06b6d4 100%);
    
    /* 低調溫和粉彩 rounded 狀態 Badge 色系 */
    --success: #059669;           /* 翡翠綠 (emerald-600) */
    --success-bg: #ecfdf5;        /* 淺粉綠 */
    --warning: #d97706;           /* 琥珀黃 (amber-600) */
    --warning-bg: #fef3c7;        /* 淺粉黃 */
    --danger: #dc2626;            /* 珊瑚紅 (red-600) */
    --danger-bg: #fef2f2;         /* 淺粉紅 */
    
    /* 100% 飽和高對比深碳灰字體 (防禦型字體設計) */
    --text-primary: #1e293b;      /* 深碳灰 (slate-800) */
    --text-secondary: #475569;    /* 中碳灰 (slate-600) */
    --text-muted: #94a3b8;        /* 輕碳灰 (slate-400) */
    
    /* 羽毛軟陰影 */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.02);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.015);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.04);
    
    --sidebar-width: 260px;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 15px;
    line-height: 1.6;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-dark);
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* Layout Framework */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling (Clean Apple White) */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--primary-gradient);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.25rem;
}

.brand-name {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.sidebar-menu {
    padding: 24px 16px;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
    overflow-y: auto;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: var(--transition-fast);
}

.menu-item a:hover {
    background-color: #f8fafc;
    color: var(--text-primary);
}

.menu-item.active a {
    background: #f5f3ff !important;
    color: var(--primary) !important;
    font-weight: 600;
    box-shadow: none !important;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    background-color: #f8fafc;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--text-primary);
    border: 2px solid var(--primary);
}

.user-info {
    flex-grow: 1;
    min-width: 0;
}

.user-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Main Content Area */
.app-container {
    flex-grow: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: var(--transition-smooth);
}

.app-header {
    height: 70px;
    border-bottom: 1px solid var(--border-color);
    background-color: rgba(253, 251, 247, 0.8);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.app-main {
    flex-grow: 1;
    padding: 32px;
}

/* Footer */
.app-footer {
    padding: 20px 32px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Responsive Hide for Sidebar */
@media (max-width: 1024px) {
    .app-sidebar {
        transform: translateX(-100%);
    }
    .app-container {
        margin-left: 0;
    }
    .app-sidebar.show {
        transform: translateX(0);
    }
}

/* Cards Design (Crisp Minimalist Card) */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow-md);
    transition: border var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
}

.glass-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.glass-card.no-hover:hover {
    border-color: var(--border-color);
    box-shadow: var(--shadow-md);
    transform: none;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* 極致高對比高質感淺色輸入框防禦 */
input, select, textarea,
input[type="text"], input[type="password"], input[type="date"], input[type="datetime-local"], input[type="number"], input[type="search"], input[type="email"],
.form-control, .form-select {
    width: 100%;
    padding: 12px 16px;
    background-color: #ffffff !important; /* 強制使用純白色背景 */
    border: 1px solid #cbd5e1 !important;
    border-radius: 12px;
    color: #1e293b !important; /* 強制使用 100% 飽和深碳灰字體 */
    -webkit-text-fill-color: #1e293b !important;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    color-scheme: light !important; /* 強制渲染為原生淺色，防外掛反轉 */
    transition: var(--transition-fast);
}

/* 使用中 (focus/active) 的呼吸防禦 */
input:focus, select:focus, textarea:focus,
input[type="text"]:focus, input[type="password"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus, input[type="number"]:focus, input[type="search"]:focus, input[type="email"]:focus,
.form-control:focus, .form-select:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    background-color: #ffffff !important;
    color: #1e293b !important;
    -webkit-text-fill-color: #1e293b !important;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.12) !important;
    color-scheme: light !important;
}

/* Placeholder */
::placeholder,
.form-control::placeholder {
    color: var(--text-muted) !important;
    -webkit-text-fill-color: var(--text-muted) !important;
    opacity: 0.7;
}

/* Chrome Autofill 防禦 */
input:-webkit-autofill,
input:-webkit-autofill:hover, 
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
    -webkit-text-fill-color: #1e293b !important;
    -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important; /* 強制純白底色 */
    color-scheme: light !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Premium Buttons */
.btn-premium {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary-gradient {
    background: var(--primary-gradient);
    color: white !important;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.btn-primary-gradient:hover {
    background: linear-gradient(135deg, #4338ca 0%, #4f46e5 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.25);
}

.btn-primary-gradient:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary-outline {
    background: transparent;
    border: 1px solid #cbd5e1;
    color: var(--text-secondary) !important;
}

.btn-secondary-outline:hover {
    border-color: var(--text-primary);
    color: var(--text-primary) !important;
    background-color: #f8fafc;
}

.btn-danger-premium {
    background: var(--danger-bg);
    color: var(--danger) !important;
    border: 1px solid rgba(220, 38, 38, 0.1);
}

.btn-danger-premium:hover {
    background: var(--danger);
    color: white !important;
}

/* Data Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.custom-table th {
    background-color: #f8fafc;
    padding: 16px;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.custom-table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    font-size: 0.95rem;
    vertical-align: middle;
}

.custom-table tr:last-child td {
    border-bottom: none;
}

.custom-table tr:hover td {
    background-color: #f8fafc/50;
}

/* Status Badges */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 30px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-pill.success {
    background-color: var(--success-bg);
    color: var(--success);
    border: 1px solid rgba(5, 150, 105, 0.1);
}

.status-pill.warning {
    background-color: var(--warning-bg);
    color: var(--warning);
    border: 1px solid rgba(217, 119, 6, 0.1);
}

.status-pill.danger {
    background-color: var(--danger-bg);
    color: var(--danger);
    border: 1px solid rgba(220, 38, 38, 0.1);
}

/* Info Dashboard Statistics Cards */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.stat-icon.primary {
    background: var(--primary-gradient);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.stat-icon.accent {
    background: var(--accent-gradient);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Premium Login Page CSS */
.login-body {
    background-color: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-gradient);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.login-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Material Icons alignment */
.material-symbols-rounded {
    vertical-align: middle;
    font-size: 1.25rem;
}