/* 
  Baraem Admin Styles - Modern Editorial
  Unified, tokenized, and refined for high-precision productivity.
*/

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

:root {
  /* Tokens from DESIGN.md mapped for CSS use */
  --br-bg-primary: oklch(98% 0.005 140);
  --br-bg-secondary: oklch(94% 0.008 140);
  --br-text-primary: oklch(15% 0.01 140);
  --br-text-secondary: oklch(45% 0.01 140);
  --br-brand-primary: oklch(60% 0.15 140);
  --br-brand-action: oklch(55% 0.2 260);
  --br-success: oklch(70% 0.15 140);
  --br-error: oklch(60% 0.15 20);
  --br-warning: oklch(80% 0.15 70);
  --br-border-subtle: oklch(0% 0 0 / 0.05);
  --br-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --br-shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.05);
  --br-radius: 16px;
}

/* Base Body */
body.fi-body {
  background-color: var(--br-bg-secondary) !important;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

[dir="rtl"] body.fi-body,
[dir="rtl"] .fi-body {
  font-family: "Tajawal", sans-serif !important;
}

/* Sidebar Refinement */
.fi-sidebar {
  background: white !important;
  border-inline-end: 1px solid var(--br-border-subtle) !important;
  box-shadow: none !important;
}

.fi-sidebar-header {
  padding: 1.5rem 1rem !important;
}

.fi-sidebar-nav {
  padding-top: 1rem !important;
}

/* Navigation Item High-Precision */
.fi-sidebar-item-active > a {
  background: var(--br-brand-primary) !important;
  color: white !important;
  border-radius: 12px !important;
  margin-inline: 0.5rem !important;
  box-shadow: var(--br-shadow-sm) !important;
}

.fi-sidebar-item-active > a * {
  color: white !important;
}

/* Topbar - Calm & Clean (No Blur) */
.fi-topbar {
  background: white !important;
  border-bottom: 1px solid var(--br-border-subtle) !important;
  position: sticky !important;
  top: 0;
  z-index: 40;
}

.fi-topbar nav {
  box-shadow: none !important;
}

/* Card & Widget Refinement - Editorial Precision */
.fi-wi-widget > div,
.fi-section,
.fi-ta-ctn,
.fi-wi-stats-overview-stat {
  background: white !important;
  border: 1px solid var(--br-border-subtle) !important;
  border-radius: var(--br-radius) !important;
  box-shadow: var(--br-shadow-md) !important;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fi-wi-stats-overview-stat:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
}

/* Table Refinement */
.fi-ta-header {
  background: var(--br-bg-primary) !important;
  border-bottom: 1px solid var(--br-border-subtle) !important;
}

.fi-ta-header-cell-label {
  color: var(--br-text-secondary) !important;
  font-weight: 600 !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
}

/* Form Elements */
.fi-fo-field-wrp label {
  color: var(--br-text-primary) !important;
  font-weight: 500 !important;
}

.fi-input-wrp {
  border-radius: 10px !important;
  border-color: var(--br-border-subtle) !important;
  transition: border-color 0.2s ease;
}

.fi-input-wrp:focus-within {
  border-color: var(--br-brand-primary) !important;
  box-shadow: 0 0 0 2px var(--br-brand-primary)33 !important;
}

/* Notification Center - Distilled Excellence */
.fi-topbar-database-notifications-btn {
  background: var(--br-bg-secondary) !important;
  color: var(--br-brand-primary) !important;
  border-radius: 10px !important;
  padding: 6px !important;
}

.fi-badge {
  border: 2px solid white !important;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* Unread Notifications */
.fi-no-notification-unread-ctn {
  background-color: var(--br-bg-primary) !important;
  border-inline-start: 4px solid var(--br-brand-primary) !important;
}

/* Dark Mode Support (Refined) */
.dark body.fi-body {
  background-color: #0f172a !important;
}

.dark .fi-sidebar,
.dark .fi-topbar,
.dark .fi-wi-widget > div,
.dark .fi-section,
.dark .fi-ta-ctn,
.dark .fi-wi-stats-overview-stat {
  background: #1e293b !important;
  border-color: rgba(255,255,255,0.05) !important;
}

.dark .fi-text-primary {
  color: #f1f5f9 !important;
}

.dark .fi-text-secondary {
  color: #94a3b8 !important;
}

/* ═══════════════════════════════════════════
   HIGH-CONTRAST HARDENING (WCAG AAA)
   ═══════════════════════════════════════════ */

/* Primary Buttons: Force White Text on Dark Green */
.fi-btn-color-primary,
.fi-btn[type="submit"],
.fi-ac-btn-action {
  background-color: var(--br-brand-primary) !important;
  color: white !important;
  font-weight: 600 !important;
  box-shadow: var(--br-shadow-sm) !important;
}

.fi-btn-color-primary:hover {
  background-color: oklch(50% 0.15 140) !important; /* Slightly darker on hover */
}

/* Ensure icons inside primary buttons are also white */
.fi-btn-color-primary svg,
.fi-btn[type="submit"] svg {
  color: white !important;
}

/* Secondary/Ghost Buttons: Neutral High Contrast */
.fi-btn-color-gray {
  background-color: white !important;
  color: var(--br-text-primary) !important;
  border: 1px solid var(--br-border-subtle) !important;
  box-shadow: var(--br-shadow-sm) !important;
}

.dark .fi-btn-color-gray {
  background-color: #334155 !important;
  color: white !important;
  border-color: rgba(255,255,255,0.1) !important;
}

/* Badge Contrast */
.fi-badge,
.fi-ta-badge,
[class*="fi-badge-color-"] {
  padding: 4px 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  border-radius: 9999px !important;
  text-transform: uppercase !important;
  font-size: 0.75rem !important;
}

/* Force White Text for High-Contrast Visibility */
.fi-badge-color-danger,
.fi-badge-color-error,
[class*="fi-badge-color-danger"],
[class*="fi-badge-color-error"] {
  background-color: #be123c !important; /* Deep Crimson */
  color: white !important;
}

.fi-badge-color-success,
[class*="fi-badge-color-success"] {
  background-color: #15803d !important; /* Deep Green */
  color: white !important;
}

.fi-badge-color-primary,
[class*="fi-badge-color-primary"] {
  background-color: var(--br-brand-primary) !important;
  color: white !important;
}

.fi-badge-color-warning,
[class*="fi-badge-color-warning"] {
  background-color: var(--br-warning) !important;
  color: #78350f !important; /* Deep Amber for light backgrounds */
}

/* ═══════════════════════════════════════════
   LEGAL CONSENT DOCUMENT STYLING
   ═══════════════════════════════════════════ */
.document-scroll-container svg {
  max-width: 1.5rem !important; /* 24px */
  max-height: 1.5rem !important; /* 24px */
  display: inline-block;
}

.document-scroll-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* ═══════════════════════════════════════════
   BARAEM AI ASSISTANT CHATBOT WIDGET STYLING
   ═══════════════════════════════════════════ */
:root {
    --chat-primary: #004D40;
    --chat-primary-hover: #003d33;
    --chat-primary-light: #e0f2f1;
    --chat-bg: #ffffff;
    --chat-bg-dark: #1f2937;
    --chat-border: #e5e7eb;
    --chat-text: #1f2937;
    --chat-text-light: #6b7280;
    --chat-user-bg: #004D40;
    --chat-user-text: #ffffff;
    --chat-ai-bg: #f3f4f6;
    --chat-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* Floating Action Button (FAB) */
.baraem-chat-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    width: 56px;
    height: 56px;
    background-color: var(--chat-primary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 50% !important;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3) !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.baraem-chat-fab:hover {
    transform: scale(1.08) !important;
    background-color: var(--chat-primary-hover) !important;
}

.baraem-chat-fab svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
}

/* Chat Drawer / Window */
.baraem-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    z-index: 9998;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 120px);
    background-color: var(--chat-bg) !important;
    border: 1px solid var(--chat-border) !important;
    border-radius: 16px !important;
    box-shadow: var(--chat-shadow) !important;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    font-family: inherit;
}

