/* ============================================================================
   1C INVENTORY & SALES AI ASSISTANT - STYLESHEET
   Theme: 1C Yellow Signature | 3-Column Category Sales Revenue Grid (High to Low)
   ============================================================================ */

:root {
  /* 1C Enterprise Palette */
  --1c-yellow-main: #ffe066;
  --1c-yellow-light: #fff8d6;
  --1c-yellow-soft: #fffdf0;
  --1c-yellow-border: #f0d050;
  --1c-header-bg: #fff3b0;
  --1c-gold-accent: #d97706;
  --1c-gold-hover: #b45309;

  --bg-primary: #f8fafc;
  --bg-white: #ffffff;
  
  --border-color: #e2e8f0;
  --border-yellow: #ebd57b;

  --primary: #d97706;
  --primary-hover: #b45309;

  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;

  --text-dark: #1e293b;
  --text-muted: #64748b;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 4px;
  --radius-md: 8px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--1c-yellow-soft);
  color: var(--text-dark);
  line-height: 1.45;
  height: 100vh;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* MAIN CONTENT SPLIT-SCREEN */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* BÊN TRÁI (65% WIDTH) - DASHBOARD NỀN MÀU TRẮNG */
.left-pane-dashboard {
  width: 65%;
  flex: 1;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  border-right: 2px solid var(--1c-yellow-border);
  overflow: hidden;
}

/* BÊN PHẢI (35% WIDTH) - CHATBOT NỀN MÀU VÀNG NHẠT */
.right-pane-chat {
  width: 35%;
  min-width: 340px;
  background: var(--1c-yellow-light);
  display: flex;
  flex-direction: column;
}

.pane-header {
  padding: 8px 14px;
  background: linear-gradient(90deg, #fff5c0, #ffe994);
  border-bottom: 1px solid var(--1c-yellow-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* INLINE CONTROLS IN LEFT PANE HEADER */
.pane-controls-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.control-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.81rem;
  color: #78350f;
  font-weight: 700;
}

.control-inline select {
  background-color: #ffffff;
  color: var(--text-dark);
  border: 1px solid var(--1c-yellow-border);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  outline: none;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

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

.header-title h2 {
  font-size: 0.9rem;
  font-weight: 700;
  color: #78350f;
}

.ai-status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
}

.model-badge {
  font-size: 0.7rem;
  background: rgba(217, 119, 6, 0.15);
  color: #92400e;
  border: 1px solid rgba(217, 119, 6, 0.3);
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: 600;
}

.btn-icon {
  background: none;
  border: none;
  color: #78350f;
  cursor: pointer;
  padding: 4px;
}

/* DASHBOARD SCROLL AREA (COMPACT HIGH DENSITY) */
.dashboard-scroll-area {
  flex: 1;
  padding: 10px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #ffffff;
}

.last-sync {
  font-size: 0.74rem;
  color: #78350f;
  font-weight: 600;
  white-space: nowrap;
}


/* HEADER SYNC AREA (NEW) */
.header-sync-time {
  flex: 1;
  text-align: center;
}

.header-sync-time .last-sync {
  font-size: 0.85rem;
  color: #b45309;
  font-weight: 700;
}

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

.btn-sync-header {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 4px rgba(180, 83, 9, 0.2);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-sync-header:hover {
  background: linear-gradient(135deg, #b45309, #92400e);
}

.ai-table th {
  background: #fef08a !important;
  color: #0369a1 !important; /* Xanh da trời đậm */
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  text-align: center !important;
}



/* DATA TABLE CARD (MAXIMIZED FULL SPACE) */
.table-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.table-header {
  padding: 7px 12px;
  background: #fef08a;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.table-header h3 {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-dark);
}

.table-search input {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  padding: 4px 10px 4px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  outline: none;
  width: 190px;
}

.table-search i {
  position: absolute;
  left: 8px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.table-responsive {
  overflow-x: auto;
  flex: 1;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.8rem;
}

.data-table th {
  background: #f1f5f9;
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-dark);
}

.data-table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

.data-table tbody tr:hover {
  background-color: #fffdf0 !important;
}

.data-table th:last-child {
  background: #fef08a !important; /* highlight table header doanh thu */
}

.data-table td:last-child {
  background-color: rgba(16, 185, 129, 0.06);
}

.code-cell {
  font-family: var(--font-mono);
  font-weight: 600;
  color: #1d4ed8;
}

.num-cell {
  font-family: var(--font-mono);
  font-weight: 600;
}

.sales-cell {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #059669;
}

.cat-cell {
  font-weight: 600;
  color: #6b21a8;
  background: #faf5ff;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* BADGES */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-safe {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(22, 163, 74, 0.3);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, 0.3);
}

/* TABLE PAGINATION STYLES */
.table-pagination {
  padding: 8px 12px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pagination-info strong {
  color: var(--text-dark);
  font-family: var(--font-mono);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-page {
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-dark);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-page:hover:not(:disabled) {
  background: var(--1c-yellow-main);
  border-color: var(--1c-yellow-border);
  color: #78350f;
}

.btn-page:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.page-indicator {
  font-weight: 700;
  color: #78350f;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: #fff8d6;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--1c-yellow-border);
}

/* CHATBOT (RIGHT PANE - 35% WIDTH - NỀN MÀU VÀNG NHẠT) */
.chat-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--1c-yellow-light);
}

.message {
  display: flex;
  gap: 8px;
  max-width: 94%;
  animation: fadeIn 0.3s ease;
}

.message.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message .avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

.system-message .avatar {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
}

.user-message .avatar {
  background: #334155;
  color: #fff;
}

.message-content {
  background: #ffffff;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 0.83rem;
  border: 1px solid var(--1c-yellow-border);
  line-height: 1.4;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
}

.user-message .message-content {
  background: #d97706;
  color: #ffffff;
  border: none;
}

/* CHAT INPUT AREA (KHUNG CHỮ NỀN TRẮNG) */
.chat-input-area {
  padding: 10px 14px;
  border-top: 1px solid var(--1c-yellow-border);
  background: #fff3b0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.textarea-wrapper {
  flex: 1;
  background: #ffffff;
  border: 1px solid var(--1c-yellow-border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: block;
}

.chat-input-area textarea {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text-dark);
  font-size: 13px;
  line-height: normal;
  margin: 0;
  padding: 0;
  resize: none;
  outline: none;
  font-family: inherit;
  overflow-y: auto;
}

.chat-input-area textarea:focus {
  border-color: var(--1c-gold-accent);
}

.btn-send {
  background: linear-gradient(135deg, #d97706, #b45309);
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  justify-content: center;
  align-items: center;
  display: flex;
  padding: 0;
  font-size: 1.1rem;
}

.empty-row {
  text-align: center;
  padding: 24px !important;
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.85rem;
}

@media (max-width: 1024px) {
  .main-content {
    flex-direction: column;
    overflow-y: auto;
  }
  .left-pane-dashboard, .right-pane-chat {
    width: 100%;
  }
}
