/* ============================================
   KanisaIQ Portal — Main Stylesheet
   Brand: Deep Purple + Gold
   ============================================ */

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

:root {
    --primary: #3d1a6b;
    --primary-light: #5a2d8f;
    --primary-dark: #2a1049;
    --gold: #c9a84c;
    --gold-light: #d9bc6c;
    --bg-cream: #faf8f3;
    --bg-white: #ffffff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-cream);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================
   LAYOUT
   ============================================ */
.wrapper { display: flex; min-height: 100vh; }
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content-area { padding: 24px; flex: 1; overflow-y: auto; }

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar-brand {
    padding: 20px 20px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-size: 17px;
    font-weight: 600;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 8px;
}
.sidebar-brand i { color: var(--gold); font-size: 20px; }
.sidebar-section {
    color: rgba(255,255,255,0.35);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 18px 20px 6px;
}
.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.65);
    font-size: 13px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
    cursor: pointer;
}
.sidebar-item:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
    text-decoration: none;
}
.sidebar-item.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    border-left-color: var(--gold);
}
.sidebar-item i { width: 20px; text-align: center; font-size: 14px; }
.sidebar-badge {
    margin-left: auto;
    background: var(--danger);
    color: #fff;
    font-size: 10px;
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

/* Collapsed sidebar */
.sidebar-collapsed .sidebar { width: 60px; }
.sidebar-collapsed .sidebar-brand span,
.sidebar-collapsed .sidebar-section,
.sidebar-collapsed .sidebar-item span,
.sidebar-collapsed .sidebar-badge { display: none; }
.sidebar-collapsed .sidebar-item { justify-content: center; padding: 10px; }

/* ============================================
   TOPBAR
   ============================================ */
.topbar {
    background: var(--bg-white);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
    background: none; border: none; font-size: 18px;
    color: var(--text-secondary); cursor: pointer; padding: 4px;
}
.bell-badge {
    position: relative; cursor: pointer;
    font-size: 18px; color: var(--text-secondary);
}
.bell-badge .badge {
    position: absolute; top: -6px; right: -6px;
    background: var(--danger); color: #fff;
    font-size: 10px; width: 18px; height: 18px;
    border-radius: 50%; display: flex;
    align-items: center; justify-content: center;
    font-weight: 600;
}
.admin-user { display: flex; align-items: center; gap: 8px; }
.admin-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.admin-name { font-size: 13px; font-weight: 500; }

/* ============================================
   KPI CARDS
   ============================================ */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }
.kpi-label { font-size: 12px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.kpi-change { font-size: 12px; margin-top: 4px; }
.kpi-change.up { color: var(--success); }
.kpi-change.down { color: var(--danger); }
.kpi-icon {
    width: 40px; height: 40px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; margin-bottom: 8px;
}
.kpi-icon.purple { background: rgba(61,26,107,0.1); color: var(--primary); }
.kpi-icon.gold { background: rgba(201,168,76,0.15); color: var(--gold); }
.kpi-icon.green { background: rgba(22,163,74,0.1); color: var(--success); }
.kpi-icon.blue { background: rgba(37,99,235,0.1); color: var(--info); }
.kpi-icon.red { background: rgba(220,38,38,0.1); color: var(--danger); }

/* ============================================
   PANELS / CARDS
   ============================================ */
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 20px; }
.panel {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 20px;
}
.panel-title {
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--primary); margin-bottom: 16px;
    display: flex; align-items: center; gap: 8px;
}
.panel-title i { color: var(--gold); }

/* ============================================
   ALERT BANNER
   ============================================ */
.alert-banner {
    padding: 14px 20px; border-radius: var(--radius);
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 20px; font-size: 13px;
}
.alert-banner.critical { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger); }
.alert-banner.warning { background: #fffbeb; border: 1px solid #fed7aa; color: var(--warning); }
.alert-banner.info { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--info); }
.alert-banner.success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--success); }

/* ============================================
   TABLES
   ============================================ */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
    text-align: left; padding: 10px 12px; font-weight: 600;
    color: var(--text-secondary); border-bottom: 2px solid var(--border);
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border-light); }
.data-table tr:hover td { background: var(--bg-cream); }

/* ============================================
   BADGES & PILLS
   ============================================ */
.badge-status {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 500;
}
.badge-status.received { background: #dbeafe; color: #1e40af; }
.badge-status.prayed { background: #dcfce7; color: #166534; }
.badge-status.assigned { background: #fef3c7; color: #92400e; }
.badge-status.closed { background: #f3f4f6; color: #6b7280; }
.badge-status.urgent { background: #fee2e2; color: #991b1b; }
.badge-status.pending { background: #fef3c7; color: #92400e; }
.badge-status.completed { background: #dcfce7; color: #166534; }
.badge-status.cancelled { background: #fee2e2; color: #991b1b; }
.badge-status.booked { background: #dbeafe; color: #1e40af; }

.sentiment-dot {
    display: inline-block; width: 10px; height: 10px;
    border-radius: 50%; margin-right: 4px;
}
.sentiment-dot.distress { background: var(--danger); }
.sentiment-dot.grief { background: var(--danger); }
.sentiment-dot.medical { background: var(--warning); }
.sentiment-dot.financial { background: var(--info); }
.sentiment-dot.thanksgiving { background: var(--success); }
.sentiment-dot.neutral { background: var(--text-muted); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: var(--radius);
    font-size: 13px; font-weight: 500; cursor: pointer;
    border: none; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-primary); }
.btn-outline:hover { background: var(--bg-cream); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--danger); color: #fff; }

/* ============================================
   FORMS
   ============================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; }
.form-input, .form-select, .form-textarea {
    width: 100%; padding: 8px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 13px; font-family: inherit;
    transition: border-color 0.15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61,26,107,0.1);
}
.form-textarea { min-height: 80px; resize: vertical; }

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.4);
    display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--bg-white); border-radius: var(--radius-lg);
    padding: 24px; max-width: 500px; width: 90%;
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
}
.modal-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* ============================================
   CHART CONTAINERS (prevent infinite-grow)
   ============================================ */
.chart-box { position: relative; height: 280px; }
.chart-box canvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }

/* ============================================
   ACTIVITY FEED
   ============================================ */
.activity-item {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 8px 0; border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.activity-time { color: var(--text-muted); font-size: 11px; margin-left: auto; white-space: nowrap; }

/* ============================================
   PRAYER ITEMS
   ============================================ */
.prayer-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border-light); }
.prayer-item:last-child { border-bottom: none; }
.prayer-name { font-weight: 600; font-size: 13px; }
.prayer-text { color: var(--text-secondary); font-size: 13px; margin-top: 2px; }
.prayer-actions { display: flex; gap: 6px; margin-top: 6px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: -240px; z-index: 50; transition: left 0.2s; }
    .sidebar-collapsed .sidebar { left: 0; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
}

/* ============================================
   PRINT
   ============================================ */
@media print {
    .sidebar, .topbar, .sidebar-toggle { display: none !important; }
    .main-content { margin: 0; }
    .content-area { padding: 0; }
    .panel { break-inside: avoid; box-shadow: none; border: 1px solid #ddd; }
}
