/* --- 1. 全域與變數 --- */
:root {
    /* 基礎字型 */
    --font-family: 'Noto Sans TC', sans-serif;
    --font-family-mono: 'Roboto Mono', 'Courier New', monospace;
    
    /* 深色主題 (預設) */
    --color-bg: #121212;
    --color-surface: #1e1e1e;
    --color-surface-hover: #2d2d2d;
    --color-border: #333333;
    --color-text-primary: #e0e0e0;
    --color-text-secondary: #aaaaaa;
    --color-text-disabled: #666666;
    
    /* 主題色 */
    --color-primary: #bb86fc;
    --color-primary-variant: #3700b3;
    --color-primary-text: #000000;
    
    /* 輔助色 */
    --color-secondary: #03dac6;
    --color-danger: #cf6679;
    --color-warning: #fdd835;
    --color-success: #69f0ae;

    /* 組件 */
    --border-radius: 12px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    --header-height: 64px;
}

/* 淺色主題 */
body.light-mode {
    --color-bg: #f5f5f5;
    --color-surface: #ffffff;
    --color-surface-hover: #f0f0f0;
    --color-border: #e0e0e0;
    --color-text-primary: #212121;
    --color-text-secondary: #555555;
    --color-text-disabled: #9e9e9e;
    
    --color-primary: #6200ee;
    --color-primary-variant: #3700b3;
    --color-primary-text: #ffffff;
    
    --color-danger: #b00020;
    --color-warning: #f57f17;
    --color-success: #00c853;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--color-bg);
    /* Ambient Glow Background for Glassmorphism */
    background-image: 
        radial-gradient(circle at 15% 50%, rgba(187, 134, 252, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 85% 30%, rgba(3, 218, 198, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--color-text-primary);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

/* --- 2. 頂部導覽列 --- */
.main-header {
    height: var(--header-height);
    background: rgba(30, 30, 30, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    border-radius: 0 0 16px 16px;
    margin-bottom: 24px;
}
body.light-mode .main-header {
    background: rgba(255, 255, 255, 0.7);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.badge {
    font-size: 0.7rem;
    background: linear-gradient(135deg, var(--color-primary), #9c27b0);
    color: #fff;
    padding: 3px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 2px 6px rgba(187, 134, 252, 0.4);
}

.header-actions { display: flex; gap: 8px; }

/* --- 3. 主佈局 --- */
.app-container {
    width: 100%;
    display: flex;
    max-width: 1600px;
    margin: 24px auto;
    padding: 0 24px;
    gap: 24px;
    align-items: flex-start;
}

.main-content { flex: 1; min-width: 0; width: 100%; overflow-x: hidden; }

.sidebar {
    max-height: calc(100vh - var(--header-height) - 48px);
    overflow-y: auto;
    flex-basis: 360px;
    position: sticky;
    top: calc(var(--header-height) + 24px);
    transition: top 0.3s;
    background: rgba(30,30,30,0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
body.light-mode .sidebar {
    background: rgba(255,255,255,0.5);
    border: 1px solid rgba(0,0,0,0.05);
}

.content-section { margin-bottom: 32px; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 12px;
    flex-wrap: wrap;
    gap: 12px;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
    border-left: 4px solid var(--color-primary);
    padding-left: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* --- 4. 按鈕與互動元件 --- */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-family: var(--font-family);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), #9c27b0);
    color: #fff;
    box-shadow: 0 4px 12px rgba(187, 134, 252, 0.3);
    border: 1px solid rgba(255,255,255,0.1);
}
.btn-primary:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    background-color: var(--color-surface-hover);
    color: var(--color-text-disabled);
    cursor: not-allowed;
    box-shadow: none;
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
}
.btn-secondary:hover {
    background-color: var(--color-surface-hover);
    border-color: var(--color-text-secondary);
}

.btn-danger {
    background-color: rgba(207, 102, 121, 0.1);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}
.btn-danger:hover {
    background-color: var(--color-danger);
    color: #000;
}

.btn-icon { padding: 8px; min-width: 36px; border-radius: 50%; }

/* --- 5. Boss 監控卡片 --- */
.boss-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.boss-card {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    padding: 16px;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.boss-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 8px 16px rgba(0,0,0,0.4);
    border-color: var(--color-primary);
}

.boss-card.selected {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary);
}

/* 狀態邊框指示條 */
.boss-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: 4px;
    background-color: var(--color-text-disabled);
    transition: background-color 0.3s;
}

.boss-card.status-alive::before { background-color: var(--color-success); }
.boss-card.status-warning::before { background-color: var(--color-warning); }
.boss-card.status-cooldown::before { background-color: var(--color-danger); }

.boss-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.boss-card-img {
    width: 44px;
    height: 44px;
    background-color: var(--color-bg);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.boss-card-info h3 {
    font-size: 1.1rem;
    margin-bottom: 2px;
    color: var(--color-text-primary);
}

.boss-card-info p {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
}

.boss-card-timer-block {
    background-color: var(--color-bg);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
}

.boss-card-status-text {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 4px;
    display: block;
}
.boss-card.status-alive .boss-card-status-text { color: var(--color-success); }
.boss-card.status-warning .boss-card-status-text { color: var(--color-warning); }
.boss-card.status-cooldown .boss-card-status-text { color: var(--color-text-secondary); }

.boss-card-countdown {
    font-family: var(--font-family-mono);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text-primary);
}
.boss-card-channel-hint {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.boss-card.is-recent {
    border-color: rgba(187, 134, 252, 0.4);
    background: rgba(187, 134, 252, 0.03);
}

.boss-list-divider {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-text-secondary);
    padding: 8px 4px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.boss-list-divider .material-icons-outlined {
    font-size: 18px;
    color: var(--color-primary);
}

/* --- 6. 表格 (可排序) --- */
.table-container {
    background-color: var(--color-surface);
    border-radius: var(--border-radius);
    border: 1px solid var(--color-border);
    overflow-x: auto;
}

#kill-history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

#kill-history-table th,
#kill-history-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

#kill-history-table th {
    background: rgba(45, 45, 45, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--color-text-primary);
    font-weight: 600;
    white-space: nowrap;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 0 rgba(255,255,255,0.05);
}
body.light-mode #kill-history-table th {
    background: rgba(240, 240, 240, 0.85);
}

/* 排序標頭樣式 */
#kill-history-table th.sortable {
    cursor: pointer;
    transition: color 0.2s;
}
#kill-history-table th.sortable:hover {
    color: var(--color-text-primary);
    background-color: var(--color-border);
}
.sort-icon {
    display: inline-block;
    width: 12px;
    text-align: center;
    font-size: 0.8rem;
    margin-left: 4px;
}

/* 表格列互動 */
#kill-history-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}
#kill-history-table tbody tr:hover {
    background-color: var(--color-surface-hover);
}

