/* ============================================
   SHARED DEMO PAGE STYLES
   ============================================ */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --accent: #06b6d4;
    --dark: #0f172a;
    --dark-mid: #1e293b;
    --dark-light: #334155;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --white: #ffffff;
    --green: #10b981;
    --green-light: #d1fae5;
    --green-dark: #065f46;
    --red: #ef4444;
    --red-light: #fee2e2;
    --orange: #f59e0b;
    --orange-light: #fef3c7;
    --purple: #7c3aed;
    --purple-light: #ede9fe;
    --blue-light: #dbeafe;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

html { font-size: 15px; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--dark);
    background: var(--gray-100);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* --- Back Bar --- */
.demo-back-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 9999;
    background: #08070d;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    font-size: 0.8rem;
    border-bottom: 1px solid rgba(168, 85, 247, 0.18);
}
.demo-back-bar a {
    color: #c084fc;
    font-weight: 600;
    transition: color 0.2s;
}
.demo-back-bar a:hover { color: #f472b6; }
.demo-back-bar .demo-label {
    color: var(--gray-400);
    font-weight: 500;
}

/* --- App Shell --- */
.app-shell {
    display: flex;
    min-height: 100vh;
    padding-top: 40px;
}

/* --- Sidebar --- */
.sidebar {
    width: 240px;
    background: var(--dark);
    color: var(--white);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 40px;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-logo {
    padding: 0 20px 20px;
    font-size: 1.2rem;
    font-weight: 800;
    border-bottom: 1px solid var(--dark-light);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo .logo-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: 700;
}
.sidebar-section {
    padding: 12px 20px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--gray-500);
    font-weight: 600;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--gray-400);
    cursor: pointer;
    transition: all 0.15s;
}
.sidebar-item:hover {
    color: var(--white);
    background: rgba(255,255,255,0.05);
}
.sidebar-item.active {
    color: var(--white);
    background: var(--dark-light);
    border-left: 3px solid var(--primary);
}
.sidebar-item .icon {
    width: 18px;
    text-align: center;
    font-size: 0.9rem;
}
.sidebar-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}
.sidebar-user {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--dark-light);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem; font-weight: 700;
}
.sidebar-user-info {
    flex: 1;
}
.sidebar-user-name {
    font-size: 0.8rem;
    font-weight: 600;
}
.sidebar-user-role {
    font-size: 0.65rem;
    color: var(--gray-500);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 28px 32px;
    min-height: calc(100vh - 40px);
}

/* --- Page Header --- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
}
.page-header-sub {
    font-size: 0.85rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* --- Buttons --- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: white; color: var(--dark); border: 1px solid var(--gray-300); }
.btn-outline:hover { border-color: var(--dark); }
.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-success { background: var(--green); color: white; }
.btn-danger { background: var(--red); color: white; }
.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; background: white; border: 1px solid var(--gray-200);
    cursor: pointer; font-size: 0.85rem;
}

/* --- Cards --- */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

/* --- Stat Cards --- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}
.stat-card-value {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--dark);
    line-height: 1;
}
.stat-card-change {
    font-size: 0.72rem;
    font-weight: 600;
    margin-top: 6px;
}
.stat-card-change.up { color: var(--green); }
.stat-card-change.down { color: var(--red); }

/* --- Tables --- */
.table-container {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.table-header h3 {
    font-size: 1rem;
    font-weight: 700;
}
.table-filters {
    display: flex;
    gap: 6px;
}
.filter-pill {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--gray-100);
    color: var(--gray-500);
    cursor: pointer;
    border: none;
}
.filter-pill.active {
    background: var(--primary);
    color: white;
}
table {
    width: 100%;
    border-collapse: collapse;
}
th {
    text-align: left;
    padding: 12px 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}
td {
    padding: 14px 20px;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-600);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
td strong {
    color: var(--dark);
    font-weight: 600;
}

/* --- Status Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}
.badge-green { background: var(--green-light); color: var(--green-dark); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-orange { background: var(--orange-light); color: #b45309; }
.badge-blue { background: var(--blue-light); color: var(--primary-dark); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* --- Search Bar --- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.82rem;
    color: var(--gray-400);
    min-width: 220px;
}

/* --- Tabs --- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}
.tab {
    padding: 10px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gray-400);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}
.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.tab:hover { color: var(--dark); }

/* --- Grid Layouts --- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* --- Chart Placeholder --- */
.chart-placeholder {
    background: var(--gray-50);
    border: 1px dashed var(--gray-300);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 0.85rem;
    font-weight: 500;
    min-height: 200px;
    position: relative;
    overflow: hidden;
}
/* Simple bar chart visual */
.mini-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 140px;
    padding: 0 20px;
}
.mini-bar {
    width: 28px;
    border-radius: 4px 4px 0 0;
    transition: height 0.3s;
}
/* Line chart visual */
.chart-line-area {
    width: 100%;
    height: 100%;
    position: absolute;
    bottom: 0;
}

/* --- Progress bar --- */
.progress-bar {
    height: 6px;
    background: var(--gray-200);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--primary);
}

/* --- Avatar --- */
.avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center; justify-content: center;
    font-size: 0.65rem; font-weight: 700;
    color: white;
    flex-shrink: 0;
}

/* --- Form Elements --- */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}
.form-input {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--dark);
    background: white;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2394a3b8'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

/* --- Notification dot --- */
.notif-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.notif-dot.green { background: var(--green); }
.notif-dot.red { background: var(--red); }
.notif-dot.orange { background: var(--orange); }

/* --- Toggle --- */
.toggle {
    width: 36px; height: 20px;
    background: var(--gray-300);
    border-radius: 10px;
    position: relative;
    cursor: pointer;
}
.toggle.on { background: var(--primary); }
.toggle::after {
    content: "";
    width: 16px; height: 16px;
    border-radius: 50%;
    background: white;
    position: absolute;
    top: 2px; left: 2px;
    transition: 0.2s;
}
.toggle.on::after { left: 18px; }

/* --- Responsive --- */
@media (max-width: 1024px) {
    .stats-row { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; }
    .stats-row { grid-template-columns: 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; align-items: flex-start; }
}
