/* 
 * AntiRaidX Cyber Orange - Version 4.1 (Button Critical Fix)
 * 修正按鈕樣式消失、導覽列自適應、摺疊選單、以及 Admin 工具
 */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Roboto+Mono&display=swap');

:root {
  --primary-color: #ff8c00;
  --secondary-color: #ff4500;
  --danger-color: #ff3c3c;
  --success-color: #4CAF50;
  --warning-color: #FFC107;
  --info-color: #2196F3;
  --bg-color: #0d0905;
  --bg-secondary-color: #1a120a;
  --text-color: #e0d0c0;
  --border-color: rgba(255, 140, 0, 0.2);
  --sidebar-width: 260px;
  --glow-shadow: 0 0 15px rgba(255, 140, 0, 0.4);
}

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

body {
  font-family: 'Roboto Mono', monospace;
  background-color: var(--bg-color);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* 背景 */
.starry-background { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: -1; background: #050301; }
.stars { background: transparent url(https://s3-us-west-2.amazonaws.com/s.cdpn.io/1231630/stars.png) repeat; width: 100%; height: 100%; opacity: 0.3; filter: sepia(100%) hue-rotate(-30deg) saturate(200%); }

/* 游標 */
.cursor { width: 20px; height: 20px; border: 2px solid var(--primary-color); position: fixed; pointer-events: none; border-radius: 50%; z-index: 10001; transform: translate(-50%,-50%); transition: 0.1s; display: none; }
.cursor-dot { width: 4px; height: 4px; background: var(--primary-color); position: fixed; pointer-events: none; border-radius: 50%; z-index: 10002; transform: translate(-50%,-50%); display: none; }

/* --- 佈局邏輯 --- */
@media (min-width: 992px) {
  body { flex-direction: row; cursor: none; }
  .sidebar { width: var(--sidebar-width); height: 100vh; position: fixed; left: 0; top: 0; border-right: 1px solid var(--border-color); background: #0d0905; display: flex; flex-direction: column; z-index: 1000; }
  .main-wrapper { margin-left: var(--sidebar-width); flex: 1; }
  .sidebar-brand { padding: 30px; font-family: 'Orbitron'; font-weight: bold; color: var(--primary-color); text-decoration: none; font-size: 1.5rem; }
  .sidebar-menu { flex: 1; }
  .sidebar-menu a { padding: 12px 25px; display: flex; align-items: center; text-decoration: none; color: #ccc; border-left: 3px solid transparent; transition: 0.3s; }
  .sidebar-menu a:hover, .sidebar-menu a.active { background: rgba(255, 140, 0, 0.1); color: #fff; border-left-color: var(--primary-color); }
  .sidebar-menu a i { margin-right: 12px; width: 20px; text-align: center; }
  .sidebar-footer { padding: 20px; border-top: 1px solid var(--border-color); }
  .menu-label { padding: 10px 25px; font-size: 0.7rem; color: #666; text-transform: uppercase; }
  .cursor, .cursor-dot { display: block; position: fixed; pointer-events: none; border-radius: 50%; z-index: 9999; transform: translate(-50%,-50%); }
  .cursor { width: 20px; height: 20px; border: 2px solid var(--primary-color); }
  .cursor-dot { width: 4px; height: 4px; background: var(--primary-color); }
}

@media (max-width: 991px) {
    /* 1. 標題放大，確保左對齊 */
    .sidebar-brand {
        font-size: 1.5rem !important;
        padding: 12px 15px !important;
        display: block;
        width: fit-content; /* 標題寬度隨字長 */
    }

    /* 2. 導覽列容器：改為橫向佈局的起點 */
    .sidebar {
        width: 100% !important;
        height: auto !important;
        position: sticky;
        top: 0;
        display: block !important; /* 改回 block 方便內部排版 */
        background: rgba(13, 9, 5, 0.98);
        border-bottom: 1px solid var(--border-color);
        z-index: 9999;
    }

    /* 3. 隱藏分類標籤 (menu-label) */
    .menu-label { display: none !important; }

    /* 4. 按鈕清單：橫向捲動，確保不換行 */
    .sidebar-menu {
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        padding: 5px 15px 12px 15px !important;
        gap: 8px; /* 按鈕間距 */
        -webkit-overflow-scrolling: touch;
    }
    .sidebar-menu::-webkit-scrollbar { display: none; }

    /* 5. 核心修正：按鈕寬度縮減 */
    .sidebar-menu a {
        /* 恢復文字顯示 */
        display: inline-flex !important; 
        align-items: center;
        
        /* 強制寬度自適應內容 */
        width: max-content !important; 
        flex: 0 0 auto !important; 
        
        padding: 6px 12px !important;
        font-size: 0.85rem !important; /* 字體稍微縮小 */
        white-space: nowrap !important; /* 核心：禁止文字換行擠開寬度 */
        
        border: 1px solid rgba(255, 140, 0, 0.3) !important;
        border-left: 1px solid rgba(255, 140, 0, 0.3) !important; /* 覆蓋左粗邊 */
        border-radius: 6px;
        background: rgba(255, 140, 0, 0.05);
        color: #fff !important;
    }

    /* 6. 文字與圖示間隔 */
    .sidebar-menu a i {
        margin-right: 6px !important;
        font-size: 0.9rem;
    }
    .sidebar-menu a span {
        display: inline !important; /* 確保文字回來 */
    }

    /* 7. Active 框線優化 */
    .sidebar-menu a.active {
        background: var(--primary-color) !important;
        color: #000 !important;
        border-color: var(--primary-color) !important;
        font-weight: bold;
    }

    /* 8. 登出按鈕：移到右上角 */
    .sidebar-footer {
        position: absolute;
        right: 15px;
        top: 12px;
        padding: 0 !important;
        border: none !important;
        background: none !important;
    }
    .sidebar-footer p { display: none; } /* 隱藏手機版用戶名 */
    .sidebar-footer a.button {
        padding: 5px 12px !important;
        font-size: 0.8rem !important;
    }
}

/* --- 按鈕系統 (強化版 - 解決消失問題) --- */
.button, button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 140, 0, 0.05); /* 預設半透明橘 */
    border: 1px solid var(--primary-color) !important;
    color: var(--primary-color) !important; /* 預設文字為橘色 */
    padding: 10px 20px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.3s;
    text-decoration: none !important;
}

/* 當滑鼠懸停 (Hover) 時，背景變橘色，文字「必須」變黑色 */
.button:hover, button:hover {
    background: var(--primary-color) !important;
    color: #000000 !important; /* 強制文字變黑色，確保清晰可見 */
    box-shadow: var(--glow-shadow);
}

/* 專門給「儲存設定」這種重要按鈕使用的樣式 (實心橘色) */
.button.save-btn {
    background: var(--primary-color) !important;
    color: #000000 !important; /* 直接設為黑色文字 */
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 140, 0, 0.4);
}

.button.save-btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 6px 20px rgba(255, 140, 0, 0.6);
}

/* 危險按鈕修復 */
.button.danger {
    border-color: var(--danger-color) !important;
    color: var(--danger-color) !important;
}
.button.danger:hover {
    background: var(--danger-color) !important;
    color: #ffffff !important; /* 危險按鈕懸停變白色文字 */
}

.button.success, button.success, .button-success, .button-success.small {
  border-color: var(--success-color) !important;
  color: var(--success-color) !important;
  background: rgba(76, 175, 80, 0.05);
}
.button.success:hover, button.success:hover, .button-success:hover {
  background: var(--success-color) !important;
  color: #000 !important;
  box-shadow: 0 0 10px var(--success-color);
}

/* --- 內容元件 --- */
.sidebar-brand { padding: 30px; font-family: 'Orbitron', sans-serif; color: var(--primary-color); text-decoration: none; text-shadow: var(--glow-shadow); font-weight: bold; }
.sidebar-brand span { color: #fff; }
.menu-label { padding: 15px 30px 5px; font-size: 0.7rem; color: #666; text-transform: uppercase; letter-spacing: 2px; }
.sidebar-menu a { display: flex; align-items: center; padding: 12px 30px; color: var(--text-color); text-decoration: none; transition: 0.3s; border-left: 4px solid transparent; font-size: 0.9rem; }
.sidebar-menu a i { margin-right: 15px; width: 20px; text-align: center; }
.sidebar-menu a:hover, .sidebar-menu a.active { background: rgba(255, 140, 0, 0.1); color: #fff; border-left-color: var(--primary-color); }

.content-container { padding: 20px; max-width: 1200px; margin: 0 auto; width: 100%; }
@media (min-width: 992px) { .content-container { padding: 40px; } }

.card { background: rgba(30, 20, 10, 0.5); border: 1px solid var(--border-color); padding: 25px; border-radius: 8px; margin-bottom: 25px; backdrop-filter: blur(10px); }
h1, h2 { font-family: 'Orbitron', sans-serif; color: var(--primary-color); margin-bottom: 20px; }
.description { font-size: 0.85rem; color: #aaa; margin-bottom: 15px; line-height: 1.6; }

/* Dashboard 特殊列表 */
.id-list { list-style: none; }
.id-list li {
  background: rgba(255, 140, 0, 0.05);
  border: 1px solid var(--border-color);
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}

/* Admin 統計卡片 */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 15px; margin-bottom: 25px; }
.stat-card { background: rgba(255,140,0,0.05); border: 1px solid var(--border-color); padding: 20px; border-radius: 8px; text-align: center; }
.stat-card h3 { font-size: 1.8rem; color: var(--primary-color); text-shadow: var(--glow-shadow); margin: 5px 0 0; }

/* 表格樣式 */
.table-responsive { width: 100%; overflow-x: auto; margin-bottom: 10px; border-radius: 6px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 700px; }
.data-table th { background: rgba(255, 140, 0, 0.1); color: var(--primary-color); padding: 12px; text-align: left; font-family: 'Orbitron'; font-size: 0.75rem; border-bottom: 2px solid var(--border-color); }
.data-table td { padding: 12px; border-bottom: 1px solid rgba(255, 140, 0, 0.05); font-size: 0.85rem; }

/* --- 摺疊選單 --- */
.category-item { background: var(--bg-secondary-color); border: 1px solid var(--border-color); border-radius: 8px; margin-bottom: 15px; overflow: hidden; }
.category-header { padding: 18px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: 0.3s; }
.category-header:hover { background: rgba(255, 140, 0, 0.08); }
.category-header h2 { margin: 0; font-size: 1rem; color: #fff; border: none; }
.category-content { display: none; padding: 20px; border-top: 1px solid var(--border-color); }
.category-item.open .category-content { display: block; }
.category-item.open .chevron { transform: rotate(180deg); }
.chevron { transition: 0.3s; color: var(--primary-color); }

/* --- 標籤與分頁 --- */
.nav-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 1px solid var(--border-color); flex-wrap: wrap; }
.nav-tabs a { padding: 10px 20px; color: #888; text-decoration: none; border-radius: 4px 4px 0 0; font-size: 0.85rem; font-family: 'Orbitron'; }
.nav-tabs a.active { background: rgba(255, 140, 0, 0.1); color: var(--primary-color); border-bottom: 2px solid var(--primary-color); }

.pagination-container { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; padding-top: 15px; border-top: 1px solid rgba(255,140,0,0.1); flex-wrap: wrap; gap: 10px; }
.pagination-info { font-size: 0.75rem; color: #666; font-family: 'Orbitron'; }

/* --- 表單 --- */
input, select, textarea { background: #111; border: 1px solid var(--border-color); color: #fff; padding: 10px; border-radius: 4px; width: 100%; margin: 8px 0; font-family: inherit; font-size: 0.9rem; }
input:focus, select:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 5px rgba(255,140,0,0.3); }

/* 閃爍動畫 */
.animate-in { animation: fadeIn 0.5s ease-out forwards; opacity: 0; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* 捲軸 */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-thumb { background: var(--primary-color); border-radius: 10px; }