/* ============================================
   LUMI — Internal App Styles (app.renee.cl replica)
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Mulish:wght@400;500;600;700;800&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css');

*, *::before, *::after { box-sizing: border-box; }

:root {
  --primary: #8993f8;
  --primary-dark: #6f3ff5;
  --primary-light: #dde1fe;
  --text: #323843;
  --text-muted: rgba(50,56,67,0.7);
  --text-light: rgba(50,56,67,0.4);
  --border: #e0e0e0;
  --bg: #f5f6fa;
  --white: #ffffff;
  --sidebar-width: 250px;
  --sidebar-mini: 60px;
  --header-height: 60px;
  --font: 'Mulish', sans-serif;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 17px;
  --font-xl: 20px;
  --font-xxl: 24px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

html, body { margin: 0; padding: 0; font-family: var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }

/* ── HEADER ── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-height);
  background: var(--white);
  box-shadow: 0 4px 4px rgba(50,56,67,0.12);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 200;
  transition: margin-left 0.3s ease, width 0.3s ease;
}
.app-header.shifted { margin-left: var(--sidebar-width); width: calc(100% - var(--sidebar-width)); }

.burger-btn {
  width: 36px; height: 36px;
  border: none; border-radius: 6px;
  background: transparent;
  color: #50577a;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
}
.burger-btn:hover { background: var(--white); color: var(--primary); }

.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 42px;
  padding: 0 12px;
  flex: 1;
  max-width: 460px;
}
.search-bar i { color: #969696; }
.search-bar input {
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-muted);
  background: transparent;
  width: 100%;
}

.header-spacer { flex: 1; }

.header-sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

.icon-btn {
  width: 42px; height: 42px;
  border: none; border-radius: 6px;
  background: transparent;
  color: #50577a;
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s, color 0.2s;
  position: relative;
}
.icon-btn:hover { background: var(--primary-light); color: var(--primary); }

.help-btn {
  display: flex; align-items: center; gap: 6px;
  border: none; border-radius: 6px;
  background: transparent;
  color: #50577a;
  font-size: 13px;
  height: 42px; padding: 0 10px;
  transition: background 0.2s, color 0.2s;
}
.help-btn:hover { background: var(--primary-light); color: var(--primary); }
.help-btn img { width: 28px; height: auto; }

.lang-btn {
  width: 38px; height: 38px;
  border: none; border-radius: 50%;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; cursor: pointer;
}

.user-menu { position: relative; }
.user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  border: 2px solid var(--primary-light);
}
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  min-width: 200px;
  padding: 8px;
  display: none;
  z-index: 300;
}
.user-dropdown.open { display: block; }
.user-dropdown li {
  list-style: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 10px;
  transition: background 0.15s, color 0.15s;
}
.user-dropdown li:hover { background: var(--primary-light); color: var(--primary); }
.user-dropdown li i { width: 16px; text-align: center; }

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  box-shadow: 1px 0 3px rgba(159,159,159,0.3);
  display: flex;
  flex-direction: column;
  padding: 16px;
  z-index: 101;
  transition: width 0.35s ease, padding 0.35s ease, left 0.35s ease;
  overflow: hidden;
}
.sidebar.mini { width: var(--sidebar-mini); padding: 16px 8px; }
.sidebar.closed { left: -100vw; }

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
  padding: 8px 0 20px;
  margin-bottom: 4px;
}
.sidebar-logo {
  width: 90px; height: auto;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease;
}
.sidebar-logo:hover { transform: scale(1.08); filter: drop-shadow(0 1px 3px rgba(0,0,0,0.15)); }
.sidebar.mini .sidebar-logo { width: 36px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding-top: 6px; scrollbar-width: none; }
.sidebar-nav::-webkit-scrollbar { display: none; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }
.sidebar-nav li + li { margin-top: 4px; }

.sidebar-divider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--primary-light);
  border-radius: 6px;
  padding: 7px 12px;
  color: rgba(50,56,67,0.9);
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 4px;
}
.sidebar.mini .sidebar-divider { background: var(--primary); font-size: 0; height: 4px; padding: 0; margin: 0 0 4px; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 95%;
  height: 44px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #50577a;
  padding: 0 14px;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
}
.sidebar-item:hover, .sidebar-item.active { background: var(--primary); color: var(--white); }
.sidebar-item.active .menu-icon { filter: brightness(0) invert(1); }
.sidebar-item:hover .menu-icon { filter: brightness(0) invert(1); transform: scale(1.15); }
.sidebar-item span { transition: opacity 0.3s ease; }
.sidebar.mini .sidebar-item { width: 40px; height: 40px; padding: 0; justify-content: center; gap: 0; }
.sidebar.mini .sidebar-item span { display: none; opacity: 0; }

.menu-icon { width: 18px; height: 18px; transition: filter 0.18s, transform 0.18s; flex-shrink: 0; }

/* ── MAIN CONTENT ── */
.main-content {
  margin-left: var(--sidebar-width);
  width: calc(100% - var(--sidebar-width));
  min-height: 100vh;
  transition: margin-left 0.3s, width 0.3s;
}
.main-content.mini { margin-left: var(--sidebar-mini); width: calc(100% - var(--sidebar-mini)); }
.content-area { padding-top: var(--header-height); }

