/* ==========================================================================
   Irembo Support Center – Custom Portal CSS
   Theme matches the Lovable public frontend:
   - Font: Nunito Sans (800 weight headings, 500/600 body)
   - Primary: #0162CE (Irembo official portal blue)
   - Background: white / #F4F6FA surface
   - Border-radius: 0.75rem (12px) cards, 0.5rem controls
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Design Tokens ────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:           #0162CE;
  --primary-dark:      #0847A0;
  --primary-light:     #E6F0FB;
  --primary-glow:      rgba(1, 98, 206, 0.18);

  /* IremboPay green accent */
  --pay-green:         #85ec68;
  --pay-green-soft:    #EEFCE9;

  /* IremboPlus purple accent */
  --plus-purple:       #5514C9;
  --plus-purple-soft:  #EFE6FB;

  /* RDB teal */
  --rdb-blue:          #055e9b;
  --rdb-blue-soft:     #e7f7ff;

  /* Surfaces */
  --bg-page:           #F8FAFC;
  --bg-sidebar:        #ffffff;
  --bg-card:           #ffffff;
  --bg-card-hover:     #F4F6FA;

  /* Text */
  --text-heading:      #0B1B33;
  --text-body:         #1A2A44;
  --text-muted:        #5B6A82;
  --text-dim:          #94A3B8;

  /* Borders */
  --border:            #E4E8EF;
  --border-focus:      #0162CE;

  /* Status */
  --color-success:     #10B981;
  --color-warning:     #F59E0B;
  --color-danger:      #D92D20;
  --color-info:        #0ea5e9;

  /* Geometry */
  --radius-sm:         0.5rem;
  --radius:            0.75rem;
  --radius-lg:         1rem;
  --radius-xl:         1.25rem;
  --radius-2xl:        1.5rem;

  /* Shadows */
  --shadow-xs:         0 1px 2px rgba(11,27,51,.04);
  --shadow-sm:         0 1px 2px rgba(11,27,51,.04), 0 4px 16px rgba(11,27,51,.06);
  --shadow-md:         0 4px 20px -2px rgba(11,27,51,.10);
  --shadow-glow:       0 8px 32px -8px rgba(1,98,206,.28);

  /* Transitions */
  --transition:        200ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Typography */
  --font-sans:         'Nunito Sans', ui-sans-serif, system-ui, sans-serif;
  --font-mono:         'JetBrains Mono', monospace;
}

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

/* ── Base ────────────────────────────────────────────────────────────────── */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans) !important;
  background-color: var(--bg-page) !important;
  color: var(--text-body) !important;
  min-height: 100vh;
  line-height: 1.6;
}

h1, h2, h3, h4, h5 {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-heading);
  line-height: 1.25;
}

/* ── Layout Shell ────────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Header ──────────────────────────────────────────────────────────── */
header {
  background: #ffffff !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: var(--shadow-xs) !important;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
aside {
  background: var(--bg-sidebar) !important;
  border-right: 1px solid var(--border) !important;
}

/* ── Cards / Glass Panels ────────────────────────────────────────────────── */
/* Override the old dark glass-panel with clean light cards */
.glass-panel {
  background: var(--bg-card) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow-sm) !important;
}

.glass-panel:hover {
  border-color: rgba(1, 98, 206, 0.20) !important;
  box-shadow: var(--shadow-md) !important;
}

.glass-card-interactive {
  transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
  cursor: pointer;
}

.glass-card-interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow) !important;
  border-color: rgba(1, 98, 206, 0.25) !important;
}

