/* ════════════════════════════════════════════════════════════
   Odoo Enterprise-like Theme — ERP Demo
   ════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
  --odoo-purple:     #875A7B;
  --odoo-purple-lt:  #f3edf7;
  --odoo-purple-dk:  #6d4863;
  --sidebar-bg:      #1a1e2d;
  --sidebar-w:       220px;
  --topbar-h:        46px;
  --bg:              #f5f5f5;
  --white:           #ffffff;
  --border:          #d0d5dd;
  --border-lt:       #e9ecef;
  --text:            #212529;
  --muted:           #6c757d;
  --success:         #28a745;
  --warning:         #e6a817;
  --danger:          #dc3545;
  --info:            #17a2b8;
  --chat-w:          380px;
  --chat-h:          520px;
}

/* ── Reset / base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  height: 100vh;
}
a { text-decoration: none; color: inherit; }

/* ════════════════════════════════════════════════════════════
   TOP BAR
   ════════════════════════════════════════════════════════════ */
.o-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  z-index: 1000;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

/* Waffle / hamburger */
.o-waffle {
  width: 30px; height: 30px;
  display: grid;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(3, 5px);
  gap: 2.5px;
  align-content: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  transition: background .15s;
  flex-shrink: 0;
}
.o-waffle:hover { background: var(--odoo-purple-lt); }
.o-waffle span {
  display: block;
  width: 5px; height: 5px;
  border-radius: 1px;
  background: var(--odoo-purple);
}

.o-topbar-brand {
  font-size: .9rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  flex-shrink: 0;
}
.o-topbar-sep {
  display: block;
  width: 1px;
  height: 18px;
  background: var(--border);
  flex-shrink: 0;
  margin: 0 4px;
}

/* Breadcrumb */
.o-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 8px;
  font-size: .82rem;
  color: var(--muted);
}
.o-breadcrumb-app { color: var(--muted); }
.o-breadcrumb-sep { font-size: .65rem; opacity: .5; }
.o-breadcrumb-view { color: var(--text); font-weight: 500; }

/* Search */
.o-topbar-search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: #f8f9fa;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  gap: 6px;
}
.o-search-icon { color: var(--muted); font-size: .85rem; flex-shrink: 0; }
.o-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: .82rem;
  color: var(--text);
  min-width: 0;
}
.o-search-filter-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .75rem;
  color: var(--odoo-purple);
  background: var(--odoo-purple-lt);
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
  cursor: default;
}

/* Right icons */
.o-topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.o-topbar-icon {
  position: relative;
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  transition: background .15s;
}
.o-topbar-icon:hover { background: var(--odoo-purple-lt); color: var(--odoo-purple); }
.o-notif-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--danger);
}
.o-user-menu {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 8px 3px 3px;
  border-radius: 20px;
  cursor: pointer;
  transition: background .15s;
}
.o-user-menu:hover { background: var(--odoo-purple-lt); }
.o-user-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--odoo-purple);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.o-user-name { font-size: .82rem; font-weight: 500; }

/* ════════════════════════════════════════════════════════════
   LAYOUT
   ════════════════════════════════════════════════════════════ */
.o-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--topbar-h);
}

/* ════════════════════════════════════════════════════════════
   SIDEBAR
   ════════════════════════════════════════════════════════════ */
.o-sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0 16px;
  transition: width .2s ease;
}
.o-sidebar::-webkit-scrollbar { width: 0; }

.o-sidebar-section-title {
  font-size: .65rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  padding: 12px 16px 4px;
  user-select: none;
}

.o-sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  margin: 1px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: rgba(255,255,255,.72);
  font-size: .82rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.o-sidebar-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}
.o-sidebar-item.active {
  background: rgba(135,90,123,.35);
  color: #fff;
}
.o-sidebar-item.active .o-sidebar-icon {
  box-shadow: 0 0 0 2px rgba(135,90,123,.5);
}
.o-sidebar-item-dim { opacity: .55; }
.o-sidebar-item-dim:hover { opacity: .9; }

.o-sidebar-icon {
  width: 28px; height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.o-sidebar-label { white-space: nowrap; overflow: hidden; }

.o-sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.07);
  margin-top: 16px;
}

/* Collapsed sidebar */
.o-layout.sidebar-collapsed .o-sidebar { width: 52px; }
.o-layout.sidebar-collapsed .o-sidebar-label,
.o-layout.sidebar-collapsed .o-sidebar-section-title { display: none; }
.o-layout.sidebar-collapsed .o-sidebar-item { justify-content: center; padding: 7px; margin: 1px 6px; }
.o-layout.sidebar-collapsed .o-sidebar-item { gap: 0; }