/* ── PAGE WRAPPER ── */
.page { padding: 24px; }
.page-title {
  color: var(--text);
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 6px;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 400;
  margin: 0 0 28px;
}

/* ── CARDS ── */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 700; color: var(--text); margin: 0; }

/* ── STAT CARDS ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.stat-icon.purple { background: rgba(137,147,248,0.12); color: var(--primary); }
.stat-icon.green { background: rgba(75,209,153,0.12); color: #4bd199; }
.stat-icon.blue { background: rgba(9,134,192,0.12); color: #0986c0; }
.stat-icon.pink { background: rgba(228,73,147,0.12); color: #e44993; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin: 0 0 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); font-weight: 400; margin: 0; }

/* ── PROCESS CARD ── */
.process-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 20px;
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.15s;
}
.process-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.process-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.process-name { font-size: 15px; font-weight: 700; color: var(--text); margin: 0 0 4px; }
.process-company { font-size: 12px; color: var(--text-muted); margin: 0; display: flex; align-items: center; gap: 4px; }
.process-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.badge-active { background: rgba(75,209,153,0.15); color: #1da57a; }
.badge-review { background: rgba(137,147,248,0.15); color: var(--primary); }
.badge-closed { background: rgba(50,56,67,0.1); color: var(--text-muted); }

.process-meta { display: flex; gap: 16px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
.process-meta-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.process-meta-item i { color: var(--primary); font-size: 12px; }

.process-progress { margin-top: 12px; }
.progress-bar { height: 4px; background: rgba(137,147,248,0.15); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 2px; background: var(--primary); transition: width 0.3s; }

/* ── GRID LAYOUTS ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-process { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }

/* ── BUTTONS ── */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: var(--radius); font-family: var(--font); font-weight: 600; cursor: pointer; transition: filter 0.12s, transform 0.06s; }
.btn:active { transform: translateY(1px); }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-md { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { filter: brightness(0.95); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-secondary { background: rgba(137,147,248,0.12); color: var(--primary); }
.btn-secondary:hover { background: rgba(137,147,248,0.2); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); background: var(--primary-light); }
.btn-danger { background: #fee2e2; color: #dc2626; }
.btn-danger:hover { background: #fecaca; }

/* ── FORM ELEMENTS ── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-label { font-size: 14px; font-weight: 600; color: var(--text); }
.form-input, .form-select, .form-textarea {
  border: 1px solid #c9ccde;
  border-radius: 6px;
  background: #fafbfc;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 0 14px;
  height: 46px;
  width: 100%;
  transition: border 0.2s, box-shadow 0.2s;
  color: var(--text);
  outline: none;
}
.form-textarea { height: auto; padding: 12px 14px; resize: vertical; min-height: 100px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(137,147,248,0.2);
  background: #fff;
}
.form-input::placeholder { color: #9ca3af; }
.form-select { appearance: none; }

/* ── TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  background: #f8f9ff;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border);
}
.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:hover td { background: #fafbff; }
.data-table tr:last-child td { border-bottom: none; }

/* ── KANBAN ── */
.kanban-board { display: flex; gap: 16px; overflow-x: auto; padding-bottom: 16px; align-items: flex-start; min-height: calc(100vh - 200px); }
.kanban-column {
  background: #f0f2ff;
  border-radius: var(--radius-lg);
  min-width: 280px;
  max-width: 280px;
  padding: 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 0 4px;
}
.kanban-col-name { font-size: 13px; font-weight: 700; color: var(--text); }
.kanban-col-count {
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 22px; height: 22px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.kanban-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.1s;
  border-left: 3px solid var(--primary);
}
.kanban-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,0.1); transform: translateY(-1px); }
.kanban-card-name { font-size: 14px; font-weight: 700; color: var(--text); margin: 0 0 6px; }
.kanban-card-info { font-size: 12px; color: var(--text-muted); display: flex; gap: 12px; align-items: center; }
.kanban-card-score {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.score-bar-wrap { flex: 1; height: 5px; background: var(--primary-light); border-radius: 3px; overflow: hidden; margin: 0 8px; }
.score-bar { height: 100%; background: var(--primary); border-radius: 3px; }
.score-label { font-size: 11px; font-weight: 700; color: var(--primary); }

/* ── TAGS / CHIPS ── */
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.tag-purple { background: rgba(137,147,248,0.12); color: var(--primary); }
.tag-green { background: rgba(75,209,153,0.12); color: #1da57a; }
.tag-pink { background: rgba(228,73,147,0.1); color: #c42b80; }
.tag-blue { background: rgba(9,134,192,0.1); color: #0769a0; }
.tag-gray { background: rgba(50,56,67,0.08); color: var(--text-muted); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 18px; font-weight: 700; color: var(--text); margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; padding: 4px; border-radius: 4px; }
.modal-close:hover { background: var(--primary-light); color: var(--primary); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 12px; justify-content: flex-end; }

/* ── EMPTY STATE ── */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state i { font-size: 48px; color: var(--primary-light); margin-bottom: 16px; display: block; }
.empty-state h3 { font-size: 18px; font-weight: 700; color: var(--text); margin: 0 0 8px; }
.empty-state p { font-size: 14px; color: var(--text-muted); margin: 0 0 24px; font-weight: 400; }

/* ── CHATBOX ── */
.chatbot-trigger {
  position: fixed;
  bottom: 24px; right: 24px;
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--primary-dark);
  color: #fff;
  border: none;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 4px 4px 20px rgba(50,56,67,0.25);
  z-index: 1000;
  transition: background 0.25s;
}
.chatbot-trigger:hover { background: var(--primary); }

.chatbox-panel {
  position: fixed;
  bottom: 86px; right: 24px;
  width: 360px;
  height: 500px;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
  display: flex; flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}
.chatbox-panel.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }
.chatbox-header {
  background: var(--primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chatbox-header h4 { margin: 0; font-size: 15px; font-weight: 700; }
.chatbox-body { flex: 1; overflow-y: auto; padding: 14px; background: #fafafa; display: flex; flex-direction: column; gap: 10px; }
.chat-msg { max-width: 85%; padding: 10px 14px; border-radius: 8px; font-size: 14px; line-height: 1.5; }
.chat-msg.bot { background: #e7eefa; color: var(--text); align-self: flex-start; }
.chat-msg.user { background: #f5c8e4; color: var(--text); align-self: flex-end; }
.chatbox-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center;
}
.chatbox-input {
  flex: 1; border: 1px solid var(--primary); border-radius: 20px;
  padding: 8px 14px; font-family: var(--font); font-size: 14px; outline: none;
}
.chatbox-send {
  background: var(--primary); color: #fff; border: none;
  border-radius: 6px; padding: 8px 16px; font-weight: 700; font-size: 13px;
  transition: background 0.2s;
}
.chatbox-send:hover { background: var(--primary-dark); }

/* ── LOADING SPINNER ── */
.spinner { display: flex; align-items: center; gap: 4px; }
.spinner span {
  width: 6px; height: 6px; border-radius: 50%; background: var(--primary);
  animation: bounce 1s ease-in-out infinite;
}
.spinner span:nth-child(2) { animation-delay: 0.15s; }
.spinner span:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ── TOGGLE ── */
.toggle {
  width: 44px; height: 24px;
  background: var(--border);
  border-radius: 12px;
  border: none;
  position: relative;
  cursor: pointer;
  transition: background 0.25s;
}
.toggle.on { background: var(--primary); }
.toggle::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  background: #fff;
  border-radius: 50%;
  top: 3px; left: 3px;
  transition: left 0.25s;
}
.toggle.on::after { left: 23px; }

/* ── BACKDROP (mobile sidebar overlay) ── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 100;
}
.sidebar-backdrop.show { display: block; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { left: -280px; width: 280px; z-index: 101; }
  .sidebar.open { left: 0; }
  .main-content, .main-content.mini { margin-left: 0; width: 100%; }
  .app-header, .app-header.shifted { margin-left: 0; width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .search-bar { display: none; }
  .kanban-board { padding: 0 16px 16px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .page { padding: 16px; }
}
