/* ====================================================================
   SVK Feed ERP | علاف برو — المنظومة الشاملة لإدارة مخازن الأعلاف والتوزيع
   High-Performance Agri-Tech Warehouse Operating System
   ==================================================================== */

:root {
  --bg-primary: #0b1319;
  --bg-secondary: #13222e;
  --bg-tertiary: #1b2f3f;
  --bg-card: #152634;
  --bg-card-hover: #1c3345;
  --border-color: #243e54;
  --border-focus: #10b981;

  --text-main: #f0fdf4;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --agri-green: #10b981;
  --agri-green-dark: #059669;
  --agri-green-light: #34d399;
  --agri-gold: #f59e0b;
  --agri-gold-dark: #d97706;
  --agri-sky: #0ea5e9;
  --agri-purple: #a855f7;
  --agri-red: #ef4444;

  --sidebar-w: 260px;
  --header-h: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  --font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* Light Mode Overrides */
body.theme-light {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #059669;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;

  --agri-green: #059669;
  --agri-green-dark: #047857;
  --agri-green-light: #10b981;
  --shadow-sm: 0 2px 4px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  direction: rtl;
  overflow-x: hidden;
  font-size: 14px;
  line-height: 1.5;
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* Layout */
.app-container {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.brand-section {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(0, 0, 0, 0.1);
}

.brand-logo {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--agri-green), var(--agri-gold));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

.brand-info h1 {
  font-size: 15.5px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
}

.brand-info span {
  font-size: 11px;
  color: var(--agri-gold);
  font-weight: 700;
  display: block;
}

.nav-menu {
  flex: 1;
  overflow-y: auto;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  padding: 8px 12px 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: right;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(16, 185, 129, 0.15), rgba(16, 185, 129, 0.05));
  color: var(--agri-green-light);
  border-right: 3px solid var(--agri-green);
  border-color: rgba(16, 185, 129, 0.2);
}

body.theme-light .nav-item.active {
  color: var(--agri-green-dark);
}

.nav-item .icon {
  font-size: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.15);
  font-size: 11px;
  color: var(--text-dim);
}

.license-status-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: var(--radius-sm);
  color: var(--agri-green-light);
  font-weight: 700;
  cursor: pointer;
  margin-top: 6px;
}

body.theme-light .license-status-badge {
  color: var(--agri-green-dark);
}

/* Main Content Area */
.main-wrapper {
  flex: 1;
  margin-right: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  overflow-x: hidden;
}

/* Top Header */
.top-header {
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-title h2 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.header-title .crumb {
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-toggle-btn {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cash-pill {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 6px 14px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--agri-gold-dark);
}

.btn-quick-pos {
  background: linear-gradient(135deg, var(--agri-green), var(--agri-green-dark));
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(16, 185, 129, 0.3);
  transition: all 0.2s ease;
}

.btn-quick-pos:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 14px rgba(16, 185, 129, 0.4);
}

/* Content Pages */
.content-body {
  padding: 22px;
  flex: 1;
}

.tab-pane {
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

.tab-pane.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* KPI Cards Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--card-accent, var(--agri-green));
}

.kpi-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
}

.kpi-details h4 {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 3px;
}