.baraem-chat-window.open {
    transform: translateY(0) scale(1) !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* RTL Support override */
.baraem-chat-rtl {
    direction: rtl;
    text-align: right;
}

/* Header */
.baraem-chat-header {
    background-color: #002e26 !important;
    color: #ffffff !important;
    padding: 14px 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1) !important;
}

.baraem-chat-header-info {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.baraem-chat-header-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    background-color: var(--chat-primary) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
}

.baraem-chat-header-title {
    font-weight: 600 !important;
    font-size: 14px !important;
    margin: 0 !important;
    line-height: 1.2 !important;
    color: #ffffff !important;
}

.baraem-chat-header-subtitle {
    font-size: 11px !important;
    color: #80cbc4 !important;
    margin: 0 !important;
    margin-top: 2px !important;
}

.baraem-chat-header-actions {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
}

.baraem-chat-header-btn {
    background: none !important;
    border: none !important;
    color: #80cbc4 !important;
    cursor: pointer !important;
    padding: 4px !important;
    border-radius: 6px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: background-color 0.2s, color 0.2s;
}

.baraem-chat-header-btn:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
}

.baraem-chat-header-btn svg {
    width: 18px !important;
    height: 18px !important;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
}

/* Chat Body (Message Container) */
.baraem-chat-body {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
    background-color: #f9fafb !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
}

/* Welcome Panel */
.baraem-chat-welcome {
    height: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    padding: 0 12px !important;
    gap: 16px !important;
}

.baraem-chat-welcome-emoji {
    font-size: 40px !important;
}

.baraem-chat-welcome-title {
    font-weight: 700 !important;
    font-size: 16px !important;
    color: var(--chat-text) !important;
    margin: 0 !important;
}

