/* =========================================
   LAYOUT STYLE (Structure & Grid)
   - Containers, Grid System, Header, Specific Views
   ========================================= */

/* --- 主容器 --- */
.container {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 20px;
    box-shadow: var(--shadow-card);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--card-border);
    width: 100%;
    max-width: 1400px;
    position: relative;
    z-index: 2;
}

/* --- Login 畫面 (Auth Container) --- */
.auth-container {
    max-width: 420px;
    width: 90%;
    text-align: center;
    margin-top: 15vh;
    background: rgba(15, 20, 25, 0.85); 
    border: 1px solid rgba(102, 252, 241, 0.15);
    border-top: 3px solid var(--accent);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 30px rgba(102, 252, 241, 0.1);
    position: relative;
    overflow: hidden;
    animation: slideIn 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
    padding: 2rem;
    border-radius: 20px;
}

.auth-icon-wrapper {
    margin-bottom: 20px;
    position: relative;
    display: inline-block;
}
.auth-icon {
    font-size: 4rem;
    color: var(--accent);
    filter: drop-shadow(0 0 10px rgba(102, 252, 241, 0.6));
    animation: float 3s ease-in-out infinite;
}
.auth-desc {
    color: var(--text-sub);
    font-size: 0.9rem;
    margin-bottom: 30px;
    font-family: 'Consolas', monospace;
    opacity: 0.7;
}

/* --- Header 區塊 --- */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}
.header-title h1 {
    font-size: 1.8rem;
    letter-spacing: 1px;
    color: var(--text-main);
}
.subtitle {
    font-size: 0.9rem;
    color: var(--text-sub);
    font-weight: 400;
}

