/* ============================================================
   CRM Estética Natural — Estilos
   ============================================================ */

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

:root {
  --sage:        #7a9e7e;
  --sage-light:  #e8f0e9;
  --sage-mid:    #b5cdb8;
  --nude:        #e8d5c4;
  --nude-light:  #f7f0ea;
  --nude-dark:   #c4a98a;
  --cream:       #faf7f4;
  --rose:        #d4a0a0;
  --rose-light:  #f5e8e8;
  --text:        #3a3530;
  --text-muted:  #8a7f78;
  --border:      rgba(58,53,48,0.1);
  --sidebar-w:   210px;
  --topbar-h:    52px;
}

body {
  font-family: 'Lato', 'Georgia', sans-serif;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
}

/* === LAYOUT === */
.app { display: flex; height: 100vh; overflow: hidden; }

/* === SIDEBAR === */
.sidebar {
  width: var(--sidebar-w);
  background: #2c2825;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}
.sidebar-brand {
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--sage);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  margin-bottom: 8px;
}
.brand-name  { font-size: 12px; font-weight: 600; color: #fff; line-height: 1.3; }
.brand-loc   { font-size: 10px; color: rgba(255,255,255,0.4); margin-top: 2px; }

.sidebar-search { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sidebar-search input {
  width: 100%; background: rgba(255,255,255,0.08); border: none;
  border-radius: 6px; padding: 6px 10px; color: #fff; font-size: 11px; outline: none;
}
.sidebar-search input::placeholder { color: rgba(255,255,255,0.3); }

.nav-items { flex: 1; padding: 8px 0; }
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 16px; font-size: 12px;
  color: rgba(255,255,255,0.5);
  cursor: pointer; transition: all 0.15s;
  border-left: 2px solid transparent;
  user-select: none;
}
.nav-item:hover { color: rgba(255,255,255,0.85); background: rgba(255,255,255,0.04); }
.nav-item.active { color: #fff; background: rgba(122,158,126,0.2); border-left-color: var(--sage); }
.nav-item i { font-size: 15px; width: 18px; }
.nav-item .badge {
  margin-left: auto; background: var(--sage); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px; font-weight: 600;
}

.sidebar-footer { padding: 10px 12px; border-top: 1px solid rgba(255,255,255,0.07); }

/* === MAIN === */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  background: #fff; border-bottom: 1px solid var(--border);
  padding: 0 20px; height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.topbar-title { font-size: 16px; font-weight: 600; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.content { flex: 1; overflow-y: auto; padding: 20px; }

.section { display: none; }
.section.active { display: block; }

/* === BUTTONS === */
.btn-primary {
  background: var(--sage); color: #fff; border: none;
  padding: 7px 14px; border-radius: 7px; font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; transition: background 0.15s;
}
.btn-primary:hover { background: #6a8e6e; }
.btn-outline {
  background: transparent; color: var(--text-muted);
  border: 1px solid var(--border); padding: 6px 12px;
  border-radius: 7px; font-size: 12px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit; transition: background 0.15s;
}
.btn-outline:hover { background: var(--sage-light); }
.btn-danger {
  background: #e74c3c; color: #fff; border: none;
  padding: 6px 12px; border-radius: 7px; font-size: 12px;
  cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  font-family: inherit;
}
.icon-btn {
  background: none; border: none; cursor: pointer; font-size: 14px;
  color: var(--text-muted); padding: 4px; border-radius: 4px;
  display: inline-flex; align-items: center;
}
.icon-btn:hover { color: var(--sage); background: var(--sage-light); }

/* === CARDS === */
.card {
  background: #fff; border-radius: 10px;
  border: 1px solid var(--border); padding: 16px;
}
.card-title { font-size: 13px; font-weight: 600; margin-bottom: 14px; }

/* === METRICS === */
.metrics-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.metric-card {
  background: #fff; border-radius: 10px; border: 1px solid var(--border);
  padding: 14px 16px; position: relative;
}
.metric-icon { position: absolute; top: 14px; right: 14px; font-size: 20px; color: var(--sage-mid); }
.metric-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.metric-value { font-size: 22px; font-weight: 600; }
.metric-sub   { font-size: 11px; color: var(--sage); margin-top: 3px; }

/* === STATUS PILLS === */
.pill {
  font-size: 10px; padding: 2px 8px; border-radius: 20px; font-weight: 600;
  display: inline-block;
}
.pill.activa   { background: var(--sage-light); color: var(--sage); }
.pill.nueva    { background: var(--nude-light);  color: var(--nude-dark); }
.pill.inactiva { background: #f0f0f0; color: #999; }
.pill.cobrado  { background: var(--sage-light); color: var(--sage); }
.pill.pendiente{ background: var(--nude-light);  color: var(--nude-dark); }
.pill.cancelado{ background: #fef0f0; color: #e74c3c; }
.pill.confirmada { background: var(--sage-light); color: var(--sage); }
.pill.completada { background: #e8f4fd; color: #2980b9; }
.pill.no_presentada { background: #fef0f0; color: #e74c3c; }

/* === AVATAR === */
.av {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--sage-light); display: flex; align-items: center;
  justify-content: center; font-size: 10px; font-weight: 700;
  color: var(--sage); flex-shrink: 0;
}
.av.rose { background: var(--rose-light); color: var(--rose); }
.av.nude { background: var(--nude-light); color: var(--nude-dark); }

/* === MINI BAR === */
.mini-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mini-bar-label { width: 110px; font-size: 11px; color: var(--text-muted); }
.mini-bar-track { flex: 1; height: 6px; background: var(--sage-light); border-radius: 3px; overflow: hidden; }
.mini-bar-fill  { height: 100%; background: var(--sage); border-radius: 3px; }
.mini-bar-fill.nude { background: var(--nude-dark); }
.mini-bar-fill.rose { background: var(--rose); }
.mini-bar-val { width: 38px; text-align: right; font-size: 11px; }

/* === KANBAN === */
.kanban-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.kanban-bar select {
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 10px;
  font-size: 12px; background: #fff; color: var(--text); font-family: inherit;
}
.badge-count { background: var(--sage-light); color: var(--sage); font-size: 11px; padding: 4px 10px; border-radius: 20px; font-weight: 600; }
.kanban-scroll { overflow-x: auto; padding-bottom: 8px; }
.kanban-cols   { display: flex; gap: 12px; min-width: max-content; }
.kanban-col    { width: 220px; flex-shrink: 0; }
.col-header {
  background: #fff; border: 1px solid var(--border);
  border-bottom: 2px solid var(--sage);
  border-radius: 8px 8px 0 0; padding: 10px 12px;
  font-size: 11px; font-weight: 600; margin-bottom: 8px;
}
.col-header.nude { border-bottom-color: var(--nude-dark); }
.col-header.rose { border-bottom-color: var(--rose); }
.col-header.gray { border-bottom-color: #bbb; }
.col-header.green{ border-bottom-color: #27ae60; }
.col-meta { font-size: 10px; color: var(--text-muted); font-weight: 400; margin-top: 2px; }
.opp-card {
  background: #fff; border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 8px; cursor: pointer; transition: box-shadow 0.15s;
}
.opp-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.07); }
.opp-header { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.opp-av { width: 22px; height: 22px; border-radius: 50%; background: var(--sage-light); display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; color: var(--sage); }
.opp-name { font-size: 12px; font-weight: 600; flex: 1; }
.opp-tag  { width: 22px; height: 22px; border-radius: 50%; background: #2c2825; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: #fff; }
.opp-field { font-size: 10px; color: var(--text-muted); margin-bottom: 2px; }
.opp-field span { color: var(--text); }
.opp-actions { display: flex; gap: 4px; margin-top: 8px; }
.opp-btn {
  width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--border);
  background: transparent; display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer; color: var(--text-muted);
}
.opp-btn:hover { background: var(--sage-light); color: var(--sage); border-color: var(--sage-mid); }

/* === TABLA CONTACTOS === */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; }
.toolbar input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; background: #fff; font-family: inherit;
}
.data-table { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; width: 100%; }
.dt-head {
  display: grid; padding: 10px 16px;
  background: var(--sage-light); font-size: 11px;
  font-weight: 600; color: var(--sage); letter-spacing: 0.4px;
}
.dt-row {
  display: grid; padding: 11px 16px;
  border-top: 1px solid var(--border); align-items: center; font-size: 12px;
}
.dt-row:hover { background: var(--nude-light); }
.dt-name { display: flex; align-items: center; gap: 8px; }

/* === CALENDARIO === */
.cal-grid { display: grid; grid-template-columns: 1.1fr 1fr; gap: 16px; }
.cal-month-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { border: 1px solid var(--border); background: #fff; border-radius: 6px; width: 28px; height: 28px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cal-days-header { display: grid; grid-template-columns: repeat(7,1fr); text-align: center; font-size: 10px; color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.cal-days { display: grid; grid-template-columns: repeat(7,1fr); gap: 3px; }
.cal-day { text-align: center; font-size: 12px; padding: 6px 2px; border-radius: 6px; cursor: pointer; color: var(--text-muted); position: relative; }
.cal-day:hover { background: var(--sage-light); }
.cal-day.today { background: var(--sage); color: #fff; font-weight: 600; }
.cal-day.has-event { color: var(--text); font-weight: 600; }
.cal-day.has-event::after { content: ''; position: absolute; bottom: 2px; left: 50%; transform: translateX(-50%); width: 4px; height: 4px; border-radius: 50%; background: var(--sage); }
.cal-day.other { color: rgba(58,53,48,0.2); }
.agenda-item { display: flex; gap: 10px; padding: 9px 12px; background: #fff; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; border-left: 3px solid var(--sage); }
.agenda-item.rose { border-left-color: var(--rose); }
.agenda-item.nude { border-left-color: var(--nude-dark); }
.agenda-time { font-size: 11px; color: var(--text-muted); width: 38px; flex-shrink: 0; margin-top: 1px; }
.a-name { font-size: 12px; font-weight: 600; }
.a-serv { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* === CONVERSACIONES === */
.conv-layout { display: grid; grid-template-columns: 230px 1fr; height: 540px; background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.conv-list { border-right: 1px solid var(--border); overflow-y: auto; }
.conv-item { padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 12px; }
.conv-item:hover { background: var(--nude-light); }
.conv-item.active { background: var(--sage-light); }
.conv-cn   { font-weight: 600; }
.conv-prev { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 10px; color: var(--text-muted); float: right; }
.conv-chat { display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; font-weight: 600; flex-shrink: 0; }
.chat-messages { flex: 1; padding: 14px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 72%; font-size: 12px; padding: 8px 12px; border-radius: 10px; line-height: 1.5; }
.msg.in  { background: var(--sage-light); color: var(--text); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg.out { background: var(--sage);       color: #fff;        align-self: flex-end;  border-bottom-right-radius: 2px; }
.msg-time { font-size: 10px; opacity: 0.6; margin-top: 3px; }
.chat-input { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-shrink: 0; }
.chat-input input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12px; font-family: inherit; }

/* === MODAL === */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: #fff; border-radius: 12px; padding: 24px;
  width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-size: 15px; font-weight: 600; margin-bottom: 18px; }
.form-group { margin-bottom: 14px; }
.form-group label { font-size: 11px; color: var(--text-muted); font-weight: 600; display: block; margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 13px; font-family: inherit;
  background: #fff; color: var(--text); outline: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--sage); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* === TOAST === */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #2c2825; color: #fff; padding: 12px 18px;
  border-radius: 8px; font-size: 13px; z-index: 2000;
  display: flex; align-items: center; gap: 8px;
  animation: fadeInUp 0.3s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.toast.success { background: var(--sage); }
.toast.error   { background: #e74c3c; }
.toast.hidden  { display: none; }
@keyframes fadeInUp { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

/* === LOADING === */
.loading { text-align: center; padding: 40px; color: var(--text-muted); font-size: 13px; }
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid var(--sage-light); border-top-color: var(--sage); border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* === RESPONSIVO === */
@media (max-width: 900px) {
  .metrics-row { grid-template-columns: repeat(2,1fr); }
  .cal-grid    { grid-template-columns: 1fr; }
  .inf-grid    { grid-template-columns: 1fr; }
}