.baraem-chat-welcome-desc {
    font-size: 13px !important;
    color: var(--chat-text-light) !important;
    margin: 0 !important;
    line-height: 1.4 !important;
}

/* Suggested chips */
.baraem-chat-suggested {
    width: 100% !important;
    margin-top: 8px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
}

.baraem-chat-suggested-label {
    font-size: 11px !important;
    font-weight: 600 !important;
    color: var(--chat-text-light) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
    margin: 0 !important;
    text-align: inherit !important;
}

.baraem-chat-suggested-btn {
    font-size: 12px !important;
    color: var(--chat-primary) !important;
    background-color: var(--chat-primary-light) !important;
    border: 1px solid rgba(0, 77, 64, 0.1) !important;
    padding: 10px 14px !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    text-align: inherit !important;
    transition: background-color 0.2s;
}

.baraem-chat-suggested-btn:hover {
    background-color: #b2dfdb !important;
}

/* Message Bubbles */
.baraem-chat-msg-row {
    display: flex !important;
    width: 100% !important;
}

.baraem-chat-msg-row.user {
    justify-content: flex-end !important;
}

.baraem-chat-msg-row.assistant {
    justify-content: flex-start !important;
}

.baraem-chat-msg-bubble {
    max-width: 85% !important;
    padding: 10px 14px !important;
    font-size: 13.5px !important;
    line-height: 1.45 !important;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05) !important;
}

.baraem-chat-msg-row.user .baraem-chat-msg-bubble {
    background-color: var(--chat-user-bg) !important;
    color: var(--chat-user-text) !important;
    border-radius: 16px 16px 0 16px !important;
}
.baraem-chat-rtl .baraem-chat-msg-row.user .baraem-chat-msg-bubble {
    border-radius: 16px 16px 16px 0 !important;
}

.baraem-chat-msg-row.assistant .baraem-chat-msg-bubble {
    background-color: var(--chat-ai-bg) !important;
    color: var(--chat-text) !important;
    border-radius: 16px 16px 16px 0 !important;
    border: 1px solid rgba(0, 0, 0, 0.03) !important;
}
.baraem-chat-rtl .baraem-chat-msg-row.assistant .baraem-chat-msg-bubble {
    border-radius: 16px 16px 0 16px !important;
}

/* Basic Markdown representation */
.baraem-chat-msg-bubble p {
    margin: 0 0 8px 0 !important;
}
.baraem-chat-msg-bubble p:last-child {
    margin-bottom: 0 !important;
}
.baraem-chat-msg-bubble ul, .baraem-chat-msg-bubble ol {
    margin: 0 0 8px 0 !important;
    padding-left: 20px !important;
}
.baraem-chat-rtl .baraem-chat-msg-bubble ul, .baraem-chat-rtl .baraem-chat-msg-bubble ol {
    padding-left: 0 !important;
    padding-right: 20px !important;
}
.baraem-chat-msg-bubble li {
    margin-bottom: 4px !important;
}
.baraem-chat-msg-bubble strong {
    font-weight: 600 !important;
}

/* Loading Indicator */
.baraem-chat-loading-dots {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 4px 6px !important;
}

.baraem-chat-loading-dots span {
    width: 6px !important;
    height: 6px !important;
    background-color: var(--chat-primary) !important;
    border-radius: 50% !important;
    display: inline-block !important;
    animation: baraem-bounce 1.4s infinite ease-in-out both !important;
}

.baraem-chat-loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.baraem-chat-loading-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes baraem-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1.0); }
}

/* Error feedback */
.baraem-chat-error {
    background-color: #fef2f2 !important;
    border: 1px solid #fee2e2 !important;
    color: #b91c1c !important;
    border-radius: 10px !important;
    padding: 8px 12px !important;
    font-size: 11px !important;
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin: 4px 0 !important;
}

/* Input Area */
.baraem-chat-input-form {
    padding: 12px !important;
    border-top: 1px solid var(--chat-border) !important;
    background-color: var(--chat-bg) !important;
    display: flex !important;
    gap: 8px !important;
    align-items: center !important;
}

.baraem-chat-input {
    flex: 1 !important;
    padding: 10px 14px !important;
    border: 1px solid #d1d5db !important;
    border-radius: 10px !important;
    font-size: 13px !important;
    outline: none !important;
    background-color: #f9fafb !important;
    transition: border-color 0.2s, box-shadow 0.2s !important;
}

.baraem-chat-input:focus {
    border-color: var(--chat-primary) !important;
    box-shadow: 0 0 0 2px var(--chat-primary-light) !important;
    background-color: #ffffff !important;
}

.baraem-chat-send-btn {
    background-color: var(--chat-primary) !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 10px !important;
    padding: 10px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
    transition: background-color 0.2s !important;
}

.baraem-chat-send-btn:hover {
    background-color: var(--chat-primary-hover) !important;
}

.baraem-chat-send-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
}

.baraem-chat-send-btn svg {
    width: 16px !important;
    height: 16px !important;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8 !important;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    .baraem-chat-window {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
    }
}