.drop-yes { color: var(--color-success); font-weight: 700; }
.drop-no { color: var(--color-text-disabled); opacity: 0.5; }


/* --- 7. 右側表單 --- */
.selected-boss-info {
    background-color: var(--color-bg);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    border: 1px solid var(--color-border);
}
#boss-placeholder {
    color: var(--color-text-disabled);
    font-style: italic;
    font-size: 0.9rem;
    text-align: center;
    width: 100%;
}

.form-group { margin-bottom: 20px; }
.input-label {
    display: block;
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.form-input {
    width: 100%;
    padding: 12px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text-primary);
    font-size: 1rem;
    transition: all 0.3s;
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 10px rgba(187, 134, 252, 0.2);
}

/* 步進器 */
.channel-stepper {
    display: flex;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
}
.stepper-btn {
    width: 48px;
    background-color: var(--color-surface-hover);
    border: none;
    color: var(--color-text-primary);
    cursor: pointer;
    font-size: 1.2rem;
}
.stepper-btn:hover { background-color: var(--color-border); }
#channel-input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--color-text-primary);
    text-align: center;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 8px;
    -moz-appearance: textfield;
}

.quick-channels {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.quick-chip {
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}
.quick-chip:hover {
    border-color: var(--color-primary);
    color: var(--color-text-primary);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 34px;
    transition: .4s;
}
.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--color-text-disabled);
    border-radius: 50%;
    transition: .4s;
}
input:checked + .slider { background-color: var(--color-primary); border-color: var(--color-primary); }
input:checked + .slider:before { transform: translateX(22px); background-color: #fff; }

/* 篩選與搜尋 */
.filter-chips { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip {
    padding: 6px 12px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    color: var(--color-text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.chip:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.chip.active {
    background-color: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
}

.search-box {
    position: relative;
    flex: 1;
    min-width: 250px;
    display: flex;
    align-items: center;
}
.search-box .material-icons-outlined {
    position: absolute;
    left: 12px;
    color: var(--color-text-disabled);
}
.search-box input {
    width: 100%;
    padding: 10px 10px 10px 40px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    color: var(--color-text-primary);
    transition: all 0.3s;
}
.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 12px rgba(187, 134, 252, 0.2);
}

.smart-sort-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--color-border);
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--color-surface);
    color: var(--color-text-secondary);
    transition: all 0.3s;
}
.smart-sort-btn:hover { background: var(--color-surface-hover); }
.smart-sort-btn.active {
    background: var(--color-primary);
    color: var(--color-primary-text);
    border-color: var(--color-primary);
}

