/* ============================
   WeVisit Dashboard Stylesheet
   ============================ */

:root {
    --primary: #270442;
    --secondary: #F87B1B;
    --sidebar-bg: #270442;
    --sidebar-width: 240px;
    --topbar-height: 72px;
    --white: #ffffff;
    --bg: #F4F6F9;
    --card-bg: #ffffff;
    --text-muted: #8A8A8A;
    --border: #EBEBEB;
    --success: #22C55E;
}

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

body.dashboard-body {
    font-family: 'Almarai', sans-serif;
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    direction: rtl;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ============================
   Sidebar
   ============================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px 28px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo-img {
    height: 38px;
    filter: brightness(0) invert(1);
}

.sidebar-logo span {
    font-family: 'Poppins', sans-serif;
    font-weight: 700;
    font-size: 18px;
    color: white;
    letter-spacing: 1px;
}

.sidebar-control-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 16px 12px;
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.75);
    border-radius: 10px;
    padding: 12px 18px;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s;
}

.sidebar-control-btn:hover { background: rgba(255,255,255,0.14); color: white; }
.sidebar-control-btn.active-ctrl,
.sidebar-control-btn.active { background: var(--secondary); color: white; }

.sidebar-nav {
    flex: 1;
    padding: 0 8px;
    margin-top: 8px;
    overflow-y: auto;
}

.sidebar-nav ul { display: flex; flex-direction: column; gap: 2px; }

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: 10px;
    color: rgba(255,255,255,0.65);
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
}

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

.sidebar-nav li.active > a {
    background: var(--secondary) !important;
    color: white !important;
}

.sidebar-nav li a i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav li.active > a i {
    color: white !important;
}

.sidebar-divider-label {
    padding: 14px 16px 6px;
    font-size: 12px;
    color: var(--secondary);
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logout-item { margin-top: auto; }
.logout-item a { color: rgba(255,255,255,0.45) !important; }
.logout-item a:hover { color: #ff6b6b !important; background: rgba(255,0,0,0.08) !important; }

/* ============================
   Main Content
   ============================ */
.dashboard-main {
    margin-right: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 0 32px 40px;
}

/* ============================
   Top Bar
   ============================ */
.dash-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: var(--card-bg);
    margin: 0 -32px 28px;
    padding: 0 32px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}

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

.dash-back-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(39, 4, 66, 0.06);
    color: var(--primary);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s ease;
    text-decoration: none;
    border: 1px solid rgba(39, 4, 66, 0.1);
}

.dash-back-btn:hover {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(39, 4, 66, 0.2);
    transform: translateY(-1px);
}

.dash-back-btn i {
    font-size: 14px;
    transition: transform 0.2s ease;
}

.dash-back-btn:hover i {
    transform: scale(1.1);
}

.dash-user {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.dash-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--primary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.dash-avatar img { width: 100%; height: 100%; object-fit: cover; }

.avatar-initials {
    color: white;
    font-weight: 700;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
}

.dash-user-info h4 {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 2px;
}

.dash-user-info span {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'Poppins', sans-serif;
}

.dash-search {
    flex: 1;
    max-width: 440px;
    position: relative;
    margin: 0 auto;
}

.dash-search input {
    width: 100%;
    padding: 10px 20px 10px 42px;
    border: 1px solid var(--border);
    border-radius: 50px;
    font-family: 'Almarai', sans-serif;
    font-size: 14px;
    outline: none;
    background: var(--bg);
    color: #333;
    direction: rtl;
}

.dash-search i {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.dash-bell {
    position: relative;
    width: 42px;
    height: 42px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--primary);
}

.bell-dot {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 9px;
    height: 9px;
    background: var(--secondary);
    border-radius: 50%;
    border: 2px solid white;
}

/* ============================
   Stats Cards
   ============================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 22px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-family: 'Cairo', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
}

.stat-change {
    font-size: 11px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.icon-purple { background: rgba(39,4,66,0.1); color: var(--primary); }
.icon-orange { background: rgba(248,123,27,0.12); color: var(--secondary); }
.icon-blue   { background: rgba(59,130,246,0.12); color: #3B82F6; }
.icon-green  { background: rgba(34,197,94,0.12); color: var(--success); }

/* ============================
   Charts Row
   ============================ */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.chart-month-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: 'Almarai', sans-serif;
    font-size: 13px;
    color: var(--primary);
    cursor: pointer;
    outline: none;
}

.chart-body { height: 240px; position: relative; }

.donut-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.donut-body canvas { max-width: 180px; max-height: 180px; }

.donut-stats {
    display: flex;
    justify-content: space-around;
    width: 100%;
}

.donut-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.donut-num {
    font-family: 'Cairo', sans-serif;
    font-size: 22px;
    font-weight: 700;
    color: var(--primary);
}

.donut-label {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot-orange { background: var(--secondary); }
.dot-purple { background: var(--primary); }

/* ============================
   Table Card
   ============================ */
.table-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 22px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.table-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.table-view-all {
    background: var(--primary);
    color: white;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: opacity 0.2s;
}

.table-view-all:hover { opacity: 0.85; }

.table-wrap { overflow-x: auto; }

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

thead th {
    padding: 10px 14px;
    text-align: right;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px;
    color: #333;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(39,4,66,0.02); }

.institution-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.institution-cell img {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
}

/* Toggle Switch */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle .slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.3s;
}
.toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: white;
    bottom: 3px;
    right: 3px;
    transition: 0.3s;
}
.toggle input:checked + .slider { background: var(--success); }
.toggle input:checked + .slider::before { transform: translateX(-20px); }

/* Action Button */
.action-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.action-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ============================
   Responsive
   ============================ */
@media (max-width: 1200px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    .sidebar { display: none; }
    .dashboard-main { margin-right: 0; padding: 0 16px 30px; }
    .stats-grid { grid-template-columns: 1fr; }
}