.header-meta-group { display: flex; gap: 10px; }
.meta-tag {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    border-radius: 30px;
    font-size: 0.85rem;
    color: var(--accent);
    border: 1px solid rgba(102, 252, 241, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.meta-tag:hover {
    background: rgba(102, 252, 241, 0.1);
    box-shadow: 0 0 10px rgba(102, 252, 241, 0.2);
}

/* --- 分頁導航 (Tabs) --- */
.nav-tabs { display: flex; gap: 15px; margin-bottom: 30px; }
.nav-btn {
    background: transparent;
    color: var(--text-sub);
    padding: 12px 24px;
    border-radius: 12px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}
.nav-btn.active {
    background: rgba(102, 252, 241, 0.1);
    color: var(--accent);
    border-color: rgba(102, 252, 241, 0.3);
    box-shadow: 0 0 15px rgba(102, 252, 241, 0.1);
}
.nav-btn:hover:not(.active) { background: rgba(255, 255, 255, 0.05); color: #fff; }

/* --- 儀表板網格系統 (Grid System) --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}
.span-1 { grid-column: span 1; }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }

/* --- Performance Card Layout --- */
.perf-card { justify-content: space-between; min-height: 180px; }
.perf-content {
    display: flex; flex-direction: column; gap: 12px; flex-grow: 1; justify-content: center; padding-top: 5px;
}
.perf-row { display: flex; justify-content: space-between; align-items: center; }
.perf-metric { display: flex; flex-direction: column; }
.perf-metric:first-child { align-items: flex-start; }
.perf-metric:last-child { align-items: flex-end; }
.perf-metric.full-width { align-items: flex-start; width: 100%; }
.perf-label {
    font-size: 0.75rem; color: var(--text-sub); text-transform: uppercase;
    letter-spacing: 0.5px; margin-bottom: 4px; opacity: 0.7; font-weight: 600;
}
.perf-value {
    font-family: 'Consolas', monospace; font-size: 1.25rem; font-weight: 700;
    color: #fff; text-shadow: 0 0 10px rgba(255,255,255,0.1);
}
.perf-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent); width: 100%; }
.perf-net-container { display: flex; justify-content: space-between; width: 100%; margin-top: 5px; gap: 10px; }
.net-item {
    display: flex; align-items: center; gap: 8px; background: rgba(0, 0, 0, 0.2);
    padding: 6px 10px; border-radius: 6px; width: 48%; border: 1px solid rgba(255,255,255,0.03);
}
.net-val { font-family: 'Consolas', monospace; font-size: 0.9rem; color: #eee; white-space: nowrap; }
.net-icon-up { color: var(--primary); font-size: 0.8rem; }
.net-icon-down { color: var(--accent); font-size: 0.8rem; }
.perf-footer {
    font-size: 0.75rem; color: #666; text-align: center; margin-top: auto;
    border-top: 1px dashed rgba(255,255,255,0.05); padding-top: 10px;
}
.chart-container { width: 100%; height: 60px; position: relative; margin-top: auto; }

/* --- Console Window --- */
.console-box { background: #000; border: 1px solid #333; padding: 0; }
.console-box .stat-label { background: #1a1a1a; padding: 10px 20px; margin: 0; border-bottom: 1px solid #333; }
.console-window {
    background-color: #0b0c10; color: #c5c6c7;
    font-family: "Consolas", "Monaco", monospace;
    padding: 15px; height: 350px; overflow-y: auto;
    font-size: 0.9rem; line-height: 1.6;
}
.console-line { border-bottom: 1px solid rgba(255, 255, 255, 0.02); }
.log-info { color: #66fcf1; }
.log-warn { color: var(--warning); }
.log-error { color: var(--danger); font-weight: bold; }

/* --- Player List Layout --- */
.player-container { display: flex; flex-wrap: wrap; gap: 15px; padding: 10px 0; }
.player-item {
    display: flex; flex-direction: column; align-items: center; width: 60px; animation: fadeIn 0.5s ease;
}
.player-avatar {
    width: 45px; height: 45px; border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1); transition: transform 0.2s;
}
.player-item:hover .player-avatar { transform: scale(1.1); border-color: var(--accent); }
.player-name {
    font-size: 0.75rem; margin-top: 5px; color: #ccc;
    width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.control-bar { margin-top: 30px; display: flex; gap: 20px; }
#action-btn { flex: 1; }
.btn-logout { background: transparent; border: 1px solid #444; color: #888; width: 60px; flex: none; }
.btn-logout:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, 0.05); }

/* --- Backup List Layout --- */
.backup-list-container { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.backup-list { max-height: 400px; overflow-y: auto; padding-right: 5px; }
.backup-item { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); }
.backup-name { color: var(--accent); font-family: monospace; font-size: 1.05rem; }
.backup-header { display: flex; justify-content: space-between; padding: 10px 15px; background: rgba(0,0,0,0.2); font-size: 0.85rem; color: #888; border-radius: 4px; margin-bottom: 5px; }
/* [新增] 備份列表細節樣式 */
.backup-info { display: flex; flex-direction: column; gap: 5px; }
.backup-meta { display: flex; gap: 15px; font-size: 0.85rem; color: #888; }
.backup-actions { display: flex; gap: 10px; align-items: center; }

.sub-info-group { display: flex; gap: 15px; margin-left: 15px; }
.sub-info { font-size: 0.9rem; color: #888; background: rgba(0,0,0,0.2); padding: 4px 10px; border-radius: 4px; }
.highlight-text { color: var(--accent); font-weight: bold; font-family: monospace; }
.warning-box { margin-top: 20px; padding: 15px; background: rgba(255, 179, 0, 0.05); border-left: 3px solid var(--warning); color: #ddd; font-size: 0.9rem; }
.warning-box ul { margin: 5px 0 0 20px; padding: 0; color: #aaa; }

/* --- Mod List Layout --- */.mod-list-container {
    display: grid;
    /* 調整最小寬度至 320px，避免卡片太窄導致內容擠壓 */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 15px;
    padding-top: 10px;
    padding-bottom: 20px;
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 5px; /* 避免捲軸蓋住內容 */
}

/* 模組卡片本體 */
.mod-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 15px;

    /* [核心修改] Grid 系統 */
    display: grid;
    /* 定義兩欄：左邊自動適應(Icon寬度)，右邊佔滿剩餘空間 */
    grid-template-columns: auto minmax(0, 1fr);
    /* 定義兩列：標題列、描述列 */
    grid-template-rows: auto auto;
    column-gap: 15px; /* Icon 與標題的間距 */
    row-gap: 8px;     /* 標題與描述的間距 */

    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    cursor: pointer;
    overflow: hidden;
}

.mod-item:hover {
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.15);
}

/* 圖示容器 */
.mod-icon-wrapper {
    /* Grid 位置：第 1 列，第 1 欄 */
    grid-row: 1;
    grid-column: 1;

    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    padding: 4px;
}

.mod-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 6px;
}

.mod-fallback-icon {
    font-size: 1.8rem;
    color: var(--primary);
    opacity: 0.7;
}

/* 資訊容器 (虛擬容器) */
.mod-info {
    /* [核心修改] display: contents 讓子元素直接參與 mod-item 的 Grid 排版 */
    display: contents;
}

/* 標題與版本區塊 */
.mod-header {
    /* Grid 位置：第 1 列，第 2 欄 */
    grid-row: 1;
    grid-column: 2;
    align-self: start;
    padding-top: 2px; 
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.mod-name {
    width: 100%;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.mod-ver {
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-sub);
    font-family: 'Consolas', monospace;
    display: inline-block;
}

.mod-badge {
    font-size: 0.75rem;
    color: var(--accent);
    border: 1px solid rgba(102, 252, 241, 0.3);
    padding: 1px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 0.5px;
    display: inline-block;
}

/* 描述區塊 (對齊 Icon 左方) */
.mod-desc {
    /* Grid 位置：第 2 列，跨越所有欄位 (從左到右) */
    grid-row: 2;
    grid-column: 1 / -1; 
    
    font-size: 0.85rem;
    color: #888;
    line-height: 1.5;
    
    /* 限制顯示行數，現在空間變大，可以顯示 3 行 */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 4px;
}

/* 編輯模式與選取狀態 */
.mod-item.edit-mode {
    border: 1px dashed rgba(255, 255, 255, 0.3);
}
.mod-item.edit-mode:hover {
    border-color: var(--accent);
}

.mod-item.selected {
    background: rgba(102, 252, 241, 0.08) !important;
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 1px var(--accent); /* 讓選取框更明顯 */
}

/* 選取圓圈圈 (只在編輯模式顯示) */
.mod-select-overlay {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.4);
    background: rgba(0, 0, 0, 0.6);
    display: none; /* 預設隱藏 */
    align-items: center;
    justify-content: center;
    z-index: 5;
    transition: all 0.2s;
}

.mod-item.edit-mode .mod-select-overlay {
    display: flex; /* 編輯模式下才顯示 */
}

.mod-item.selected .mod-select-overlay {
    background: var(--accent);
    border-color: var(--accent);
    color: #000;
}

.mod-select-check {
    font-size: 0.8rem;
    display: none;
}

.mod-item.selected .mod-select-check {
    display: block;
}

/* Mod Toolbar (維持原樣，但確保 margin 正確) */
.mod-toolbar {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(102, 252, 241, 0.2);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    animation: slideIn 0.3s ease;
}

/* 拖曳上傳區塊樣式修正 */
.mod-list-container.drag-active {
    border: 2px dashed var(--accent) !important;
    background: rgba(102, 252, 241, 0.05);
    position: relative;
}

.mod-list-container.drag-active::after {
    content: "放開滑鼠以開始上傳 .jar 檔案";
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(11, 12, 16, 0.85);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    z-index: 10;
    backdrop-filter: blur(4px);
    pointer-events: none;
    border-radius: 12px;
}

/* Mod Modal Layout */
.modal-header-section {
    display: flex; gap: 20px; align-items: center; margin-bottom: 25px;
    border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 20px;
}
.modal-icon-wrapper {
    width: 80px; height: 80px; border-radius: 12px; background: rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1); flex-shrink: 0;
}
.modal-icon-wrapper img { width: 100%; height: 100%; object-fit: cover; }
.modal-fallback-icon { font-size: 2.5rem; color: var(--primary); }
.modal-title-group h2 { margin: 0 0 8px 0; color: var(--accent); font-size: 1.5rem; }
.modal-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.modal-subtitle { font-size: 0.9rem; color: #888; text-transform: uppercase; margin: 0 0 8px 0; }
.modal-text { font-size: 0.95rem; line-height: 1.6; margin: 0; color: #ddd; }
.modal-section { margin-bottom: 20px; }
.modal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.deps-container { display: flex; flex-wrap: wrap; gap: 8px; }
.dep-tag {
    font-size: 0.8rem; background: #2a2b30; padding: 4px 10px; border-radius: 20px;
    color: #ccc; border: 1px solid rgba(255,255,255,0.1);
}
.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* --- Settings Page Layout --- */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; padding: 10px; }
.setting-card {
    background: rgba(255, 255, 255, 0.03); border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px; padding: 20px; display: flex; align-items: center; gap: 20px; transition: all 0.2s ease;
}
.setting-card:hover { background: rgba(255, 255, 255, 0.06); border-color: rgba(102, 252, 241, 0.3); transform: translateX(5px); }
.setting-card.disabled { opacity: 0.5; pointer-events: none; border-style: dashed; }
.setting-icon {
    width: 50px; height: 50px; background: rgba(0, 0, 0, 0.3); border-radius: 10px;
    display: flex; align-items: center; justify-content: center; font-size: 1.5rem;
    color: var(--primary); border: 1px solid rgba(255, 255, 255, 0.1);
}
.setting-content { flex: 1; }
.setting-content label { display: block; font-size: 1.1rem; font-weight: 700; color: var(--text-main); margin-bottom: 5px; }
.setting-desc { font-size: 0.85rem; color: #888; }
.setting-control { display: flex; align-items: center; gap: 10px; }
.unit { color: #aaa; font-size: 0.9rem; }
.settings-footer { margin-top: 30px; display: flex; justify-content: flex-end; border-top: 1px solid rgba(255, 255, 255, 0.05); padding-top: 20px; }

/* BlueMap 樣式 */
.map-wrapper {
    display: flex;
    flex-direction: column;
    height: 80vh; /* 給予足夠的高度 */
    padding-bottom: 0 !important;
    overflow: hidden;
}

.map-container {
    flex: 1;
    position: relative;
    background: #111;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#bluemap-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    position: relative;
    z-index: 10;
}

.map-loader-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #0b0c10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--accent);
    z-index: 1; /* 在 iframe 下層 */
    font-family: 'Consolas', monospace;
    gap: 15px;
    font-size: 1.2rem;
}

/* =========================================
   RESPONSIVE DESIGN (RWD)
   ========================================= */

/* Tablet (769px - 1024px) */
@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
    .span-1 { grid-column: span 1; }
    .span-2, .span-3, .span-4 { grid-column: span 2; }
    .container { padding: 1.5rem; width: 95%; }
}

/* Mobile (< 768px) */
@media (max-width: 768px) {
    body { padding: 10px; }
    .container { padding: 1rem; width: 100%; border-radius: 12px; }

    /* Header */
    .main-header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .header-title { width: 100%; }
    .header-title h1 { font-size: 1.5rem; }
    .header-title .subtitle { display: none; }
    .header-meta-group { width: 100%; justify-content: space-between; flex-wrap: wrap; }
    .meta-tag { flex: 1; justify-content: center; font-size: 0.75rem; padding: 8px; }

    /* Tabs */
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; gap: 10px; padding-bottom: 5px; mask-image: linear-gradient(to right, black 90%, transparent 100%); }
    .nav-btn { flex: 0 0 auto; padding: 10px 16px; font-size: 0.9rem; }

    /* Grid */
    .dashboard-grid { grid-template-columns: 1fr; }
    .span-1, .span-2, .span-3, .span-4 { grid-column: span 1; }

    /* Components */
    .perf-row { flex-direction: row; gap: 10px; }
    .perf-net-container { flex-direction: row; }
    .mod-list-container { grid-template-columns: repeat(auto-fill, minmax(100%, 1fr)); }
    .mod-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
    .upload-zone, .action-zone { width: 100%; display: flex; flex-direction: column; text-align: center; }
    .setting-card { flex-direction: column; align-items: flex-start; gap: 15px; }
    .setting-icon { display: none; }
    .setting-control { width: 100%; justify-content: space-between; margin-top: 5px; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 8px; }
    
    /* Modal */
    .modal-content { width: 95%; padding: 20px; max-height: 80vh; }
    .modal-header-section { flex-direction: column; text-align: center; gap: 10px; }
    .modal-grid { grid-template-columns: 1fr; gap: 10px; }
    .modal-actions { flex-direction: column; }
    
    /* Backup Items Mobile */
    .backup-item { flex-direction: column; align-items: flex-start; gap: 10px; }
    .backup-actions { width: 100%; justify-content: flex-end; }
}

@media (max-width: 380px) {
    .stat-value { font-size: 1.5rem; }
    .perf-row { flex-direction: column; align-items: flex-start; gap: 15px; }
    .perf-metric:last-child { align-items: flex-start; }
}