/* static/style.css */
:root {
    --primary-color: #6366f1; /* Indigo 500 */
    --primary-hover: #4f46e5; /* Indigo 600 */
    --accent-color: #ec4899;  /* Pink 500 */
    --bg-color: #0b0f19;      /* Dark Theme Deep Blue */
    --card-bg: rgba(17, 24, 39, 0.7); /* Glassmorphic Translucent Dark Gray */
    --text-main: #f8fafc;     /* Slate 50 */
    --text-muted: #94a3b8;    /* Slate 400 */
    --border-color: rgba(255, 255, 255, 0.1);  /* Subtle Translucent Slate */
    --success: #10b981;       /* Emerald 500 */
    --error: #ef4444;         /* Red 500 */
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 50% 0%, #1e1b4b 0%, #090d16 70%);
    background-color: var(--bg-color);
    background-attachment: fixed;
    color: var(--text-main);
    margin: 0;
    padding: 20px;
    line-height: 1.6;
}

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

.container.wide-mode {
    max-width: 1425px; /* 1.5x width */
}

.card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(255, 255, 255, 0.05);
    margin-bottom: 24px;
    transition: transform 0.2s, box-shadow 0.2s;
}

/* Header Specifics */
header.card {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    background: rgba(17, 24, 39, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

h1 {
    font-size: 2rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    background: linear-gradient(135deg, #a5b4fc 0%, #f472b6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    color: #f8fafc;
    font-size: 1.5rem;
    margin-top: 0;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    font-weight: 700;
}

h3 {
    color: #cbd5e1;
    font-weight: 600;
}

a {
    color: #818cf8;
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #a5b4fc;
}

/* Controls & Buttons */
.controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-select-wrapper {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 16px;
    border-radius: 50px;
    border: 1px solid var(--border-color);
}

select {
    border: none;
    background: transparent;
    font-size: 1rem;
    padding: 5px;
    outline: none;
    cursor: pointer;
    color: var(--text-main);
    font-weight: 600;
}

select option {
    background-color: #0b0f19;
    color: #f8fafc;
}

input[type="text"], input[type="file"] {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

input[type="text"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    font-size: 0.95rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

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

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.45);
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Unit List (for study files/import list if any) */
.unit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    border-radius: 12px;
    margin-bottom: 15px;
    transition: all 0.2s;
}

.unit-item:hover {
    border-color: var(--primary-color);
    background-color: rgba(255, 255, 255, 0.05);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.15);
}

.unit-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Quiz Styles */
.word-card {
    text-align: center;
    padding: 60px 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.word-main {
    font-size: 3.5rem;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -1px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.pos {
    color: #818cf8;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.definition {
    font-size: 1.5rem;
    font-weight: 600;
    color: #e2e8f0;
}

.options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.quiz-btn {
    padding: 25px;
    font-size: 1.1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-main);
}

.quiz-btn:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.15);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
    transform: translateY(-2px);
}

.correct {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: #10b981 !important;
    color: #34d399 !important;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3) !important;
}

.wrong {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: #ef4444 !important;
    color: #f87171 !important;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.3) !important;
}

/* ==========================================
   4. Tab Switcher & Progress Table Styles
   ========================================== */
.tabs-container {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1px;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted);
    border-bottom: 3px solid transparent;
    transition: all 0.2s ease;
    outline: none;
}

.tab-btn:hover {
    color: #cbd5e1;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 8px 8px 0 0;
}

.tab-btn.active {
    color: #818cf8;
    border-bottom-color: #818cf8;
}

.tab-content {
    display: none;
}

.tab-content.active-content {
    display: block;
    animation: tabFadeIn 0.3s ease;
}

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

/* Table styles & responsive wrapper */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}

.progress-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    text-align: center;
    font-size: 0.9rem;
    background: rgba(15, 23, 42, 0.6);
    color: #e2e8f0;
}

.progress-table th, .progress-table td {
    border-right: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 10px;
    vertical-align: middle;
}

.progress-table th:last-child, .progress-table td:last-child {
    border-right: none;
}

.progress-table th {
    background-color: rgba(30, 41, 59, 0.8);
    font-weight: 700;
    color: var(--text-main);
}

/* ==========================================
   4. 大表格矩陣滾動與 Sticky 樣式
   ========================================== */
.matrix-scroll-container {
    max-height: 650px;
    overflow: auto;
}

.matrix-table {
    table-layout: auto;
}

/* Sticky 表頭 */
.matrix-table thead th {
    position: sticky;
    top: 0;
    background-color: #1e293b;
    z-index: 15;
    box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.3);
}

/* Sticky 首欄日期 */
.matrix-table td.sticky-col-header, 
.matrix-table th.sticky-col-header {
    position: sticky;
    left: 0;
    background-color: #1e293b;
    z-index: 10;
    box-shadow: 2px 0 5px -2px rgba(0, 0, 0, 0.3);
    border-right: 2px solid var(--border-color) !important;
}

/* 雙重 Sticky */
.matrix-table th.sticky-col-header {
    z-index: 30;
    top: 0;
    background-color: #0f172a;
}

/* Sticky 最下方 Summary */
.matrix-summary-row td {
    position: sticky;
    bottom: 0;
    background-color: #0f172a;
    z-index: 15;
    box-shadow: 0 -2px 5px -2px rgba(0, 0, 0, 0.3);
    font-weight: bold;
    border-top: 2px solid var(--border-color) !important;
}