/* ════════════════════════════════════════════════════════════
   CONTENT AREA
   ════════════════════════════════════════════════════════════ */
.o-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg);
}

/* View toolbar (Nuevo + vistas) */
.o-view-toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.o-btn-new {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--odoo-purple);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: .8rem;
  font-weight: 500;
  cursor: default;
  transition: background .15s;
}
.o-btn-new:hover { background: var(--odoo-purple-dk); }
.o-btn-secondary {
  display: flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 12px;
  font-size: .8rem;
  cursor: default;
  transition: all .15s;
}
.o-btn-secondary:hover { border-color: var(--odoo-purple); color: var(--odoo-purple); }

.o-view-types {
  margin-left: auto;
  display: flex;
  gap: 1px;
  background: var(--border-lt);
  border-radius: 5px;
  padding: 2px;
}
.o-view-type-btn {
  width: 28px; height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: default;
  font-size: .9rem;
  transition: all .15s;
}
.o-view-type-btn.active { background: white; color: var(--odoo-purple); box-shadow: 0 1px 3px rgba(0,0,0,.1); }

.o-record-count {
  font-size: .78rem;
  color: var(--muted);
  margin-left: 8px;
}

/* ════════════════════════════════════════════════════════════
   STAT BUTTONS (KPI)
   ════════════════════════════════════════════════════════════ */
.o-stats-bar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: stretch;
  overflow-x: auto;
}
.o-stats-bar::-webkit-scrollbar { height: 0; }

.o-stat-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 12px 20px;
  border: none;
  border-right: 1px solid var(--border-lt);
  background: transparent;
  cursor: default;
  transition: background .15s;
  min-width: 140px;
  white-space: nowrap;
}
.o-stat-btn:first-child { border-left: 1px solid var(--border-lt); }
.o-stat-btn:hover { background: var(--odoo-purple-lt); }

.o-stat-value {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--odoo-purple);
  line-height: 1.1;
}
.o-stat-label {
  font-size: .72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: 3px;
}
.o-stat-icon {
  font-size: .8rem;
  margin-bottom: 6px;
  opacity: .6;
}

/* ════════════════════════════════════════════════════════════
   LIST VIEW
   ════════════════════════════════════════════════════════════ */
