:root {
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --sidebar-bg: #1e293b;
    --text-main: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
}

[v-cloak] { display: none; }

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

.sidebar {
    width: 260px;
    min-width: 260px;
    background-color: var(--sidebar-bg);
    color: white;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
}

/* 側邊欄遮罩（窄屏用） */
.sidebar-overlay {
    display: none;
}

/* 品牌區含關閉按鈕 */
.brand {
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-close {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: all 0.2s;
}

.sidebar-close:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

/* 漢堡選單按鈕（sidebar 隱藏時顯示） */
.hamburger-btn {
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 50;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s;
    color: var(--text-main);
}

.hamburger-btn:hover {
    background: #f1f5f9;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    transform: scale(1.05);
}

/* sidebar 隱藏時，header 左邊留空間給漢堡按鈕 */
.sidebar.collapsed ~ .main-content .top-header {
    padding-left: 72px;
}

/* 響應式：窄螢幕自動隱藏側邊欄 */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        box-shadow: 4px 0 20px rgba(0,0,0,0.3);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 260px;
        min-width: 260px;
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.4);
        z-index: 90;
    }
}

.nav-list {
    list-style: none;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s;
    color: #cbd5e1;
}

.nav-item:hover, .nav-item.active {
    background-color: rgba(255,255,255,0.1);
    color: white;
}

.nav-icon { margin-right: 12px; }

.nav-arrow { font-size: 10px; color: #94a3b8; transition: transform 0.2s; }
.nav-arrow.open { transform: rotate(180deg); }

.sub-nav-list { list-style: none; padding: 4px 0 12px 44px; margin: 0; background: rgba(0,0,0,0.15); border-bottom-left-radius: 8px; border-bottom-right-radius: 8px; }
.sub-nav-item { padding: 10px 16px; font-size: 13px; color: #cbd5e1; cursor: pointer; transition: 0.2s; border-radius: 6px; margin-right: 16px; margin-bottom: 2px; }
.sub-nav-item:hover, .sub-nav-item.active { background: rgba(255,255,255,0.1); color: white; font-weight: 500; }

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.top-header {
    background: var(--bg-card);
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.subtitle { color: var(--text-muted); margin-top: 4px; font-size: 14px; }

.content-wrapper { padding: 32px; }

.card {
    background: var(--bg-card);
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    overflow-x: auto; /* 允許表格過寬時橫向捲動 */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* 確保表格不會被過度擠壓 */
}

.data-table th, .data-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap; /* 防止文字垂直折行 */
}

.data-table th {
    background: #f1f5f9;
    font-size: 13px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.code-box {
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 13px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.status-badge.active { background: #dcfce7; color: #166534; }
.status-badge.inactive { background: #fee2e2; color: #991b1b; }

.fw-600 { font-weight: 600; }
.text-center { text-align: center; }
.text-danger { color: var(--danger) !important; }
.mt-3 { margin-top: 16px; }
.w-100 { width: 100%; }
.empty-state { padding: 40px !important; color: var(--text-muted); }

/* Buttons */
button { cursor: pointer; border: none; outline: none; font-family: inherit; border-radius: 6px; font-weight: 500; transition: 0.2s; }
.primary-btn { background: var(--primary); color: white; padding: 10px 20px; }
.primary-btn:hover:not(:disabled) { background: var(--primary-hover); }
.primary-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.secondary-btn { background: #e2e8f0; color: var(--text-main); padding: 10px 20px; }
.secondary-btn:hover { background: #cbd5e1; }
.action-btn { background: #e2e8f0; color: var(--text-main); padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.action-btn:hover { background: #cbd5e1; }

/* Modal */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    display: flex; justify-content: center; align-items: center;
    z-index: 1000;
}

.modal {
    background: white; border-radius: 12px; width: 480px; max-width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}

.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.close-btn { background: none; font-size: 20px; color: var(--text-muted); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 12px; }

.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-group label, .credential-box label { font-size: 14px; font-weight: 600; color: var(--text-main); }
.form-input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 15px; outline: none; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); }
.mono { font-family: monospace; letter-spacing: 0.5px; }

.copy-group { display: flex; gap: 8px; }
.copy-group .form-input { flex: 1; background: #f8fafc; }
.copy-btn { background: #f1f5f9; color: var(--primary); padding: 0 16px; border: 1px solid var(--border); }
.copy-btn:hover { background: #e2e8f0; }

.alert-box { padding: 12px 16px; border-radius: 8px; margin-bottom: 24px; font-size: 14px; line-height: 1.5; }
.alert-box.warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.alert-box.danger { background: #fef2f2; color: #b91c1c; border: 1px solid #f87171; }

/* API Docs Styles */
.p-6 { padding: 32px; }
.doc-title { font-size: 24px; color: var(--text-main); margin-bottom: 16px; }
.doc-divider { border: 0; border-bottom: 1px solid var(--border); margin-bottom: 32px; }
.doc-section { margin-bottom: 40px; }
.doc-section h3 { font-size: 18px; margin-bottom: 12px; color: var(--text-main); }
.doc-section p { margin-bottom: 16px; color: var(--text-muted); line-height: 1.6; }
.doc-section h4 { font-size: 14px; margin-bottom: 8px; margin-top: 24px; color: var(--text-main); }
.endpoint { display: inline-flex; align-items: center; background: #f8fafc; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; margin-bottom: 16px; }
.method { padding: 6px 12px; font-weight: 700; font-size: 13px; color: white; }
.method.post { background: #10b981; }
.url { padding: 6px 16px; font-family: monospace; font-size: 14px; color: var(--text-main); }
.code-block { background: #1e293b; color: #f8fafc; padding: 16px; border-radius: 8px; overflow-x: auto; font-family: monospace; font-size: 13px; line-height: 1.5; }
.code-block code { font-family: monospace; }
.pdf-btn { display: flex; align-items: center; gap: 8px; background: #ef4444; }
.pdf-btn:hover { background: #dc2626; }
.icon { font-size: 16px; }

/* Architecture Flow Diagram */
.arch-flow {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 20px 0;
    overflow-x: auto;
    flex-wrap: nowrap;
}

.arch-node {
    min-width: 110px;
    padding: 14px 16px;
    border-radius: 12px;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.arch-node small {
    display: block;
    font-weight: 400;
    opacity: 0.85;
    font-size: 0.7rem;
    margin-top: 2px;
}

.arch-arrow {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #94A3B8;
    padding: 0 6px;
    flex-shrink: 0;
    line-height: 1.2;
}

.arch-arrow small {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    margin-top: 2px;
}

.expiry-date.expired {
    color: var(--danger);
    font-weight: 600;
}

/* ========================================== */
/* Login Overlay Styles (Glassmorphism) */
/* ========================================== */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.login-card {
    background: rgba(30, 41, 59, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header h2 {
    color: #fff;
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 30px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    transition: all 0.2s ease;
    text-align: center;
    letter-spacing: 2px;
}

.login-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.login-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 15px;
    background: rgba(239, 68, 68, 0.1);
    padding: 8px;
    border-radius: 6px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.logout-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.2);
}