/* --- Target Lock Mode (Hunting Mode) --- */
.target-lock-panel {
    background: rgba(187, 134, 252, 0.08);
    border: 1px solid var(--color-primary);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.target-boss-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.target-boss-info h2 {
    font-size: 1.25rem;
    margin: 0;
    background: linear-gradient(90deg, var(--color-primary), #fff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.target-boss-info p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: 4px 0 0 0;
}

#unlock-boss-btn {
    margin-left: auto;
    background: rgba(255,255,255,0.05);
    color: var(--color-text-secondary);
}
#unlock-boss-btn:hover {
    background: var(--color-danger);
    color: #fff;
}

.focus-input-area {
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.05);
}

.large-channel-input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.large-channel-input {
    flex: 1;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--color-primary);
    text-align: center;
    font-family: var(--font-family-mono);
    width: 100%;
    transition: all 0.3s;
}

.large-channel-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 15px rgba(187, 134, 252, 0.3);
    background: var(--color-surface);
}

.input-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-large {
    width: 100%;
    padding: 18px;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.auto-inc-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.drop-type-selector {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.drop-chip {
    flex: 1;
    cursor: pointer;
}

.drop-chip input {
    display: none;
}

.drop-chip .chip-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    transition: all 0.2s;
    white-space: nowrap;
}

.drop-chip input:checked + .chip-content {
    background: rgba(187, 134, 252, 0.2);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.drop-chip.star-chip input:checked + .chip-content {
    background: rgba(253, 216, 53, 0.15);
    border-color: var(--color-warning);
    color: var(--color-warning);
    box-shadow: 0 0 12px rgba(253, 216, 53, 0.3);
}

/* --- History List inside Panel --- */
.target-history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 4px;
}

.target-history-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.target-history-item:hover {
    border-color: var(--color-primary);
    background: var(--color-surface-hover);
}

.history-ch-badge {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-primary);
}
.history-drops { display: flex; gap: 4px; margin-top: 4px; }
.drop-icon { font-size: 14px !important; }
.drop-icon.equip { color: #90caf9; }
.drop-icon.scroll { color: #a5d6a7; }
.drop-icon.star { color: var(--color-warning); filter: drop-shadow(0 0 2px rgba(253, 216, 53, 0.8)); }

.history-time-info { text-align: right; }
.history-status-tag {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
}
.tag-alive { color: var(--color-success); background: rgba(105, 240, 174, 0.1); }
.tag-warning { color: var(--color-warning); background: rgba(253, 216, 53, 0.1); }
.tag-cooldown { color: var(--color-text-disabled); background: rgba(255, 255, 255, 0.05); }

.history-countdown {
    font-family: var(--font-family-mono);
    font-size: 0.85rem;
    display: block;
    margin-top: 2px;
}

/* --- RWD --- */
@media (max-width: 900px) {
    .app-container { padding: 0 16px; gap: 16px; margin: 16px auto; flex-direction: column; }
    .sidebar { 
        padding: 12px; 
        margin-bottom: 16px; 
        max-height: none; 
        position: relative; 
        top: 0;
        order: -1;
        width: 100%;
        flex-basis: auto;
    }
    .sidebar-header { margin-bottom: 12px; }
    .sidebar-header h2 { font-size: 1.1rem; }
    
    .large-channel-input { font-size: 2rem; padding: 12px; }
    .drop-chip .chip-content { padding: 12px 8px; font-size: 0.8rem; }
    .filter-bar { flex-direction: column; gap: 12px; }
    .search-box { width: 100%; }
    .table-container { border-radius:12px; }
    #kill-history-table { min-width: 700px; }
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }
