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

:root {
    --bg-color: #f5f5f5;
    --text-color: #333;
    --card-bg: #fff;
    --border-color: #eee;
    --sidebar-bg: linear-gradient(180deg, #2c3e50 0%, #1a252f 100%);
    --header-color: #2c3e50;
    --table-header-bg: #f8f9fa;
    --input-bg: #fff;
    --input-border: #ddd;
    --modal-bg: #fff;
    --shadow: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] {
    --bg-color: #1a1a2e;
    --text-color: #eee;
    --card-bg: #16213e;
    --border-color: #0f3460;
    --sidebar-bg: linear-gradient(180deg, #0f0f23 0%, #16213e 100%);
    --header-color: #eee;
    --table-header-bg: #0f3460;
    --input-bg: #16213e;
    --input-border: #0f3460;
    --modal-bg: #16213e;
    --shadow: rgba(0, 0, 0, 0.3);
}

body {
    font-family: 'Microsoft JhengHei', 'PingFang TC', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* 左側選單 */
.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: #fff;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

/* 暗黑模式切換按鈕 */
.dark-mode-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s;
}

.dark-mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-header {
    position: relative;
}

.sidebar-header {
    padding: 20px;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.menu {
    list-style: none;
    padding: 10px 0;
}

.menu-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 20px;
    color: #ecf0f1;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 0.95rem;
}

.menu-item a i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.menu-item a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    padding-left: 25px;
}

.menu-item.active a {
    background-color: #3498db;
    border-left: 4px solid #fff;
}

/* 右側內容區域 */
.content {
    flex: 1;
    margin-left: 220px;
    padding: 30px;
    background-color: var(--bg-color);
}

.content-header {
    background: var(--card-bg);
    padding: 20px 25px;
    border-radius: 8px;
    margin-bottom: 25px;
    box-shadow: 0 2px 10px var(--shadow);
}

.content-header h1 {
    font-size: 1.8rem;
    color: var(--header-color);
    font-weight: 600;
}

.content-body {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow);
    min-height: 400px;
}

/* 卡片樣式 */
.card {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 10px var(--shadow);
    position: relative;
}

.card-title {
    font-size: 1.2rem;
    color: var(--header-color);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid #3498db;
}

/* 卡片操作按鈕 */
.card-actions {
    position: absolute;
    top: 8px;
    right: 10px;
    display: flex;
    gap: 10px;
}

.card-edit-btn,
.card-delete-btn {
    font-size: 16px;
    color: #999;
    cursor: pointer;
    transition: color 0.2s;
}

.card-edit-btn:hover {
    color: #3498db;
}

.card-delete-btn {
    font-size: 20px;
    line-height: 1;
}

.card-delete-btn:hover {
    color: #e74c3c;
}

/* 表格樣式 */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.table th,
.table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.table th {
    background-color: var(--table-header-bg);
    font-weight: 600;
    color: var(--header-color);
}

.table tr:hover {
    background-color: var(--table-header-bg);
}

.inline-add-row {
    display: none;
}

.inline-add-card {
    display: none;
}

.inline-edit.inline-edit-always {
    display: block;
}

.inline-edit {
    display: none;
}

.inline-edit .form-control {
    margin-top: 6px;
}

.inline-edit-row {
    margin-top: 6px;
}

.inline-actions {
    margin-top: 8px;
    display: flex;
    gap: 8px;
}

.inline-actions .btn {
    padding: 4px 10px;
    font-size: 0.85rem;
}

/* 操作按鈕列：+ 匯出 Appwrite 匯出 Laravel 匯入 CSV 全選模式 */
.action-buttons-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 0;
}

.action-buttons-bar .btn,
.action-buttons-bar .csv-buttons .btn,
.action-buttons-bar .csv-buttons a {
    flex-shrink: 0;
}

.action-buttons-bar #selectModeBtn {
    flex-shrink: 0;
}

.modal.inline-mode {
    position: static;
    background: transparent;
    width: auto;
    height: auto;
    display: block;
}

.modal.inline-mode .modal-content {
    max-width: none;
    width: 100%;
    box-shadow: none;
}

/* 按鈕樣式 */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background-color: #3498db;
    color: #fff;
}

.btn-primary:hover {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: #fff;
}

.btn-danger {
    background-color: #e74c3c;
    color: #fff;
}

/* 表單樣式 */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--header-color);
}

.form-control {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--input-border);
    border-radius: 5px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    background-color: var(--input-bg);
    color: var(--text-color);
}

.form-control:focus {
    outline: none;
    border-color: #3498db;
}

/* 小按鈕 */
.btn-sm {
    padding: 5px 10px;
    font-size: 0.8rem;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Badge 標籤 */
.badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background-color: #d4edda;
    color: #155724;
}

.badge-danger {
    background-color: #f8d7da;
    color: #721c24;
}

/* Modal 彈窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: var(--modal-bg);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #999;
}

.modal-close:hover {
    color: #333;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--header-color);
}

/* 表單行 */
.form-row {
    display: flex;
    gap: 15px;
}

/* Textarea */
textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* 卡片網格 */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.12);
    transition: all 0.3s ease;
}

