/* =========================================
   新追加的通用樣式 (配合 HTML 修改)
   ========================================= */

/* 頂部登入區塊 */
.auth-box {
    background: #f1f1f1;
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-box input {
    width: 200px; /* 預設桌面寬度 */
}

.btn-logout {
    margin-left: 10px;
    padding: 5px 10px;
    cursor: pointer;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
}

/* 搜尋區塊 */
.search-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 40px;
    margin-bottom: 15px;
    flex-wrap: wrap; /* 允許換行 */
    gap: 10px;
}

.search-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* 表格捲動容器 */
.table-wrapper {
    width: 100%;
    overflow-x: auto; /* 內容太寬時出現卷軸 */
    -webkit-overflow-scrolling: touch; /* 讓 iOS 滑動更順暢 */
}

/* 新增一些 UI 元素樣式 */
#statusBox {
    display: none; /* 預設隱藏 */
    margin-top: 20px;
    padding: 15px;
    background: #eef2f7;
    border-radius: 8px;
}

.badge {
    background: #edf2f7;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    color: #4a5568;
}

.note-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    color: #666;
}

.btn-mini {
    padding: 2px 4px;
    font-size: 10px;
    border: 1px solid #cbd5e0;
    background: white;
    border-radius: 3px;
    cursor: pointer;
}

.btn-action, .btn-test {
    padding: 6px 12px;
    border-radius: 4px;
    border: 1px solid #cbd5e0;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: 0.2s;
}

.btn-action:hover { background: #f7fafc; border-color: #3498db; }

.btn-submit:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}
/* 全域設定 */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 40px auto;
    max-width: 1100px;
    background-color: #f4f7f9;
    color: #333;
    line-height: 1.6;
}

.container {
    background: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

h2 {
    color: #2c3e50;
    border-left: 5px solid #3498db;
    padding-left: 15px;
    margin-bottom: 30px;
}

/* 表單佈局 */
.form-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    background: #fafbfc;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #edf2f7;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.full-width {
    grid-column: span 2;
}

label {
    font-weight: 600;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: #4a5568;
}

input, select, textarea {
    padding: 8px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
}

input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* 按鈕樣式 */
.btn-submit {
    background-color: #28a745;
    color: white;
    border: none;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    margin-top: 10px;
}

.btn-submit:hover { background-color: #218838; }

/* 表格樣式 */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

th, td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

th {
    background-color: #f8fafc;
    font-size: 0.85em;
    color: #718096;
    text-transform: uppercase;
}

/* 狀態樣式 */
.status-active { color: #38a169; font-weight: bold; }
.status-inactive { color: #e53e3e; }

.row-disabled {
    background-color: #f9f9f9;
    color: #a0aec0;
}

.row-disabled .sha256-text {
    opacity: 0.5;
}

/* SHA-256 特殊顯示 */
.sha256-text {
    font-family: 'Consolas', monospace;
    background: #edf2f7;
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 0.9em;
}

/* 複製與測試按鈕 */
.btn-copy, .btn-toggle {
    cursor: pointer;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    padding: 2px 6px;
    transition: all 0.2s;
}

.btn-copy:hover { background: #e2e8f0; }

/* 搜尋框 */
#searchInput {
    border-radius: 20px;
    padding-left: 15px;
    width: 200px;
}

.hidden {
    display: none !important;
}

/* =========================================
   📱 Mobile RWD 手機版專用設定 (Media Query)
   當螢幕寬度小於 768px 時生效
   ========================================= */
@media (max-width: 768px) {

    /* 1. 調整整體邊距，避免浪費手機空間 */
    body {
        margin: 10px;
        padding: 0;
    }

    .container {
        padding: 15px;
        width: auto; /* 讓寬度自動適應 */
    }

    h2 {
        font-size: 1.2rem; /* 標題縮小一點 */
        margin-bottom: 20px;
    }

    /* 2. 登入區塊變垂直排列 */
    .auth-box {
        flex-direction: column; /* 改為直向 */
        align-items: stretch;   /* 寬度拉滿 */
    }

    .auth-box input {
        width: 100% !important; /* 強制填滿寬度 */
        box-sizing: border-box; /* 包含 padding */
    }

    .btn-logout {
        margin-left: 0;
        margin-top: 5px;
        width: 100%;
        padding: 8px;
    }

    /* 3. 表單區塊從 2 欄變成 1 欄 */
    .form-section {
        grid-template-columns: 1fr; /* 強制單欄 */
        gap: 10px;
        padding: 15px;
    }

    /* 讓原本跨兩欄的元素 (full-width) 在手機版也只佔 1 欄 */
    .full-width {
        grid-column: span 1;
    }

    /* 4. 搜尋與標題區塊調整 */
    .search-box {
        flex-direction: column; /* 標題與搜尋框垂直排列 */
        align-items: flex-start;
        margin-top: 25px;
    }

    .search-controls {
        width: 100%;
        flex-wrap: wrap; /* 如果按鈕太多，允許換行 */
        gap: 10px;
    }

    #searchInput {
        width: 100%; /* 搜尋框填滿 */
        box-sizing: border-box;
    }

    /* 5. 表格優化 */
    table {
        min-width: 600px; /* 設定最小寬度，強迫出現卷軸 */
    }

    th, td {
        padding: 8px; /* 減少內距 */
        font-size: 13px; /* 字體縮小 */
    }

    /* 隱藏較不重要的欄位 (選用) - 這裡示範隱藏 SHA256 */
    /* .sha256-text, th:nth-child(4) { display: none; } */

    /* 按鈕好按一點 */
    .btn-action, .btn-test {
        padding: 8px 12px;
        margin-bottom: 2px;
    }
}