/* ============================================================
   Education Marketplace — Demo Dashboard
   Vanilla CSS, no frameworks
   ============================================================ */

:root {
    --primary: #4f46e5;
    --primary-light: #818cf8;
    --primary-dark: #3730a3;
    --green: #16a34a;
    --blue: #2563eb;
    --amber: #d97706;
    --red: #dc2626;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --white: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --radius: 10px;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 250px;
    background: var(--gray-900);
    color: var(--gray-300);
    padding: 20px 0;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar .brand {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    margin-bottom: 15px;
}

.sidebar .brand h1 {
    font-size: 18px;
    color: var(--white);
    font-weight: 700;
}

.sidebar .brand p {
    font-size: 11px;
    color: var(--gray-500);
    margin-top: 4px;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    transition: background .15s, color .15s;
}

.sidebar nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.sidebar nav a.active { background: var(--primary); color: var(--white); }
.sidebar nav a .num {
    background: rgba(255,255,255,.1);
    width: 22px; height: 22px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700;
    flex-shrink: 0;
}
.sidebar nav a.active .num { background: rgba(255,255,255,.25); }

.sidebar .spacer { flex: 1; }

.sidebar .login-box {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.sidebar .login-box button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: var(--white);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 8px;
}
.sidebar .login-box button.ghost {
    background: transparent;
    border: 1px solid var(--gray-600, #4b5563);
}

/* ---------- Main ---------- */
.main {
    flex: 1;
    margin-left: 250px;
    padding: 25px 30px;
    min-height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.topbar h2 { font-size: 22px; font-weight: 700; }
.topbar .user-chip {
    background: var(--white);
    border: 1px solid var(--gray-200);
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow);
}
.topbar .user-chip .role {
    background: var(--primary);
    color: var(--white);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 600;
}

/* ---------- Stats cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat-card .label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--primary-dark); }
.stat-card .sub { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ---------- Cards / panels ---------- */
.panel {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.panel h3 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    padding: 10px 12px;
    background: var(--gray-100);
    color: var(--gray-700);
    font-weight: 600;
    border-bottom: 2px solid var(--gray-200);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .3px;
}

td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--gray-200);
    color: var(--gray-700);
}

tr:hover td { background: var(--gray-50); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge.approved, .badge.completed, .badge.active, .badge.paid { background: #dcfce7; color: #166534; }
.badge.pending, .badge.new, .badge.processing, .badge.contacted { background: #fef3c7; color: #92400e; }
.badge.suspended, .badge.cancelled, .badge.failed, .badge.refunded, .badge.lost { background: #fee2e2; color: #991b1b; }
.badge.qualified { background: #dbeafe; color: #1e40af; }
.badge.converted { background: #d1fae5; color: #065f46; }
.badge.paid { background: #e0e7ff; color: #3730a3; }

/* ---------- Stars ---------- */
.stars { color: #f59e0b; letter-spacing: 1px; }
.stars .off { color: var(--gray-300); }

/* ---------- Buttons ---------- */
button.btn {
    padding: 7px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    background: var(--white);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: background .15s;
}
button.btn:hover { background: var(--gray-100); }
button.btn.primary { background: var(--primary); color: var(--white); border-color: var(--primary); }
button.btn.primary:hover { background: var(--primary-dark); }
button.btn.danger { background: var(--red); color: var(--white); border-color: var(--red); }
button.btn.sm { padding: 4px 10px; font-size: 11px; }

/* ---------- Search ---------- */
.search-box {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-box input, .search-box select {
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    background: var(--white);
}
.search-box input { flex: 1; min-width: 200px; }

/* ---------- Result grid ---------- */
.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.result-card {
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.result-card .title { font-weight: 700; font-size: 14px; }
.result-card .vendor { font-size: 12px; color: var(--gray-500); }
.result-card .price { font-size: 16px; font-weight: 700; color: var(--primary-dark); }
.result-card .meta { font-size: 11px; color: var(--gray-500); }

/* ---------- Chat ---------- */
.chat-window {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}
.chat-msg {
    max-width: 70%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.4;
}
.chat-msg.them { background: var(--gray-100); border-bottom-left-radius: 4px; }
.chat-msg.me { background: var(--primary); color: var(--white); margin-left: auto; border-bottom-right-radius: 4px; }
.chat-msg .who { font-size: 10px; opacity: .7; margin-bottom: 2px; }

.chat-input { display: flex; gap: 10px; margin-top: 12px; }
.chat-input input {
    flex: 1; padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
}

/* ---------- Modal ---------- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-overlay.show { display: flex; }

.modal {
    background: var(--white);
    border-radius: 12px;
    padding: 28px;
    width: 380px;
    max-width: 90vw;
    box-shadow: 0 20px 40px rgba(0,0,0,.2);
}
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--gray-700); }
.modal input, .modal select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 14px;
}
.modal button {
    width: 100%;
    padding: 11px;
    border: none;
    border-radius: 8px;
    background: var(--primary);
    color: var(--white);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 8px;
}
.modal .demo-note {
    font-size: 12px;
    color: var(--gray-500);
    background: var(--gray-50);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 14px;
    line-height: 1.6;
}
.modal .demo-note b { color: var(--gray-700); }

/* ---------- Charts ---------- */
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .bar-label { width: 140px; flex-shrink: 0; }
.bar-row .bar {
    height: 22px;
    background: var(--primary);
    border-radius: 5px;
    transition: width .3s;
}
.bar-row .bar-val { width: 60px; text-align: right; font-weight: 600; font-size: 12px; }

/* ---------- Empty ---------- */
.empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-500);
    font-size: 14px;
}

/* ---------- Toast ---------- */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--gray-900);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 13px;
    box-shadow: 0 8px 20px rgba(0,0,0,.2);
    z-index: 200;
    opacity: 0;
    transition: opacity .2s;
}
.toast.show { opacity: 1; }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar .brand h1, .sidebar .brand p,
    .sidebar nav a span, .sidebar nav a .num,
    .sidebar .login-box p { display: none; }
    .sidebar nav a { justify-content: center; padding: 12px; }
    .main { margin-left: 64px; padding: 15px; }
}
