/* ========================================
   全樺試務中心 - 共用元件樣式
   ======================================== */

/* ============================================
   篩選器共用樣式 (Filter Components)
   ============================================ */

/* 篩選區塊容器 */
.filter-panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.filter-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    border-radius: 8px 8px 0 0;
}

.filter-panel-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.95rem;
}

.filter-panel-toggle {
    background: #e2e8f0;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    color: #475569;
    transition: all 0.2s;
}

.filter-panel-toggle:hover {
    background: #cbd5e1;
}

.filter-panel-body {
    padding: 20px 24px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    align-items: start;
}

/* 單行佈局 (篩選器較少時) */
.filter-panel-body.inline {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-end;
}

.filter-panel-body.inline .filter-field {
    flex: 0 0 auto;
    min-width: 200px;
}

.filter-panel-body.collapsed {
    display: none;
}

.filter-panel-footer {
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
    border-radius: 0 0 8px 8px;
}

/* 篩選欄位 */
.filter-field {
    flex: 1;
    min-width: 200px;
}

.filter-field-label {
    font-weight: 500;
    color: #475569;
    margin-bottom: 8px;
    display: block;
    font-size: 0.9rem;
}

.filter-field-hint {
    display: block;
    font-size: 0.75rem;
    color: #ef4444;
    font-weight: 400;
    margin-top: 4px;
}

/* Checkbox 列表 */
.checkbox-list {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    padding: 12px;
    max-height: 180px;
    overflow-y: auto;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    transition: color 0.2s;
}

.checkbox-item:hover {
    color: var(--color-primary);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

.checkbox-item.selected {
    background: var(--color-primary-lighter);
    margin: 0 -12px;
    padding: 6px 12px;
}

/* Radio 列表 */
.radio-list {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    padding: 12px;
    max-height: 180px;
    overflow-y: auto;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    cursor: pointer;
    font-size: 0.9rem;
    color: #374151;
    transition: color 0.2s;
}

.radio-item:hover {
    color: var(--color-primary);
}

.radio-item input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}

/* 科數選擇器 (按鈕式) */
.subject-count-selector {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.subject-count-btn {
    padding: 10px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.subject-count-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.subject-count-btn.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
}

/* ============================================
   類組選擇器 (Group Selector - Button Grid)
   ============================================ */

.group-selector {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    overflow: hidden;
}

.group-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid #e2e8f0;
}

.group-selector-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.9rem;
}

.group-selector-actions {
    display: flex;
    gap: 8px;
}

.group-selector-body {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 280px;
    overflow-y: auto;
}