/* ── Form Controls ───────────────────────────────────────────────────────── */
select, input, textarea {
  font-family: var(--font-sans) !important;
  color: var(--text-body);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.block-input {
  padding: 0.75rem 1rem !important;
  font-size: 0.875rem !important;
  line-height: 1.5 !important;
  border-radius: 0.75rem !important;
}

.block-textarea {
  padding: 0.85rem 1rem !important;
  font-size: 0.875rem !important;
  line-height: 1.6 !important;
  border-radius: 0.75rem !important;
  min-height: 80px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
button {
  cursor: pointer;
  font-family: var(--font-sans) !important;
  transition: background-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

/* Primary action button */
.btn-primary {
  background: #0162CE !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: var(--radius-sm) !important;
  font-weight: 700 !important;
  box-shadow: 0 4px 14px rgba(1, 98, 206, 0.25) !important;
}

.btn-primary:hover {
  background: #1d7cf2 !important;
  box-shadow: 0 6px 20px rgba(1, 98, 206, 0.35) !important;
}

/* ── Sidebar Navigation ──────────────────────────────────────────────────── */
.sidebar-nav-item {
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
  font-weight: 600;
  color: var(--text-muted);
  text-align: left !important;
}

.sidebar-nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.sidebar-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}

/* ── KPI Metric Cards ────────────────────────────────────────────────────── */
.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem 1.5rem;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-glow);
  border-color: rgba(1,98,206,.20);
}

/* ── Status Badges ───────────────────────────────────────────────────────── */
.status-badge, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: capitalize;
}

