/* ============================================
   UMKM Copilot — Clean Professional Theme
   Dark + Light Mode Toggle
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* --- TOKENS: DARK (default) --- */
:root {
    --bg:        #09090b;
    --surface:   #111113;
    --card:      #18181b;
    --hover:     #1f1f23;
    --border:    #27272a;
    --border-l:  #3f3f46;
    --text:      #fafafa;
    --text-2:    #a1a1aa;
    --text-3:    #71717a;
    --blue:      #3b82f6;
    --green:     #22c55e;
    --yellow:    #eab308;
    --red:       #ef4444;
    --purple:    #a855f7;
    --r:         8px;
    --r-lg:      12px;
    --sidebar-w: 240px;
    --topbar-h:  56px;
    --shadow:    0 1px 3px rgba(0,0,0,.4);
}

/* --- TOKENS: LIGHT --- */
[data-theme="light"] {
    --bg:        #f8f9fa;
    --surface:   #ffffff;
    --card:      #ffffff;
    --hover:     #f1f3f5;
    --border:    #e5e7eb;
    --border-l:  #d1d5db;
    --text:      #111827;
    --text-2:    #4b5563;
    --text-3:    #9ca3af;
    --shadow:    0 1px 3px rgba(0,0,0,.08);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    transition: background .25s, color .25s;
}

a { color: inherit; text-decoration: none; }

/* --- SIDEBAR --- */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform .25s ease, background .25s;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    width: 32px; height: 32px;
    background: var(--blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .95rem;
    flex-shrink: 0;
}

.sidebar-title { font-size: .9rem; font-weight: 600; }

.sidebar-menu {
    flex: 1;
    padding: 8px;
    overflow-y: auto;
}

.menu-label {
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-3);
    padding: 12px 8px 4px;
}

.menu-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 500;
    color: var(--text-2);
    transition: all .15s;
}

.menu-link:hover { background: var(--hover); color: var(--text); }
.menu-link.active { background: rgba(59,130,246,.1); color: var(--blue); }
.menu-link i { width: 18px; text-align: center; font-size: 1rem; opacity: .7; }
.menu-link.active i { opacity: 1; }

.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.dot-live {
    width: 7px; height: 7px;
    background: var(--green);
    border-radius: 50%;
}

.sidebar-footer span { font-size: .7rem; color: var(--text-3); }

/* --- MAIN --- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }

/* --- TOPBAR --- */
.topbar {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 90;
    transition: background .25s, border-color .25s;
}

.topbar h1 { font-size: .95rem; font-weight: 600; }

.hamburger {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.topbar-badge {
    font-size: .68rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
    background: rgba(34,197,94,.12);
    color: var(--green);
}

/* --- THEME TOGGLE --- */
.theme-toggle {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text-2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all .2s;
}

.theme-toggle:hover {
    border-color: var(--border-l);
    color: var(--text);
    background: var(--hover);
}

[data-theme="light"] .theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-moon { display: inline; }
:root .theme-toggle .icon-sun { display: inline; }
:root .theme-toggle .icon-moon { display: none; }

/* --- CONTENT --- */
.content {
    padding: 24px;
    max-width: 1200px;
}

/* --- CARDS --- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    margin-bottom: 16px;
    transition: background .25s, border-color .25s;
}

.card-head {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-body { padding: 16px; }

/* --- STATS --- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: border-color .2s, background .25s;
}

.stat:hover { border-color: var(--border-l); }

.stat-ico {
    width: 40px; height: 40px;
    border-radius: var(--r);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.stat-ico.blue   { background: rgba(59,130,246,.1);  color: var(--blue); }
.stat-ico.green  { background: rgba(34,197,94,.1);   color: var(--green); }
.stat-ico.yellow { background: rgba(234,179,8,.1);   color: var(--yellow); }
.stat-ico.red    { background: rgba(239,68,68,.1);   color: var(--red); }
.stat-ico.purple { background: rgba(168,85,247,.1);  color: var(--purple); }

.stat-val { font-size: 1.25rem; font-weight: 700; line-height: 1.2; }
.stat-lbl { font-size: .72rem; color: var(--text-3); margin-top: 1px; }

/* --- GRID --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* --- LIST ITEMS --- */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--hover); }

