/* 基礎設定 */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --card-bg: rgba(255, 255, 255, 0.8);
    --text-main: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', sans-serif;
    background: var(--bg-gradient);
    min-height: 100vh;
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
}

.container {
    width: 100%;
    max-width: 1000px;
    animation: fadeIn 0.8s ease-out;
}

/* 標題區域 */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #4f46e5, #9333ea);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* 上傳區域 */
.upload-area {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 2px dashed #cbd5e1;
    border-radius: var(--border-radius);
    padding: 4rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1.5rem;
    color: var(--primary-color);
}

.upload-area p {
    font-size: 1.2rem;
    color: var(--text-main);
}

.upload-area span {
    color: var(--primary-color);
    font-weight: 600;
    text-decoration: underline;
}

/* 按鈕樣式 */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.btn {
    padding: 0.75rem 2rem;
    border-radius: 9999px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    font-size: 1rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(79, 70, 229, 0.39);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover {
    background: #f1f5f9;
}

/* 部門分析區域 */
.analysis-section {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
    animation: slideUp 0.5s ease-out;
}

.analysis-section h3 {
    margin-bottom: 1rem;
    color: var(--text-main);
    font-size: 1.25rem;
    border-left: 4px solid var(--primary-color);
    padding-left: 0.75rem;
}

.dept-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.dept-item {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.dept-item:hover {
    border-color: var(--primary-color);
    background: #f1f5f9;
}

.dept-info {
    display: flex;
    flex-direction: column;
}

.dept-name {
    font-weight: 700;
    color: var(--text-main);
}

.dept-count {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

/* 表格容器 */
.result-container {
    background: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

.table-wrapper {
    overflow-x: auto;
    max-height: 60vh;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-align: left;
    padding: 1rem;
    border-bottom: 2px solid #e2e8f0;
    position: sticky;
    top: 0;
}

td {
    padding: 1rem;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text-main);
}

tr:hover {
    background-color: #f8fafc;
}

/* 隱藏元素 */
.hidden {
    display: none;
}

/* 動畫 */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* 頁尾 */
footer {
    text-align: center;
    margin-top: 4rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}
