/* AWS Lightsail 监控面板 - 多主题支持 */

/* ========== 主题定义 ==========
   所有主题都用白底（按紫枫要求），只换强调色/边框/文字
   ============================================= */

/* 默认紫色 */
:root, [data-theme="purple"] {
    --bg: #ffffff;
    --bg-soft: #f8f7fc;
    --surface: #ffffff;
    --surface-2: #f3f1f8;
    --text: #1f1f2e;
    --muted: #6b6b80;
    --primary: #a78bfa;
    --primary-strong: #8b5cf6;
    --primary-soft: rgba(167, 139, 250, .12);
    --primary-text: #ffffff;
    --accent: #f472b6;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #e8e5ef;
    --shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-lg: 0 4px 12px rgba(0,0,0,.08);
}

[data-theme="blue"] {
    --bg: #ffffff;
    --bg-soft: #f0f7ff;
    --surface: #ffffff;
    --surface-2: #e8f1fb;
    --text: #1a2433;
    --muted: #5b6b80;
    --primary: #60a5fa;
    --primary-strong: #3b82f6;
    --primary-soft: rgba(96, 165, 250, .12);
    --primary-text: #ffffff;
    --accent: #38bdf8;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #e1ebf5;
    --shadow: 0 1px 3px rgba(96,165,250,.06), 0 1px 2px rgba(96,165,250,.04);
    --shadow-lg: 0 4px 12px rgba(96,165,250,.08);
}

[data-theme="green"] {
    --bg: #ffffff;
    --bg-soft: #f0faf4;
    --surface: #ffffff;
    --surface-2: #e8f5ee;
    --text: #1a2e22;
    --muted: #5b7a68;
    --primary: #22c55e;
    --primary-strong: #16a34a;
    --primary-soft: rgba(34, 197, 94, .12);
    --primary-text: #ffffff;
    --accent: #34d399;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #dfeedf;
    --shadow: 0 1px 3px rgba(34,197,94,.06), 0 1px 2px rgba(34,197,94,.04);
    --shadow-lg: 0 4px 12px rgba(34,197,94,.08);
}

[data-theme="amber"] {
    --bg: #ffffff;
    --bg-soft: #fffbeb;
    --surface: #ffffff;
    --surface-2: #fff4d6;
    --text: #2e2310;
    --muted: #7a6e4f;
    --primary: #f59e0b;
    --primary-strong: #d97706;
    --primary-soft: rgba(245, 158, 11, .12);
    --primary-text: #ffffff;
    --accent: #f97316;
    --ok: #84cc16;
    --warn: #f59e0b;
    --danger: #dc2626;
    --border: #faecbf;
    --shadow: 0 1px 3px rgba(245,158,11,.06), 0 1px 2px rgba(245,158,11,.04);
    --shadow-lg: 0 4px 12px rgba(245,158,11,.08);
}

[data-theme="rose"] {
    --bg: #ffffff;
    --bg-soft: #fff5f9;
    --surface: #ffffff;
    --surface-2: #ffe9f1;
    --text: #2e0e1e;
    --muted: #7a4d65;
    --primary: #f472b6;
    --primary-strong: #db2777;
    --primary-soft: rgba(244, 114, 182, .12);
    --primary-text: #ffffff;
    --accent: #ec4899;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #fbd8e3;
    --shadow: 0 1px 3px rgba(244,114,182,.06), 0 1px 2px rgba(244,114,182,.04);
    --shadow-lg: 0 4px 12px rgba(244,114,182,.08);
}

[data-theme="slate"] {
    --bg: #ffffff;
    --bg-soft: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #ecf0f5;
    --text: #1e293b;
    --muted: #64748b;
    --primary: #64748b;
    --primary-strong: #475569;
    --primary-soft: rgba(100, 116, 139, .12);
    --primary-text: #ffffff;
    --accent: #94a3b8;
    --ok: #10b981;
    --warn: #f59e0b;
    --danger: #ef4444;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(100,116,139,.06), 0 1px 2px rgba(100,116,139,.04);
    --shadow-lg: 0 4px 12px rgba(100,116,139,.08);
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    font-size: 14px;
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
}
.topbar .brand { font-size: 1.1rem; font-weight: 600; color: var(--primary-strong); }
.topbar nav { display: flex; gap: 1rem; align-items: center; }
.topbar nav a { color: var(--text); padding: .25rem .5rem; border-radius: 4px; }
.topbar nav a:hover { background: var(--primary-soft); text-decoration: none; }
.topbar .user { color: var(--muted); font-size: .9rem; }
.topbar .user-menu { color: var(--text); padding: .25rem .5rem; }

.container { max-width: 1280px; margin: 0 auto; padding: 1.5rem; }

.footer {
    text-align: center; padding: 1.5rem; color: var(--muted); font-size: .85rem;
    border-top: 1px solid var(--border);
    background: var(--bg-soft);
    margin-top: 2rem;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}
.card.narrow { max-width: 420px; margin: 4rem auto; }
.card h1, .card h3 { margin-top: 0; }
.card-head {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 1rem;
}
.card-foot {
    margin-top: 1rem; padding-top: .75rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
    font-size: .85rem;
}
.card-foot .muted { color: var(--muted); }

.page-actions {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.5rem;
}
.page-actions h1 { margin: 0; font-size: 1.5rem; }
.page-actions .actions { display: flex; gap: .5rem; }