.kpi-details .kpi-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.kpi-details .kpi-sub {
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Panels */
.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-header {
  padding: 14px 18px;
  background: rgba(0, 0, 0, 0.08);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-body {
  padding: 18px;
}

/* Tables */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 13px;
}

.data-table th {
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  font-weight: 700;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}

.badge-green { background: rgba(16, 185, 129, 0.15); color: #10b981; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-gold { background: rgba(245, 158, 11, 0.15); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-sky { background: rgba(14, 165, 233, 0.15); color: #0ea5e9; border: 1px solid rgba(14, 165, 233, 0.3); }
.badge-red { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; border: 1px solid rgba(168, 85, 247, 0.3); }

/* Forms & Inputs */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 14px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: var(--agri-green); color: #fff; }
.btn-primary:hover { background: var(--agri-green-dark); }

.btn-warning { background: var(--agri-gold); color: #000; }
.btn-warning:hover { background: var(--agri-gold-dark); }

.btn-secondary { background: var(--bg-tertiary); border-color: var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background: var(--bg-card-hover); }

.btn-danger { background: var(--agri-red); color: #fff; }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 4px 9px; font-size: 11.5px; }

/* POS Specific Layout */
.pos-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  gap: 16px;
  align-items: start;
  width: 100%;
}

.pos-catalog {
  min-width: 0;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
}

.catalog-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
}

.filter-chip {
  padding: 5px 12px;
  border-radius: 20px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-chip.active, .filter-chip:hover {
  background: rgba(16, 185, 129, 0.15);
  border-color: var(--agri-green);
  color: var(--agri-green-light);
}

body.theme-light .filter-chip.active {
  color: var(--agri-green-dark);
}

.feed-items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  max-height: 560px;
  overflow-y: auto;
  padding-left: 4px;
}

.feed-item-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.feed-item-card:hover {
  border-color: var(--agri-green);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.feed-item-company {
  font-size: 11px;
  color: var(--agri-gold);
  font-weight: 700;
}

.feed-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  margin: 3px 0 6px;
  line-height: 1.3;
}

.feed-item-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid rgba(255,255,255,0.05);
  padding-top: 8px;
  margin-top: auto;
}

.feed-item-price {
  font-size: 13px;
  font-weight: 800;
  color: var(--agri-green);
}

.feed-item-stock {
  font-size: 11px;
  color: var(--text-dim);
}

/* POS Cart / Invoice Panel */
.pos-cart-panel {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  width: 390px;
  min-width: 370px;
  max-width: 420px;
  box-sizing: border-box;
}

.pos-cart-header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 10px;
}

.pos-cart-items {
  max-height: 270px;
  overflow-y: auto;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cart-item-row {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cart-item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.cart-item-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 4px;
}

.cart-item-qty input {
  width: 50px;
  text-align: center;
  padding: 4px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-main);
  font-weight: 700;
}

.cart-totals {
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cart-total-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-muted);
}

.cart-total-row.grand {
  font-size: 17px;
  font-weight: 800;
  color: var(--text-main);
  border-top: 1px dashed var(--border-color);
  padding-top: 8px;
  margin-top: 4px;
}

.cart-total-row.grand span:last-child {
  color: var(--agri-green);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0,0,0,0.1);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text-main); }

.modal-body {
  padding: 18px;
  flex: 1;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-color);
  background: rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* Printable Invoices & Vouchers */
#printArea {
  display: none;
}

@media print {
  @page {
    margin: 5mm;
  }
  html, body {
    background: #fff !important;
    color: #000 !important;
    height: auto !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  body > *:not(#printArea) {
    display: none !important;
  }
  #printArea {
    display: block !important;
    position: static !important;
    width: 100% !important;
    color: #000 !important;
    background: #fff !important;
    margin: 0 auto !important;
  }
  .no-print {
    display: none !important;
  }
}

/* Thermal 80mm Receipt Style */
.thermal-receipt {
  width: 80mm;
  padding: 4mm;
  background: #fff;
  color: #000;
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  margin: 0 auto;
}

.thermal-header {
  text-align: center;
  border-bottom: 1px dashed #000;
  padding-bottom: 6px;
  margin-bottom: 8px;
}

.thermal-items table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}

.thermal-items th, .thermal-items td {
  padding: 4px 2px;
  text-align: right;
}

.thermal-totals {
  border-top: 1px dashed #000;
  margin-top: 8px;
  padding-top: 6px;
  font-weight: bold;
}

/* Official A4 Voucher / Invoice */
.a4-voucher {
  max-width: 210mm;
  padding: 12mm;
  background: #fff;
  color: #000;
  border: 1px solid #ccc;
  margin: 0 auto;
  font-family: 'Cairo', Arial, sans-serif;
}

.a4-voucher-header {
  display: flex;
  justify-content: space-between;
  border-bottom: 2px solid #000;
  padding-bottom: 10px;
  margin-bottom: 14px;
}

/* Responsive adjustments */
@media (max-width: 1120px) {
  .pos-layout {
    grid-template-columns: 1fr;
  }
  .pos-cart-panel {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-wrapper {
    margin-right: 0;
  }
  .form-grid-2, .form-grid-3, .form-grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ==================================================================== */
/* AI ASSISTANT HUB STYLES (المساعد والمستشار الذكي)                    */
/* ==================================================================== */

.nav-ai-item {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.12), rgba(99, 102, 241, 0.15)) !important;
  border: 1px solid rgba(99, 102, 241, 0.35) !important;
  position: relative;
  overflow: hidden;
}