.o-list-view {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.o-list-view + .o-list-view { margin-top: 0; }

.o-list-header-bar {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-lt);
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fafafa;
}
.o-list-title {
  font-weight: 600;
  font-size: .82rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.o-list-count-badge {
  background: var(--odoo-purple-lt);
  color: var(--odoo-purple);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: .72rem;
  font-weight: 600;
}

/* Table */
.o-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.o-table thead tr {
  background: #f8f9fa;
  border-bottom: 1px solid var(--border);
}
.o-table thead th {
  padding: 8px 12px;
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  white-space: nowrap;
  cursor: default;
  user-select: none;
}
.o-table thead th.sortable { cursor: pointer; }
.o-table thead th.sortable:hover { color: var(--odoo-purple); }
.o-table thead th .sort-icon { opacity: .4; font-size: .65rem; margin-left: 3px; }

.o-table tbody tr {
  border-bottom: 1px solid var(--border-lt);
  transition: background .1s;
}
.o-table tbody tr:last-child { border-bottom: none; }
.o-table tbody tr:hover { background: #f8f4fb; }

.o-table tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  color: var(--text);
}

/* Checkbox col */
.o-col-check { width: 36px; text-align: center; }
.o-checkbox {
  width: 14px; height: 14px;
  accent-color: var(--odoo-purple);
  cursor: pointer;
}

/* Rank badge */
.o-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
  background: var(--odoo-purple-lt);
  color: var(--odoo-purple);
}
.o-rank-1 { background: #FFF3CD; color: #e6a817; }
.o-rank-2 { background: #e9ecef; color: #495057; }
.o-rank-3 { background: #f8d7da; color: #dc3545; }

/* Status pills */
.o-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 10px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.o-badge-success  { background: #d4edda; color: #155724; }
.o-badge-warning  { background: #fff3cd; color: #856404; }
.o-badge-danger   { background: #f8d7da; color: #721c24; }
.o-badge-info     { background: #d1ecf1; color: #0c5460; }
.o-badge-purple   { background: var(--odoo-purple-lt); color: var(--odoo-purple-dk); }
.o-badge-gray     { background: #e9ecef; color: #495057; }

/* Progress bar */
.o-progress {
  height: 5px;
  background: var(--border-lt);
  border-radius: 3px;
  overflow: hidden;
  min-width: 60px;
}
.o-progress-bar {
  height: 100%;
  border-radius: 3px;
  background: var(--odoo-purple);
  transition: width .3s;
}
.o-progress-bar.full { background: var(--success); }

/* Two-digit name avatar */
.o-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--odoo-purple-lt);
  color: var(--odoo-purple);
  font-size: .7rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Two-line cell */
.o-cell-main { font-weight: 500; color: var(--text); }
.o-cell-sub  { font-size: .72rem; color: var(--muted); margin-top: 1px; }

/* Numeric cell */
.o-num { font-variant-numeric: tabular-nums; }
.o-num-bold { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--odoo-purple); }

/* ════════════════════════════════════════════════════════════
   LOADING
   ════════════════════════════════════════════════════════════ */
.o-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 80px 0;
  color: var(--muted);
  font-size: .82rem;
}
.o-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--odoo-purple);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ════════════════════════════════════════════════════════════
   CHAT FLOTANTE
   ════════════════════════════════════════════════════════════ */
.chat-toggle-btn {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--odoo-purple);
  color: white;
  border: none;
  font-size: 1.25rem;
  box-shadow: 0 4px 16px rgba(135,90,123,.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1040;
  transition: background .2s, transform .2s;
}
.chat-toggle-btn:hover {
  background: var(--odoo-purple-dk);
  transform: scale(1.06);
}

.chat-panel {
  position: fixed;
  bottom: 86px; right: 24px;
  width: var(--chat-w);
  height: var(--chat-h);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 1039;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(.97);
  pointer-events: none;
  transition: opacity .2s ease, transform .22s cubic-bezier(.16,1,.3,1);
}
.chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

.chat-header {
  background: var(--odoo-purple-dk);
  color: white;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.chat-status {
  font-size: .7rem;
  color: rgba(255,255,255,.65);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #4ade80;
}
.chat-close-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.7);
  cursor: pointer;
  font-size: .9rem;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color .15s;
}
.chat-close-btn:hover { color: white; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f9f7fb;
  scroll-behavior: smooth;
}
.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg-bot  { align-self: flex-start; }
.msg-user { align-self: flex-end; }

.msg-bubble {
  padding: 8px 12px;
  border-radius: 12px;
  font-size: .82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg-bot .msg-bubble {
  background: white;
  color: var(--text);
  border-bottom-left-radius: 3px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
  border: 1px solid var(--border-lt);
}
.msg-user .msg-bubble {
  background: var(--odoo-purple);
  color: white;
  border-bottom-right-radius: 3px;
}
.msg-time {
  font-size: .65rem;
  color: var(--muted);
  margin-top: 3px;
  padding: 0 3px;
}
.msg-user .msg-time { text-align: right; }

.chat-typing {
  padding: 6px 14px;
  display: none;
  align-items: center;
  gap: 3px;
  background: #f9f7fb;
  border-top: 1px solid var(--border-lt);
  font-size: .75rem;
  color: var(--muted);
  flex-shrink: 0;
}
.chat-typing.visible { display: flex; }

.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--odoo-purple);
  animation: tdot 1.1s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes tdot {
  0%,80%,100% { transform: translateY(0); opacity: .4; }
  40%          { transform: translateY(-5px); opacity: 1; }
}
.typing-text { margin-left: 5px; }

.chat-input-area {
  padding: 10px 12px;
  background: white;
  border-top: 1px solid var(--border-lt);
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.chat-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 7px 14px;
  font-size: .82rem;
  outline: none;
  background: #f9f7fb;
  transition: border-color .15s;
}
.chat-input:focus { border-color: var(--odoo-purple); background: white; }
.chat-input:disabled { opacity: .6; }
.chat-send-btn {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--odoo-purple);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  flex-shrink: 0;
  transition: background .15s;
}
.chat-send-btn:hover:not(:disabled) { background: var(--odoo-purple-dk); }
.chat-send-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .o-sidebar { display: none; }
  .o-topbar-search { display: none; }
  .chat-panel { right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; }
}

/* ── Scrollbar global ───────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d0d5dd; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #875A7B; }