.btn {
    display: inline-block;
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    padding: .5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: .9rem;
    text-decoration: none;
    transition: all .15s;
}
.btn:hover { background: var(--primary-soft); border-color: var(--primary); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); font-weight: 600; }
.btn.primary:hover { background: var(--primary-strong); border-color: var(--primary-strong); }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: white; }
.btn.small { padding: .3rem .6rem; font-size: .8rem; }
button.link {
    background: none; border: none; color: var(--primary);
    cursor: pointer; font-size: inherit; padding: 0;
}

.alert {
    padding: .75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.alert.error { background: rgba(239,68,68,.08); color: #b91c1c; border: 1px solid #fecaca; }
.alert.success { background: rgba(16,185,129,.08); color: #047857; border: 1px solid #a7f3d0; }

.badge {
    display: inline-block; padding: .15rem .55rem;
    border-radius: 999px; font-size: .75rem;
    background: var(--surface-2);
}
.badge.ok { background: rgba(16,185,129,.12); color: #047857; }
.badge.warn { background: rgba(245,158,11,.12); color: #b45309; }

/* ========== 主题切换器 ========== */
.theme-switcher { position: relative; }
.theme-switcher summary {
    list-style: none;
    cursor: pointer;
    padding: .25rem .55rem;
    border-radius: 4px;
    color: var(--text);
    font-size: .85rem;
    user-select: none;
}
.theme-switcher summary::-webkit-details-marker { display: none; }
.theme-switcher summary:hover { background: var(--primary-soft); }
.theme-switcher[open] summary { background: var(--primary-soft); }
.theme-menu {
    position: absolute;
    top: 100%; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: .4rem;
    margin-top: .25rem;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    min-width: 130px;
}
.theme-form { display: block; margin: 0; }
.theme-btn {
    display: flex; align-items: center; gap: .5rem;
    width: 100%;
    background: transparent;
    border: none;
    padding: .4rem .55rem;
    border-radius: 4px;
    cursor: pointer;
    color: var(--text);
    font-size: .85rem;
    text-align: left;
}
.theme-btn:hover { background: var(--primary-soft); }
.theme-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.theme-btn .dot {
    display: inline-block;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 1px solid rgba(0,0,0,.1);
}
.theme-purple .dot { background: #a78bfa; }
.theme-blue .dot { background: #3b82f6; }
.theme-green .dot { background: #22c55e; }
.theme-amber .dot { background: #f59e0b; }
.theme-rose .dot { background: #ec4899; }
.theme-slate .dot { background: #64748b; }

label {
    display: block;
    margin-bottom: .75rem;
    color: var(--muted);
    font-size: .85rem;
}
label.checkbox { display: flex; align-items: center; gap: .5rem; color: var(--text); }
input, select, textarea {
    display: block;
    width: 100%;
    padding: .5rem .75rem;
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: .9rem;
    font-family: inherit;
    margin-top: .25rem;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
input[type="checkbox"] { width: auto; display: inline-block; margin: 0; }

button[type="submit"] {
    background: var(--primary);
    color: var(--primary-text);
    border: none;
    padding: .6rem 1.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 1rem;
}
button[type="submit"]:hover { background: var(--primary-strong); }

.grid { display: grid; gap: 1.5rem; }
.grid.instances {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
}
.grid.form { grid-template-columns: 1fr 1fr 1fr; gap: 1.5rem; }
@media (max-width: 1024px) { .grid.form { grid-template-columns: 1fr; } }

.instance { padding: 1rem; }
.instance.offline { opacity: .65; }
.instance .name { font-size: 1.1rem; font-weight: 600; color: var(--text); }
.instance .host { font-size: .8rem; color: var(--muted); margin-top: .15rem; }

.metrics {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem;
    margin: 1rem 0;
}
.metric { text-align: center; }
.metric .label { font-size: .7rem; color: var(--muted); text-transform: uppercase; }
.metric .value { font-size: 1.25rem; font-weight: 600; color: var(--primary); margin-top: .15rem; }

.quota { margin-top: 1rem; }
.quota-label {
    display: flex; justify-content: space-between;
    font-size: .8rem; color: var(--muted); margin-bottom: .25rem;
}
.bar {
    background: var(--bg-soft);
    border-radius: 4px; height: 8px; overflow: hidden;
}
.bar .fill {
    background: var(--primary);
    height: 100%;
    transition: width .3s, background .3s;
}
.bar .fill.warn { background: var(--warn); }
.bar .fill.danger { background: var(--danger); }
.quota-pct {
    text-align: right; font-size: .75rem; color: var(--muted); margin-top: .25rem;
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .75rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
.table tr.disabled { opacity: .55; }
.table .muted { color: var(--muted); }
.table .center { text-align: center; }
.actions-cell { white-space: nowrap; display: flex; gap: .35rem; }
.actions-cell form { display: inline; }

.muted { color: var(--muted); }
code { background: var(--bg-soft); padding: 1px 4px; border-radius: 3px; font-size: .85em; }

.chart-box {
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    margin: 1rem 0;
    min-height: 180px;
}
canvas { max-height: 240px; }

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

.loading { color: var(--muted); padding: 2rem; text-align: center; }
.empty { text-align: center; color: var(--muted); padding: 3rem; }