/* 交角左下角 */
.matrix-summary-row td.sticky-col-header {
    z-index: 25;
    left: 0;
    background-color: #1e293b !important;
}

/* 週末列 */
.weekend-row td {
    background-color: rgba(255, 255, 255, 0.01);
}

.weekend-row td.date-col {
    background-color: #1e293b !important;
    color: #cbd5e1;
}

/* 今日列高亮標示 */
.today-row td {
    background-color: rgba(59, 130, 246, 0.15) !important;
    border-top: 2px solid #3b82f6 !important;
    border-bottom: 2px solid #3b82f6 !important;
}

.today-row td.date-col {
    background-color: #1e3a8a !important;
    color: #60a5fa !important;
    font-weight: 700;
    box-shadow: 2px 0 6px rgba(59, 130, 246, 0.4);
}

.today-badge {
    display: inline-block;
    background-color: #2563eb;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
    box-shadow: 0 0 6px rgba(37, 99, 235, 0.6);
}


/* 矩陣格 */
.matrix-cell {
    min-width: 130px;
    padding: 6px 8px !important;
}

.matrix-cell div {
    margin: 3px auto;
}

/* 測驗小標籤 */
.progress-badge {
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    font-weight: 700;
    line-height: 1.3;
    display: inline-block;
    max-width: 120px;
    margin: 2px;
}

.badge-quiz {
    background-color: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.badge-reverse {
    background-color: rgba(139, 92, 246, 0.2);
    color: #c084fc;
    border: 1px solid rgba(139, 92, 246, 0.4);
}

.badge-spelling {
    background-color: rgba(236, 72, 153, 0.2);
    color: #f472b6;
    border: 1px solid rgba(236, 72, 153, 0.4);
}

.progress-legend {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Summary 欄格 */
.matrix-footer-cell {
    padding: 10px 6px !important;
}

/* 個人彙總狀態標籤 */
.unit-status-pill {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-weight: 700;
}

.unit-status-pill.completed {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.unit-status-pill.in-progress {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.unit-status-pill.not-started {
    background-color: rgba(255, 255, 255, 0.05);
    color: #94a3b8;
}

/* ==========================================
   5. Dropdown & Unified Quiz Styles (Premium Redesign)
   ========================================== */

/* 首頁單元下拉選單包裝 */
.unit-select-wrapper-homepage {
    position: relative;
    margin-bottom: 24px;
    width: 100%;
}

.unit-select-homepage {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.15rem;
    font-weight: 600;
    color: #f8fafc;
    background-color: rgba(255, 255, 255, 0.03);
    border: 2px solid var(--border-color);
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2.5' d='M19.5 8.25l-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 20px center;
    background-size: 16px;
    padding-right: 48px;
}

.unit-select-homepage:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25), 0 10px 15px -3px rgba(99, 102, 241, 0.1);
    outline: none;
}

/* 動態出現的單元詳細卡片 */
.selected-unit-card {
    display: none;
    flex-direction: column;
    gap: 20px;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 28px;
    background: rgba(30, 41, 59, 0.4);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
    animation: cardSlideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

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

.selected-unit-card .unit-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 18px;
}

.selected-unit-card .unit-name {
    font-size: 1.5rem;
    font-weight: 800;
    color: #f8fafc;
    background: linear-gradient(135deg, #c7d2fe, #fbcfe8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.selected-unit-card .unit-count-badge {
    font-size: 0.9rem;
    font-weight: 700;
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.2);
    padding: 6px 16px;
    border-radius: 50px;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

/* 學習按鈕組 */
.unit-action-group {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    width: 100%;
    margin-top: 10px;
}

.btn-action-list,
.btn-action-study {
    flex: 1;
    min-width: 140px;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 16px 24px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    background-color: rgba(255, 255, 255, 0.03);
    color: #cbd5e1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
}

.btn-action-list:hover,
.btn-action-study:hover {
    border-color: rgba(255, 255, 255, 0.2);
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-action-quiz {
    flex: 1;
    min-width: 140px;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 16px 24px;
    border-radius: 12px;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.4);
}

.btn-action-quiz:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
    background: linear-gradient(135deg, #4f46e5, #7c3aed);
}

/* 測驗頁面模式選擇卡片 */
.quiz-mode-card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-top: 25px;
}

.quiz-mode-card {
    border: none;
    border-radius: 16px;
    padding: 24px;
    color: #ffffff;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 160px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    position: relative;
    overflow: hidden;
}

.quiz-mode-card::after {
    content: '';
    position: absolute;
    top: -30%;
    right: -30%;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.quiz-mode-card:hover::after {
    transform: scale(1.3);
}

.quiz-mode-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(99, 102, 241, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.3);
}

.quiz-mode-card.mode-chinese {
    background: linear-gradient(135deg, #6366f1, #4f46e5);
}

.quiz-mode-card.mode-english {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.quiz-mode-card.mode-spelling {
    background: linear-gradient(135deg, #ec4899, #db2777);
}

.quiz-mode-card-icon {
    font-size: 2.2rem;
    margin-bottom: 12px;
}

.quiz-mode-card-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 6px;
}

.quiz-mode-card-desc {
    font-size: 0.9rem;
    opacity: 0.9;
    font-weight: normal;
    line-height: 1.45;
}