.status-draft     { background: transparent !important; color: #64748B !important; }
.status-in_review { background: transparent !important; color: #D97706 !important; }
.status-published { background: transparent !important; color: #059669 !important; }
.status-archived  { background: transparent !important; color: #94A3B8 !important; }
.status-changes_requested { background: transparent !important; color: #DC2626 !important; }

.health-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 700;
}
.health-good    { background: #E6F0FB; color: #0162CE; }
.health-medium  { background: #FEF3C7; color: #92400E; }
.health-poor    { background: #FEE2E2; color: #991B1B; }

/* ── Canvas Block ────────────────────────────────────────────────────────── */
.canvas-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.canvas-block:hover {
  box-shadow: var(--shadow-md);
  border-color: rgba(1,98,206,.18);
}

/* ── Preview Viewport Container ──────────────────────────────────────────── */
.preview-container {
  transition: max-width var(--transition);
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.preview-container.viewport-desktop { max-width: 100%; }
.preview-container.viewport-tablet  { max-width: 768px; }
.preview-container.viewport-mobile  { max-width: 390px; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #C8D0DC; }

/* ── Article Table ───────────────────────────────────────────────────────── */
.article-table-row {
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}

.article-table-row:hover {
  background: var(--primary-light);
}

/* ── Notification Drawer ─────────────────────────────────────────────────── */
.notification-drawer {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* ── Stat Pill ───────────────────────────────────────────────────────────── */
.stat-pill {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 0.15rem 0.55rem;
}

/* ── Product Tag Pills ───────────────────────────────────────────────────── */
.tag-irembo-gov  { background: #E6F0FB; color: #0263CD; border-radius: 9999px; padding: 0.1rem 0.5rem; font-size: 0.68rem; font-weight: 700; }
.tag-irembo-pay  { background: #EEFCE9; color: #166534; border-radius: 9999px; padding: 0.1rem 0.5rem; font-size: 0.68rem; font-weight: 700; }
.tag-irembo-plus { background: #EFE6FB; color: #5514C9; border-radius: 9999px; padding: 0.1rem 0.5rem; font-size: 0.68rem; font-weight: 700; }
.tag-rdb         { background: #e7f7ff; color: #055e9b; border-radius: 9999px; padding: 0.1rem 0.5rem; font-size: 0.68rem; font-weight: 700; }

/* ── Sidebar Width ───────────────────────────────────────────────────────── */
.portal-sidebar { width: 240px; min-width: 240px; }

/* ── Gradient Hero Strip (top of sidebar / header logo area) ─────────────── */
.portal-brand-strip {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

/* ── Callout Variants ────────────────────────────────────────────────────── */
.callout-info    { background: #EFF6FF; border-left: 3px solid #3B82F6; }
.callout-warning { background: #FFFBEB; border-left: 3px solid #F59E0B; }
.callout-danger  { background: #FEF2F2; border-left: 3px solid #EF4444; }
.callout-success { background: #F0FDF4; border-left: 3px solid #22C55E; }

/* ── Overrides for Tailwind dark-mode classes used in portal.js ──────────── */
/* These ensure the light theme takes precedence over dark Tailwind utilities */
.bg-slate-950 { background-color: var(--bg-page) !important; }
.bg-slate-900 { background-color: #F8FAFC !important; }
.bg-slate-800 { background-color: #F1F5F9 !important; }
.bg-slate-700 { background-color: #E4E8EF !important; }

.text-slate-100     { color: var(--text-body) !important; }
.text-slate-200     { color: var(--text-body) !important; }
.text-slate-300     { color: var(--text-muted) !important; }
.text-slate-400     { color: var(--text-muted) !important; }
.text-slate-500     { color: var(--text-dim) !important; }

.border-white\/5    { border-color: var(--border) !important; }
.border-white\/10   { border-color: var(--border) !important; }
.border-white\/20   { border-color: rgba(1,98,206,.15) !important; }

.bg-brand-600         { background-color: var(--primary) !important; }
.bg-brand-600\/30     { background-color: var(--primary-light) !important; }
.text-brand-400       { color: var(--primary) !important; }
.text-brand-300       { color: var(--primary-dark) !important; }
.border-brand-500     { border-color: var(--primary) !important; }

.bg-white\/5         { background-color: rgba(1,98,206,.04) !important; }
.bg-white\/10        { background-color: rgba(1,98,206,.07) !important; }
.hover\:bg-white\/5:hover  { background-color: var(--primary-light) !important; }
.hover\:bg-white\/10:hover { background-color: var(--primary-light) !important; }

/* Sidebar active state */
.bg-brand-600\/20 { background-color: var(--primary-light) !important; }

/* Notification indicator */
.bg-brand-500 { background-color: var(--primary) !important; }

/* Emerald (success/publish) stays green */
.bg-emerald-600 { background-color: #059669 !important; }
.hover\:bg-emerald-500:hover { background-color: #10B981 !important; }
.text-emerald-400 { color: #059669 !important; }

/* Amber (review/warning) stays amber */
.bg-amber-600 { background-color: #D97706 !important; }
.hover\:bg-amber-500:hover { background-color: #F59E0B !important; }

/* Rose (danger/delete) stays rose */
.text-rose-400 { color: #DC2626 !important; }
.hover\:bg-rose-500\/20:hover { background-color: #FEE2E2 !important; }

/* Cyan accent (version history, etc.) */
.text-cyan-400 { color: #0369A1 !important; }
.bg-cyan-600   { background-color: var(--primary) !important; }

/* ── Freshdesk Solutions Hierarchy Tree ──────────────────────────────────── */
.tree-node-product {
  transition: background var(--transition);
}
.tree-node-product:hover {
  background: #F8FAFC;
}

.tree-node-category {
  transition: background var(--transition);
  border-left: 2px solid #E4E8EF;
}
.tree-node-category:hover {
  border-left-color: #0162CE;
  background: #F8FAFC;
}

.tree-node-article {
  transition: all var(--transition);
  border-left: 2px solid #E4E8EF;
}
.tree-node-article:hover {
  border-left-color: #0162CE;
  background: #E6F0FB;
}

/* ── Live Preview Simulator ──────────────────────────────────────────────── */
.preview-pane-shell {
  background: #ffffff;
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.preview-citizen-header {
  background: #0B1B33;
  color: #ffffff;
}

/* ── Blue-ish Health Bar ─────────────────────────────────────────────────── */
.health-bar-fill {
  background: linear-gradient(90deg, #0162CE 0%, #00B4D8 100%) !important;
}

/* ── Buttons with explicit white text ────────────────────────────────────── */
.btn-primary, button[style*="background:#0162CE"], button[style*="background: #0162CE"] {
  color: #ffffff !important;
}

.badge-count-white {
  color: #ffffff !important;
}

/* ── Toast Notifications ─────────────────────────────────────────────────── */
.toast-floating {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 100;
  animation: toastSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 10px 30px -5px rgba(11,27,51,0.15), 0 0 0 1px rgba(11,27,51,0.05);
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Solutions Cards Grid ────────────────────────────────────────────────── */
.solution-product-card {
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: #ffffff;
}

.solution-product-card:hover {
  transform: translateY(-2px);
  border-color: rgba(1, 98, 206, 0.3);
  box-shadow: 0 8px 24px -4px rgba(1, 98, 206, 0.12);
}

.solution-institution-card {
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: #ffffff;
}

.solution-institution-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* ── User Profile Pill ───────────────────────────────────────────────────── */
.user-profile-pill {
  transition: background var(--transition), border-color var(--transition);
}

.user-profile-pill:hover {
  background: #F4F6FA;
  border-color: rgba(1, 98, 206, 0.2);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .portal-sidebar { display: none; }
}

/* ── Rich Text Canvas (TipTap) ───────────────────────────────────────────── */
.toolbar-btn {
  padding: 6px 8px;
  border-radius: 6px;
  color: #1A2A44;
  transition: background var(--transition, 0.15s);
}
.toolbar-btn:hover { background: #F1F5F9; }
.toolbar-btn.is-active { background: #E6F0FB; color: #0162CE; }

.tiptap-canvas .ProseMirror {
  min-height: 380px;
  outline: none;
  font-size: 0.875rem;
  line-height: 1.7;
  color: #1A2A44;
}
.tiptap-canvas .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: #94A3B8;
  float: left;
  height: 0;
  pointer-events: none;
}
.tiptap-canvas .ProseMirror h2 { font-size: 1.15rem; font-weight: 800; color: #0B1B33; margin: 1em 0 0.4em; }
.tiptap-canvas .ProseMirror h3 { font-size: 1rem; font-weight: 800; color: #0B1B33; margin: 1em 0 0.4em; }

/* Tailwind's Preflight reset strips list-style/padding from every <ol>/<ul>
   on the page — without this override, toggling a numbered/bullet list
   inside the editor produces a real <ol>/<li> in the document that's simply
   invisible, since the browser has nothing left to draw the marker with. */
.tiptap-canvas .ProseMirror ol,
.tiptap-summary .ProseMirror ol {
  list-style-type: decimal;
  padding-left: 1.4em;
  margin: 0.5em 0;
}
.tiptap-canvas .ProseMirror ul,
.tiptap-summary .ProseMirror ul {
  list-style-type: disc;
  padding-left: 1.4em;
  margin: 0.5em 0;
}
.tiptap-canvas .ProseMirror li,
.tiptap-summary .ProseMirror li {
  display: list-item;
}
.tiptap-canvas .ProseMirror li p,
.tiptap-summary .ProseMirror li p {
  margin: 0;
}

/* Same Preflight problem as lists: a bare <table> gets no border, spacing,
   or cell padding at all without this, since Tailwind zeroes those out. */
.tiptap-canvas .ProseMirror table {
  border-collapse: collapse;
  table-layout: fixed;
  width: 100%;
  margin: 0.75em 0;
}
.tiptap-canvas .ProseMirror th,
.tiptap-canvas .ProseMirror td {
  border: 1px solid #E4E8EF;
  padding: 6px 10px;
  vertical-align: top;
  position: relative;
}
.tiptap-canvas .ProseMirror th {
  background: #F8FAFC;
  font-weight: 800;
  text-align: left;
}
.tiptap-canvas .ProseMirror td > p,
.tiptap-canvas .ProseMirror th > p {
  margin: 0;
}
.tiptap-canvas .ProseMirror .selectedCell {
  background: #E6F0FB;
}

/* Overview Summary field — grows with its content, never scrolls internally */
.tiptap-summary .ProseMirror {
  min-height: 60px;
  outline: none;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: #1A2A44;
}
.tiptap-summary .ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder);
  color: #94A3B8;
  float: left;
  height: 0;
  pointer-events: none;
}