.group-btn {
    position: relative;
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.group-btn:hover {
    border-color: #1A8B58;
    color: #1A8B58;
    background: #f0fdf4;
}

.group-btn.selected {
    background: linear-gradient(135deg, #1A8B58, #16a34a);
    border-color: #1A8B58;
    color: white;
    box-shadow: 0 2px 4px rgba(26, 139, 88, 0.3);
}

.group-btn.selected::after {
    content: '✓';
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.7rem;
    font-weight: bold;
}

/* 類組選擇器 - 單選模式 */
.group-selector.single-select .group-btn.selected::after {
    content: '';
}

/* 類組選擇器 - 緊湊模式 */
.group-selector.compact .group-selector-body {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
    padding: 12px;
}

.group-selector.compact .group-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
}

/* 學校選擇器 (Tab + 按鈕) */
.school-selector {
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    overflow: hidden;
}

.school-tabs {
    display: flex;
    border-bottom: 1px solid #e2e8f0;
}

.school-tab {
    flex: 1;
    padding: 10px;
    background: #f8fafc;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #64748b;
    transition: all 0.2s;
}

.school-tab:hover {
    background: #f1f5f9;
}

.school-tab.active {
    background: var(--color-primary);
    color: white;
}

.school-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.school-btn {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    background: white;
    color: #475569;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.school-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.school-btn.selected {
    background: var(--color-primary-lighter);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* 篩選按鈕列 */
.filter-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-mini-outline {
    padding: 6px 12px;
    border: 1px solid var(--color-primary);
    background: white;
    color: var(--color-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-mini-outline:hover {
    background: var(--color-primary-lighter);
}

.btn-clear {
    padding: 6px 12px;
    border: 1px solid #ef4444;
    background: white;
    color: #ef4444;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.btn-clear:hover {
    background: #fef2f2;
}

.btn-search {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(26, 139, 88, 0.3);
}

.btn-search:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26, 139, 88, 0.4);
}

.btn-next-step {
    padding: 10px 24px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(26, 139, 88, 0.3);
}

.btn-next-step:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(26, 139, 88, 0.4);
}

.btn-reset {
    padding: 10px 24px;
    background: white;
    color: #64748b;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-reset:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* ============================================
   功能按鈕群組 (Tab Buttons)
   ============================================ */

.function-tabs {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.function-tab {
    padding: 12px 24px;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    color: #475569;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.function-tab:hover {
    border-color: #1A8B58;
    color: #1A8B58;
}

.function-tab.active {
    background: #1A8B58;
    border-color: #1A8B58;
    color: white;
}

/* ============================================
   下載區塊 (Download Section)
   ============================================ */

.download-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 16px;
    padding: 20px;
}

.download-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.download-card:hover {
    border-color: #1A8B58;
    box-shadow: 0 4px 12px rgba(26, 139, 88, 0.15);
    transform: translateY(-2px);
}

.download-icon {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
}

.download-icon-excel {
    color: #16a34a;
}

.download-icon-pdf {
    color: #dc2626;
}

.download-icon-word {
    color: #2563eb;
}

.download-name {
    font-size: 0.85rem;
    color: #475569;
    text-align: center;
    line-height: 1.4;
}

/* ============================================
   圖表佔位符 (Chart Placeholder)
   ============================================ */

.chart-container {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
}

.chart-placeholder {
    height: 300px;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

.chart-placeholder-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.chart-placeholder-text {
    font-size: 0.95rem;
}

/* 簡易長條圖 (CSS Only) */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px 0;
}

.bar-chart-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bar-chart-label {
    width: 120px;
    font-size: 0.9rem;
    color: #475569;
    text-align: right;
    flex-shrink: 0;
}

.bar-chart-bar-wrapper {
    flex: 1;
    height: 28px;
    background: #f1f5f9;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.bar-chart-bar {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 4px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
}

.bar-chart-bar.bar-green {
    background: linear-gradient(90deg, #22c55e, #4ade80);
}

.bar-chart-bar.bar-orange {
    background: linear-gradient(90deg, #f97316, #fb923c);
}

.bar-chart-bar.bar-red {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.bar-chart-value {
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ============================================
   佳作作品卡片 (Work Card)
   ============================================ */

.works-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px 0;
}

.work-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.work-card:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-4px);
}

.work-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: #f1f5f9;
}

.work-card-info {
    padding: 12px;
}

.work-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.work-card-meta {
    font-size: 0.8rem;
    color: #64748b;
}

/* ============================================
   結果提示 (Result Message)
   ============================================ */

.result-placeholder {
    padding: 60px 20px;
    text-align: center;
    color: #94a3b8;
    font-style: italic;
    background: #f8fafc;
    border-radius: 8px;
    border: 2px dashed #e2e8f0;
}

.result-loading {
    padding: 40px 20px;
    text-align: center;
    color: #64748b;
}

.result-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   響應式調整
   ============================================ */

@media (max-width: 768px) {
    .filter-panel-body {
        flex-direction: column;
    }

    .filter-field {
        width: 100%;
        min-width: unset;
    }

    .filter-panel-footer {
        flex-direction: column;
    }

    .btn-search,
    .btn-next-step,
    .btn-reset {
        width: 100%;
    }

    .function-tabs {
        flex-direction: column;
    }

    .function-tab {
        width: 100%;
        text-align: center;
    }

    .download-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .bar-chart-label {
        width: 80px;
        font-size: 0.8rem;
    }

    /* Checkbox Grid - 手機端 2 欄 */
    .checkbox-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .checkbox-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    /* 科數選擇器 */
    .subject-count-selector {
        gap: 6px;
    }

    .subject-count-btn {
        padding: 8px 14px;
        font-size: 0.85rem;
    }

    /* 類組選擇器 - 手機端 2 欄 */
    .group-selector-body {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 12px;
    }

    .group-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    /* 學校選擇器 */
    .school-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   考科組合分析篩選器樣式
   ============================================ */

/* Checkbox Grid - 按鈕式多選 */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.checkbox-btn {
    padding: 10px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #475569;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkbox-btn:hover {
    border-color: #1A8B58;
    color: #1A8B58;
    background: #f0fdf4;
}

.checkbox-btn.active {
    background: #1A8B58;
    border-color: #1A8B58;
    color: white;
    box-shadow: 0 2px 4px rgba(26, 139, 88, 0.3);
}

/* Filter Toggle Button */
.filter-toggle-btn {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #64748b;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.filter-toggle-btn:hover {
    color: #1A8B58;
}

.filter-toggle-btn svg {
    transition: transform 0.2s;
}

.filter-toggle-btn.collapsed svg {
    transform: rotate(-90deg);
}

/* Mini Outline Button */
.btn-mini-outline {
    padding: 6px 16px;
    border: 1px solid #cbd5e1;
    background: white;
    color: #64748b;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
    margin-left: 8px;
}

.btn-mini-outline:hover {
    border-color: #1A8B58;
    color: #1A8B58;
    background: #f0fdf4;
}

/* ============================================
   提示訊息區塊 (Notice Box)
   用於顯示說明文字、警告訊息等
   ============================================ */

/* 基本提示框樣式 */
.notice-box {
    margin-top: 16px;
    padding: 16px;
    border-radius: 8px;
    font-size: 0.85rem;
}

/* 警告提示框 (黃色) - 用於重要提醒 */
.notice-box--warning {
    background-color: #fffbeb;
    border: 1px solid #fcd34d;
    color: #92400e;
}

/* 資訊提示框 (藍色) - 用於補充說明 */
.notice-box--info {
    background-color: #f0f9ff;
    border: 1px solid #7dd3fc;
    color: #0369a1;
}

/* 成功提示框 (綠色) - 用於正面回饋 */
.notice-box--success {
    background-color: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

/* 錯誤提示框 (紅色) - 用於錯誤提示 */
.notice-box--error {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* 提示框標題 */
.notice-box__title {
    font-weight: 600;
    margin-bottom: 8px;
}

/* 提示框列表 */
.notice-box__list {
    margin: 0;
    padding-left: 20px;
    list-style-type: disc;
}

.notice-box__list li {
    margin-bottom: 4px;
}

.notice-box__list li:last-child {
    margin-bottom: 0;
}

/* 提示框段落 */
.notice-box__text {
    margin: 0 0 8px 0;
}

.notice-box__text:last-child {
    margin-bottom: 0;
}