.list-av {
    width: 36px; height: 36px;
    background: rgba(59,130,246,.1);
    color: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: .75rem;
    flex-shrink: 0;
}

.list-body { flex: 1; min-width: 0; }
.list-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.list-name { font-size: .82rem; font-weight: 600; }
.list-time { font-size: .65rem; color: var(--text-3); }
.list-sub { font-size: .75rem; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* --- BADGES --- */
.badge {
    display: inline-block;
    font-size: .62rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: middle;
}

.badge-blue   { background: rgba(59,130,246,.15);  color: var(--blue); }
.badge-green  { background: rgba(34,197,94,.15);   color: var(--green); }
.badge-yellow { background: rgba(234,179,8,.15);   color: var(--yellow); }
.badge-red    { background: rgba(239,68,68,.15);   color: var(--red); }
.badge-purple { background: rgba(168,85,247,.15);  color: var(--purple); }
.badge-gray   { background: rgba(113,113,122,.15); color: var(--text-3); }

/* --- BUTTONS --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--r);
    font-size: .82rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
}

.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.1); }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-ghost:hover { border-color: var(--border-l); background: var(--hover); }

.btn-sm { padding: 5px 10px; font-size: .72rem; }

/* --- FORMS --- */
.input, .select {
    width: 100%;
    padding: 8px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--r);
    color: var(--text);
    font-size: .82rem;
    font-family: inherit;
    outline: none;
    transition: border-color .2s, background .25s;
}

.input:focus, .select:focus { border-color: var(--blue); }
.input::placeholder { color: var(--text-3); }

label.lbl {
    display: block;
    font-size: .72rem;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 4px;
}

/* --- CHAT --- */
.chat-wrap { max-width: 480px; margin: 0 auto; }

.chat-box {
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    overflow: hidden;
}

.chat-top {
    padding: 12px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-top-av {
    width: 32px; height: 32px;
    background: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: .85rem;
}

.chat-top-name { font-size: .82rem; font-weight: 600; }
.chat-top-sub  { font-size: .65rem; color: var(--text-3); }

.chat-body {
    height: 380px;
    overflow-y: auto;
    padding: 16px;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: background .25s;
}

.chat-msg {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: .82rem;
    line-height: 1.5;
    animation: fadeUp .2s ease;
}

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

.chat-msg.in {
    background: var(--card);
    border: 1px solid var(--border);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
}

.chat-msg.out {
    background: var(--blue);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-bar {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border-top: 1px solid var(--border);
}

.chat-bar .input { flex: 1; }

/* --- TABLE --- */
.tbl { width: 100%; border-collapse: collapse; font-size: .82rem; }

.tbl th {
    text-align: left;
    padding: 10px 12px;
    font-size: .68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    border-bottom: 1px solid var(--border);
    background: var(--surface);
}

.tbl td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.tbl tr:hover td { background: var(--hover); }

.tbl-r { text-align: right; }

/* --- EMPTY --- */
.empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-3);
}

.empty i { font-size: 2rem; display: block; margin-bottom: 12px; }

/* --- MOBILE NAV --- */
.mob-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    z-index: 100;
}

.mob-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: .58rem;
    color: var(--text-3);
    padding: 4px;
}

.mob-nav a i { font-size: 1.1rem; }
.mob-nav a.active { color: var(--blue); }

/* --- OVERLAY --- */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 99;
}

.overlay.open { display: block; }

/* --- RESPONSIVE --- */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main { margin-left: 0; }
    .hamburger { display: block; }
    .stats { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .content { padding: 16px; }
    .mob-nav { display: flex; }
    .main { padding-bottom: 64px; }
    
    .tbl-wrap { overflow: visible; }
    .tbl thead { display: none; }
    .tbl tbody tr {
        display: block;
        border: 1px solid var(--border);
        border-radius: var(--r);
        margin-bottom: 8px;
    }
    .tbl td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 12px;
        border-bottom: 1px solid var(--border);
    }
    .tbl td:last-child { border-bottom: none; }
    .tbl td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-3);
        font-size: .65rem;
        text-transform: uppercase;
    }
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