.nav-ai-item:hover {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.25), rgba(99, 102, 241, 0.25)) !important;
  border-color: #818cf8 !important;
}

.badge-ai-live {
  background: linear-gradient(135deg, #0d9488, #6366f1);
  color: #fff;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 800;
  margin-right: auto;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
  animation: pulseAI 2s infinite;
}

@keyframes pulseAI {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(0.96); }
}

.ai-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  min-height: 600px;
  gap: 14px;
}

.ai-header-card {
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}

.ai-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ai-header-avatar {
  font-size: 36px;
  width: 54px;
  height: 54px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(99, 102, 241, 0.3);
}

.ai-header-title {
  margin: 0 0 4px 0;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.ai-header-sub {
  margin: 0;
  font-size: 12.5px;
  color: #94a3b8;
}

.ai-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 5px 12px;
  border-radius: 20px;
}

.ai-status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* Chips Bar */
.ai-chips-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.ai-chips-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-chip-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-color);
  color: #e2e8f0;
  border-radius: 20px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: inherit;
}

.ai-chip-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: #6366f1;
  color: #fff;
  transform: translateY(-1px);
}

.ai-chip-btn.highlight {
  background: rgba(13, 148, 136, 0.15);
  border-color: #0d9488;
  color: #2dd4bf;
}

/* Messages Container */
.ai-chat-window {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.ai-messages-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
  animation: aiFade 0.25s ease-out;
}

@keyframes aiFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-msg.user {
  align-self: flex-start;
  flex-direction: row;
}

.ai-msg.bot {
  align-self: flex-end;
  flex-direction: row-reverse;
  max-width: 90%;
}

.ai-msg-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: #1e293b;
  border: 1px solid var(--border-color);
}

.ai-msg.bot .ai-msg-avatar {
  background: linear-gradient(135deg, #0f172a, #312e81);
  border-color: #4f46e5;
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.3);
}

.ai-msg-bubble {
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--text-color);
  font-size: 13.5px;
  line-height: 1.65;
  position: relative;
}

.ai-msg.user .ai-msg-bubble {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff;
  border: none;
  border-top-right-radius: 2px;
}

.ai-msg.bot .ai-msg-bubble {
  background: #0f172a;
  border: 1px solid #334155;
  border-top-left-radius: 2px;
}

.ai-msg-time {
  font-size: 10.5px;
  color: #64748b;
  margin-top: 6px;
  text-align: left;
}

.ai-msg.user .ai-msg-time {
  color: rgba(255, 255, 255, 0.7);
}

.ai-speak-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 8px;
  transition: all 0.2s;
}

.ai-speak-btn:hover {
  color: #38bdf8;
  background: rgba(255, 255, 255, 0.05);
}

/* AI Rich Cards in Answers */
.ai-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.ai-mini-kpi {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 10px;
  text-align: center;
}

.ai-mini-val {
  font-size: 16px;
  font-weight: 800;
  color: #38bdf8;
}

.ai-mini-lbl {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 2px;
}

.ai-alert-box {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0;
  color: #fca5a5;
  font-size: 12.5px;
}

.ai-table-mini {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin: 8px 0;
}

.ai-table-mini th {
  background: #1e293b;
  color: #94a3b8;
  padding: 6px 8px;
  text-align: right;
  border-bottom: 1px solid #334155;
}

.ai-table-mini td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

/* Input Area */
.ai-chat-input-bar {
  background: #091220;
  border-top: 1px solid var(--border-color);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.ai-chat-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13.5px;
  color: #fff;
  outline: none;
  font-family: inherit;
}

.ai-chat-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.ai-btn-send {
  background: linear-gradient(135deg, #0d9488, #6366f1);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.ai-btn-send:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.ai-btn-voice {
  background: #1e293b;
  border: 1px solid var(--border-color);
  color: #94a3b8;
  border-radius: 12px;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.ai-btn-voice:hover {
  color: #fff;
  border-color: #ef4444;
}

.ai-btn-voice.listening {
  background: #ef4444;
  color: #fff;
  animation: pulseAI 1s infinite;
}
