/* ====================================================================
   KTO DASHBOARD — 共用設計基底 (Design Tokens & Primitives)
   側邊欄 SaaS 儀表板風格：深灰底、紫/淺紫/藍點綴，卡片式版面。
   ==================================================================== */

:root {
    /* Brand colors */
    --primary-purple: #8b6cf7;
    --secondary-purple: #b4a1ff;
    --light-purple: #4f8cff;      /* used as the "blue" accent */
    --dark-purple: #5b3fd6;
    --accent-color: #b4a1ff;
    --accent-green: #34d399;

    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #8b6cf7, #4f8cff);
    --secondary-gradient: linear-gradient(135deg, #6c5ce7, #4f8cff);
    --tertiary-gradient: linear-gradient(135deg, #e0455c, #ff3742);
    --accent-gradient: linear-gradient(90deg, #8b6cf7, #4f8cff);

    /* Status colors */
    --success-color: #34d399;
    --warning-color: #f0b84f;
    --error-color: #ef5a5a;
    --info-color: #4f8cff;

    /* Surfaces — 深灰階系統（不是純黑，帶一點藍紫調） */
    --bg-page: #17171d;
    --bg-sidebar: #131317;
    --surface-1: #1e1e26;
    --surface-2: #26262f;
    --surface-3: #2e2e39;
    --surface-sunken: #0e0e12;
    --border-hairline: rgba(255, 255, 255, 0.07);
    --border-hairline-strong: rgba(255, 255, 255, 0.13);
    --border-accent: rgba(139, 108, 247, 0.35);

    /* Legacy aliases kept for compatibility with existing rules */
    --glass-bg: var(--surface-1);
    --glass-bg-strong: var(--surface-2);
    --glass-border: var(--border-hairline);

    /* Text */
    --text-primary: #f5f5f8;
    --text-secondary: rgba(245, 245, 248, 0.72);
    --text-muted: rgba(245, 245, 248, 0.46);
    --text-faint: rgba(245, 245, 248, 0.28);

    /* Elevation */
    --shadow-primary: 0 1px 0 rgba(255,255,255,0.03) inset, 0 10px 30px rgba(0, 0, 0, 0.45);
    --shadow-hover: 0 1px 0 rgba(255,255,255,0.04) inset, 0 16px 40px rgba(0, 0, 0, 0.55);
    --shadow-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    --glow-purple: 0 0 0 1px rgba(139, 108, 247, 0.18), 0 0 24px rgba(139, 108, 247, 0.1);

    /* Shape */
    --border-radius-lg: 20px;
    --border-radius: 14px;
    --border-radius-sm: 10px;
    --border-radius-xs: 7px;

    /* Layout */
    --sidebar-width: 250px;
    --sidebar-width-collapsed: 60px;

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;

    /* Motion */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.12s ease;

    /* Type */
    --font-sans: 'Inter', 'Helvetica Neue', 'Noto Sans TC', Arial, sans-serif;
    --font-mono: 'SF Mono', 'Monaco', 'Courier New', monospace;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    font-weight: 400;
    overflow-x: hidden;
    position: relative;
    letter-spacing: 0.1px;
}

/* ==================== APP SHELL (sidebar + main) ==================== */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-main {
    flex: 1;
    min-width: 0;
    /* Sidebar is icon-only by default and only expands as a hover overlay
       (see sidebar.css), so content stays at the compact margin unless the
       sidebar is pinned open. */
    margin-left: var(--sidebar-width-collapsed);
    padding: 28px 32px 40px;
    transition: margin-left 0.2s ease;
}

body.sidebar-pinned .app-main {
    margin-left: var(--sidebar-width);
}

/* ==================== TOPBAR PRIMITIVE ==================== */
.page-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.page-topbar .greeting {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-topbar .greeting h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.page-topbar .greeting p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ==================== SECTION HEADING PRIMITIVE ==================== */
.section-heading {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--secondary-purple);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* ==================== CARD PRIMITIVE ==================== */
.glass-panel,
.dash-card {
    background: var(--surface-1);
    border: 1px solid var(--border-hairline);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-primary);
    position: relative;
    transition: var(--transition);
}

.glass-panel:hover,
.dash-card:hover {
    border-color: var(--border-hairline-strong);
}

.dash-card {
    padding: 22px;
}

.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dash-card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.dash-card-header .card-link {
    font-size: 0.8rem;
    color: var(--secondary-purple);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dash-card-header .card-link:hover {
    color: var(--text-primary);
}

/* ==================== BUTTON PRIMITIVES ==================== */
.btn-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    border: none;
    border-radius: 999px;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    cursor: pointer;
    transition: var(--transition);
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 6px 18px rgba(139, 108, 247, 0.3);
}

.btn-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(139, 108, 247, 0.4);
}

.btn-pill:active {
    transform: translateY(0);
}

.btn-pill-ghost {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border-hairline);
    box-shadow: none;
}

.btn-pill-ghost:hover {
    background: var(--surface-3);
    box-shadow: none;
}

/* ==================== STATUS PILL ==================== */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 13px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--surface-2);
    border: 1px solid var(--border-hairline);
    color: var(--text-secondary);
}

.status-pill .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-faint);
}

.status-pill.online .dot {
    background: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.status-pill.offline .dot {
    background: var(--error-color);
    box-shadow: 0 0 8px var(--error-color);
}

/* ==================== COMING SOON PLACEHOLDER ==================== */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    text-align: center;
    min-height: 60vh;
    color: var(--text-secondary);
}

.coming-soon .icon-badge {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-gradient);
    box-shadow: 0 12px 32px rgba(139, 108, 247, 0.35);
}

.coming-soon h1 {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
}

.coming-soon p {
    font-size: 0.95rem;
    color: var(--text-muted);
    max-width: 420px;
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(139, 108, 247, 0.35);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(139, 108, 247, 0.55);
}

/* ==================== SELECTION ==================== */
::selection {
    background: rgba(139, 108, 247, 0.35);
    color: var(--text-primary);
}

::-moz-selection {
    background: rgba(139, 108, 247, 0.35);
    color: var(--text-primary);
}

/* ==================== SHARED KEYFRAMES ==================== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-14px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(14px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-soft {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.75; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .app-main {
        margin-left: 0;
        padding: 20px 16px 32px;
    }
}