/* 響應式設計 */
@media (max-width: 768px) {

    /* 側邊欄 - 預設完全隱藏，點擊後疊加顯示 */
    .sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0;
        width: 260px;
        height: 100vh;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        visibility: hidden;
    }

    .sidebar.open {
        transform: translateX(0);
        visibility: visible;
    }

    /* 側邊欄遮罩 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1999;
    }

    .sidebar-overlay.show {
        display: block;
    }

    /* 主內容區 - 手機版完全佔滿螢幕，無左側空白 */
    .content {
        margin-left: 0 !important;
        padding: 15px !important;
        padding-top: 70px !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 1;
    }

    .container {
        flex-direction: column;
        width: 100%;
    }

    /* 漢堡選單按鈕 */
    .mobile-menu-btn {
        display: flex !important;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 2001;
        background: linear-gradient(135deg, #667eea, #764ba2);
        color: white;
        border: none;
        width: 44px;
        height: 44px;
        padding: 0;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 1.2rem;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    }

    /* 標題調整 */
    .content-header h1 {
        font-size: 1.5rem;
    }

    /* 手機版/桌面版切換 */
    .mobile-only {
        display: block !important;
    }
    .desktop-only {
        display: none !important;
    }

    /* 表格響應式 */
    .table {
        font-size: 0.85rem;
    }

    .table th,
    .table td {
        padding: 8px 6px;
    }

    /* 隱藏部分表格欄位 */
    .table .hide-mobile {
        display: none;
    }

    /* 通用手機版卡片樣式 */
    .mobile-card {
        background: var(--card-bg, #fff);
        border-radius: 12px;
        padding: 16px;
        margin-bottom: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        position: relative;
    }
    .mobile-card-actions {
        position: absolute;
        top: 12px;
        right: 12px;
        display: flex;
        gap: 12px;
    }
    .mobile-card-actions .card-edit-btn,
    .mobile-card-actions .card-delete-btn {
        font-size: 18px;
        padding: 5px;
    }
    .mobile-card-header {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 10px;
        padding-right: 60px;
    }
    .mobile-card-title {
        font-size: 1.1rem;
        font-weight: 600;
        color: var(--header-color, #2c3e50);
    }
    .mobile-card-info {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        background: var(--bg-color, #f5f5f5);
        padding: 12px;
        border-radius: 8px;
        margin-top: 10px;
    }
    .mobile-card-item {
        flex: 1;
        min-width: 80px;
    }
    .mobile-card-label {
        display: block;
        font-size: 0.75rem;
        color: #999;
        margin-bottom: 2px;
    }
    .mobile-card-value {
        font-size: 0.95rem;
        font-weight: 500;
        color: var(--text-color, #333);
    }
    .mobile-card-note {
        font-size: 0.85rem;
        color: #888;
        margin-top: 8px;
    }

    /* 按鈕組 */
    .btn-group,
    .content-header .btn {
        flex-wrap: wrap;
        gap: 8px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .btn-sm {
        padding: 4px 8px;
        font-size: 0.75rem;
    }

    /* 表單行 */
    .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* 彈窗 */
    .modal-content {
        width: 95%;
        max-width: none;
        padding: 20px;
        margin: 10px;
        max-height: 85vh;
    }

    /* 歌詞面板 - 手機版移到底部 */
    .lyrics-panel {
        position: fixed;
        right: 0;
        bottom: 60px;
        left: 0;
        top: auto;
        width: 100%;
        height: 40vh;
        max-height: 40vh;
        border-radius: 15px 15px 0 0;
        z-index: 1500;
    }

    .lyrics-panel .lyrics-header {
        padding: 10px 15px;
    }

    .lyrics-panel .lyrics-content {
        padding: 10px 15px;
        font-size: 0.9rem;
    }

    /* 音樂播放器 */
    #musicPlayerBar {
        padding: 8px 15px;
    }

    #musicPlayerBar .player-title {
        font-size: 0.85rem;
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* 兩層選擇彈窗 */
    .two-layer-modal .modal-content {
        padding: 15px;
    }

    .two-layer-lang-btn,
    .two-layer-sub-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    /* 卡片網格 */
    .card-grid {
        grid-template-columns: 1fr;
    }

    /* 版本管理彈窗 */
    #versionsModal .modal-content {
        width: 95%;
    }
}

/* 更小螢幕的額外調整 */
@media (max-width: 480px) {
    .content {
        padding: 10px;
        padding-top: 65px;
    }

    .content-header h1 {
        font-size: 1.3rem;
    }

    .table {
        font-size: 0.8rem;
    }

    .btn-sm {
        padding: 3px 6px;
        font-size: 0.7rem;
    }

    /* 播放器更緊湊 */
    #musicPlayerBar audio {
        width: 100px;
    }
}

/* 漢堡選單 - 桌面版隱藏 */
.mobile-menu-btn {
    display: none;
}

/* 手機版/桌面版切換 - 預設值 */
.mobile-only {
    display: none;
}
.desktop-only {
    display: block;
}
table.desktop-only {
    display: table;
}

/* 側邊欄遮罩 - 桌面版隱藏 */
.sidebar-overlay {
    display: none;
}

/* 150% 縮放和中等螢幕優化 (約 1280px 以下，相當於 150% 縮放) */
@media (max-width: 1280px) {
    .sidebar {
        width: 180px;
    }

    .content {
        margin-left: 180px;
        padding: 20px;
    }

    /* 歌詞面板適應 */
    .lyrics-panel {
        width: 280px;
    }

    .table {
        font-size: 0.9rem;
    }

    .btn {
        padding: 8px 14px;
        font-size: 0.9rem;
    }

    /* 彈窗內表單行改為單欄 */
    .modal-content .form-row {
        flex-direction: column;
        gap: 0;
    }

    /* 彈窗寬度調整 */
    .modal-content {
        max-width: 450px;
    }
}

/* 更高縮放級別 (約 1024px 以下) */
@media (max-width: 1024px) {
    .sidebar {
        width: 160px;
    }

    .content {
        margin-left: 160px;
        padding: 15px;
    }

    .lyrics-panel {
        width: 250px;
    }

    .content-header h1 {
        font-size: 1.4rem;
    }

    .table th,
    .table td {
        padding: 10px 8px;
    }

    /* 隱藏非必要欄位 */
    .table .hide-zoom {
        display: none;
    }

    .btn-sm {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}
