/* ==========================================================================
   MQRT Admin Dashboard Stylesheet (Glassmorphism Dark Theme)
   Version: 2.1
   ========================================================================== */

:root {
    --bg-base: #070a11;
    --bg-card: rgba(16, 22, 35, 0.85);
    --bg-card-input: rgba(10, 14, 24, 0.9);
    --border-color: rgba(255, 255, 255, 0.1);
    --border-focus: #38bdf8;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #38bdf8;
    --accent-indigo: #6366f1;
    --accent-green: #22c55e;
    --accent-amber: #f59e0b;
    --accent-red: #ef4444;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans TC", sans-serif;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* 背景光暈裝飾 */
.background-decorations {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 0;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.18;
}

.blob-1 { width: 500px; height: 500px; background: #2563eb; top: -100px; left: -100px; }
.blob-2 { width: 450px; height: 450px; background: #7c3aed; bottom: -100px; right: -100px; }

/* 登入牆 (Login Overlay) */
.login-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(3, 7, 18, 0.88);
    backdrop-filter: blur(16px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1.5rem;
}

.login-card {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    max-width: 440px;
    width: 100%;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}

.lock-icon-circle {
    width: 60px; height: 60px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin: 0 auto 1.25rem;
}

.login-title { font-size: 1.35rem; font-weight: 700; margin-bottom: 0.5rem; }
.login-desc { font-size: 0.88rem; color: var(--text-secondary); margin-bottom: 1.5rem; line-height: 1.5; }

.input-wrapper input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem;
    color: #fff;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 5px;
    outline: none;
    margin-bottom: 0.5rem;
}

.input-wrapper input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.login-hint { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1.75rem; }

.login-actions {
    display: flex; gap: 1rem;
}

.btn-back-home, .btn-unlock-admin {
    flex: 1; padding: 0.8rem 1rem; border-radius: var(--radius-md);
    font-size: 0.92rem; font-weight: 600; text-decoration: none; cursor: pointer; border: none;
    transition: 0.2s;
}

.btn-back-home { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.btn-back-home:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.btn-unlock-admin { background: var(--accent-blue); color: #041226; }
.btn-unlock-admin:hover { background: #7dd3fc; }

/* 後台主頁面 */
.admin-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 4rem;
    position: relative;
    z-index: 1;
}

/* 頂部標頭 */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.brand-group {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.brand-logo {
    width: 52px; height: 52px;
    background: linear-gradient(135deg, #0284c7, #2563eb);
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.25rem;
}

.brand-logo span { color: #38bdf8; }

.header-title { font-size: 1.6rem; font-weight: 700; }
.header-subtitle { font-size: 0.88rem; color: var(--text-secondary); }

.header-actions { display: flex; gap: 0.75rem; }

.btn-header {
    padding: 0.6rem 1.1rem; border-radius: var(--radius-md); font-size: 0.85rem; font-weight: 600;
    text-decoration: none; cursor: pointer; border: 1px solid var(--border-color); transition: 0.2s;
}

.btn-view-portal { background: rgba(56, 189, 248, 0.12); color: var(--accent-blue); border-color: rgba(56, 189, 248, 0.3); }
.btn-view-portal:hover { background: rgba(56, 189, 248, 0.22); }
.btn-logout { background: rgba(239, 68, 68, 0.12); color: #f87171; border-color: rgba(239, 68, 68, 0.3); }
.btn-logout:hover { background: rgba(239, 68, 68, 0.22); }

/* 全域主密碼與統計面板 */
.master-panel {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2.5rem;
}

.master-key-card, .stats-card, .actions-card {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-label { font-size: 0.85rem; font-weight: 600; color: var(--accent-amber); margin-bottom: 0.6rem; }

.master-input-group {
    display: flex; gap: 0.5rem; align-items: center;
}

.master-input-group input {
    flex: 1;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    color: #fff;
    font-size: 1.1rem;
    letter-spacing: 2px;
    font-weight: 600;
}

.master-input-group input:focus { border-color: var(--accent-amber); outline: none; }

.btn-eye {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    color: #fff; cursor: pointer; transition: 0.2s;
}

.btn-eye:hover { background: rgba(255, 255, 255, 0.15); }

.master-note { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.6rem; }

.stats-card {
    flex-direction: row; align-items: center; justify-content: space-around;
}

.stat-item { text-align: center; }
.stat-num { font-size: 1.8rem; font-weight: 800; display: block; }
.color-lock { color: var(--accent-amber); }
.color-public { color: var(--accent-green); }
.stat-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.2rem; }

.actions-card { gap: 0.6rem; }

.btn-action {
    padding: 0.65rem 1rem; border-radius: var(--radius-sm); font-size: 0.88rem; font-weight: 600;
    cursor: pointer; border: none; transition: 0.2s; text-align: center;
}

.btn-add-card { background: var(--accent-indigo); color: #fff; }
.btn-add-card:hover { background: #4f46e5; }
.btn-save-all { background: var(--accent-green); color: #052e16; font-weight: 700; }
.btn-save-all:hover { background: #4ade80; }
.btn-reset { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary); }
.btn-reset:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

/* 卡片清單管理 */
.section-title-bar {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem;
}

.section-title-bar h2 { font-size: 1.25rem; font-weight: 700; }
.section-badge { font-size: 0.85rem; color: var(--text-secondary); }

.cards-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* 單一卡片編輯條 (Card Item) */
.card-edit-item {
    background: var(--bg-card);
    backdrop-filter: blur(14px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.card-edit-item:hover {
    border-color: rgba(56, 189, 248, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.item-top-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.item-icon-input {
    width: 52px;
    height: 48px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    text-align: center;
    color: #fff;
}

.item-title-input {
    flex: 2;
    min-width: 200px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
}

.item-url-input {
    flex: 2;
    min-width: 200px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 0.9rem;
    font-family: monospace;
    color: var(--accent-blue);
}

.item-badge-input {
    width: 140px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.item-category-select {
    width: 150px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 0.85rem;
    color: #fff;
}

.item-mid-row {
    display: flex;
    gap: 1rem;
}

.item-desc-input {
    flex: 1;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.9rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    resize: vertical;
}

.item-bottom-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.security-settings {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.pin-control-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.pin-control-group label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.item-pin-input {
    width: 110px;
    background: var(--bg-card-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.45rem 0.6rem;
    font-size: 0.95rem;
    color: var(--accent-amber);
    font-weight: 700;
    letter-spacing: 2px;
}

.item-pin-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.82rem;
    cursor: pointer;
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-item {
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    text-decoration: none;
    transition: 0.2s;
}

.btn-item-launch { background: rgba(56, 189, 248, 0.1); color: var(--accent-blue); border-color: rgba(56, 189, 248, 0.25); }
.btn-item-launch:hover { background: rgba(56, 189, 248, 0.2); }
.btn-item-delete { background: rgba(239, 68, 68, 0.1); color: #f87171; border-color: rgba(239, 68, 68, 0.25); }
.btn-item-delete:hover { background: rgba(239, 68, 68, 0.2); }

/* Modal 彈出視窗 */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1.5rem;
}

.modal-box {
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-lg);
    padding: 2.2rem;
    max-width: 580px;
    width: 100%;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute; top: 1rem; right: 1.25rem;
    background: none; border: none; color: var(--text-muted); font-size: 1.5rem; cursor: pointer;
}

.modal-box-title { font-size: 1.3rem; margin-bottom: 1.5rem; }

.form-group {
    margin-bottom: 1.1rem;
    display: flex; flex-direction: column; gap: 0.35rem;
}

.form-group label { font-size: 0.82rem; color: var(--text-secondary); font-weight: 500; }

.form-group input, .form-group textarea, .form-group select {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    color: #fff; font-size: 0.92rem; outline: none;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    border-color: var(--accent-blue);
}

.form-row { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }
.width-100 { width: 100px; }

.modal-form-actions { display: flex; gap: 0.75rem; margin-top: 1.5rem; }

.btn-cancel, .btn-confirm {
    flex: 1; padding: 0.75rem; border-radius: var(--radius-sm);
    font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none;
}

.btn-cancel { background: rgba(255, 255, 255, 0.08); color: var(--text-secondary); }
.btn-cancel:hover { background: rgba(255, 255, 255, 0.15); }
.btn-confirm { background: var(--accent-blue); color: #041226; }
.btn-confirm:hover { background: #7dd3fc; }

/* 浮動提示 Toast */
.toast-box {
    position: fixed;
    bottom: 2rem; right: 2rem;
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.4rem;
    color: #fff; font-size: 0.9rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    z-index: 99999;
    opacity: 0;
    transform: translateY(20px);
    transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
}

.toast-box.show {
    opacity: 1;
    transform: translateY(0);
}

/* 頁尾 */
.admin-footer {
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* RWD 適應 */
@media (max-width: 900px) {
    .master-panel { grid-template-columns: 1fr; }
    .item-top-row { flex-direction: column; align-items: stretch; }
    .item-bottom-row { flex-direction: column; align-items: stretch; }
}
