/* ===================================================
   REMI · Panel CSS
   Módulo [D] — panel.css
   Estética: negro #0A0A0A + verde #22C55E + blanco
   Tipografía: Space Grotesk (headings) + Inter (body)
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

/* ---- Reset & base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0A0A0A;
  --surface:   #141414;
  --surface2:  #1C1C1C;
  --border:    #2A2A2A;
  --green:     #22C55E;
  --green-dim: #16A34A;
  --green-bg:  #052E16;
  --text:      #F1F5F9;
  --text-2:    #94A3B8;
  --text-3:    #64748B;
  --white:     #FFFFFF;
  --danger:    #EF4444;
  --warn:      #F59E0B;
  --radius:    10px;
  --radius-lg: 16px;
  --chat-bg:   #0D1117;
  /* burbujas */
  --bubble-out: #22C55E;
  --bubble-out-text: #052E16;
  --bubble-in:  #1E2730;
  --bubble-in-text: #E2E8F0;
  /* sidebar width */
  --sidebar: 340px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

/* ---- App shell ---- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ---- Header ---- */
#header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

#header .logo-mark {
  width: 32px;
  height: 32px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

#header .title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 18px;
  font-weight: 700;
  color: var(--white);
}

#header .title span {
  color: var(--green);
}

#header .subtitle {
  font-size: 12px;
  color: var(--text-3);
  margin-left: 2px;
}

#header .spacer { flex: 1; }

#header .status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
}

#header .status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---- Main layout ---- */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ============================================
   COLUMNA IZQUIERDA: Chat simulador WhatsApp
   ============================================ */
#chat-col {
  width: 420px;
  min-width: 300px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
  border-right: 1px solid var(--border);
  position: relative;
}

/* Patrón de fondo tipo WhatsApp */
#chat-col::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image:
    radial-gradient(circle, #22C55E 1px, transparent 1px);
  background-size: 28px 28px;
  z-index: 0;
}

/* Header del chat */
#chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #111827;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

.chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--green), #0EA5E9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chat-contact-info { flex: 1; }
.chat-contact-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--white);
}
.chat-contact-status {
  font-size: 11px;
  color: var(--green);
}

/* ---- Mensajes ---- */
#messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  z-index: 1;
  scroll-behavior: smooth;
}

#messages::-webkit-scrollbar { width: 4px; }
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* Fecha separadora */
.msg-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--text-3);
  padding: 8px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg-date-sep::before, .msg-date-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.msg-date-sep span {
  background: #1a2332;
  padding: 2px 10px;
  border-radius: 8px;
  white-space: nowrap;
}

/* Burbujas */
.bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  gap: 2px;
  margin-bottom: 4px;
}

.bubble-wrap.out {
  align-self: flex-end;
  align-items: flex-end;
}

.bubble-wrap.in {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
  max-width: 100%;
}

.bubble-wrap.out .bubble {
  background: var(--bubble-out);
  color: var(--bubble-out-text);
  border-bottom-right-radius: 4px;
  font-weight: 500;
}

.bubble-wrap.in .bubble {
  background: var(--bubble-in);
  color: var(--bubble-in-text);
  border-bottom-left-radius: 4px;
}

.bubble-time {
  font-size: 10px;
  color: var(--text-3);
  padding: 0 4px;
}

.bubble-wrap.out .bubble-time {
  color: rgba(5, 46, 22, 0.65);
  padding: 0 4px;
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-size: 9px;
}

/* Tiempo dentro de burbuja saliente */
.bubble-wrap.out .bubble {
  padding-bottom: 18px;
}

/* Indicador "escribiendo..." */
#typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 4px 0;
}

#typing-indicator.visible {
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-bubble {
  background: var(--bubble-in);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-2);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Input de chat ---- */
#chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  background: #111827;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}

#chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 22px;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  overflow-y: auto;
  line-height: 1.4;
}

#chat-input::placeholder { color: var(--text-3); }

#chat-input:focus {
  border-color: var(--green);
}

#send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.1s;
}

#send-btn:hover { background: var(--green-dim); }
#send-btn:active { transform: scale(0.94); }

#send-btn svg {
  width: 18px;
  height: 18px;
  fill: #052E16;
}

/* Sugerencias de chat */
#chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 0;
}

.suggestion-chip {
  font-size: 12px;
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text-2);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.suggestion-chip:hover {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-bg);
}

/* ============================================
   COLUMNA DERECHA: Panel de tabs
   ============================================ */
#panel-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

/* ---- Tabs nav ---- */
#tabs-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
#tabs-nav::-webkit-scrollbar { display: none; }

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-3);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}

.tab-btn .tab-icon { font-size: 15px; }

.tab-btn:hover {
  color: var(--text-2);
  background: var(--surface2);
}

.tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--green);
  background: var(--surface2);
}

/* Badge para conteo */
.tab-badge {
  background: var(--green);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}

/* ---- Tab content ---- */
#tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

#tab-content::-webkit-scrollbar { width: 5px; }
#tab-content::-webkit-scrollbar-track { background: transparent; }
#tab-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Section headings ---- */
.section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: var(--white);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green);
  font-family: 'Inter', sans-serif;
}

/* ---- Estado vacío ---- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-3);
  gap: 12px;
  min-height: 180px;
}

.empty-state .empty-icon { font-size: 40px; opacity: 0.5; }

.empty-state .empty-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}

.empty-state .empty-hint {
  font-size: 13px;
  color: var(--text-3);
  max-width: 260px;
  line-height: 1.6;
}

.empty-state .empty-example {
  font-size: 12px;
  color: var(--green);
  background: var(--green-bg);
  padding: 6px 12px;
  border-radius: 8px;
  font-style: italic;
  cursor: pointer;
  border: 1px solid #134e2a;
  transition: background 0.15s;
}
.empty-state .empty-example:hover { background: #0a3a1e; }

/* ---- Tarjetas genéricas ---- */
.card-list { display: flex; flex-direction: column; gap: 8px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: border-color 0.2s;
}

.card:hover { border-color: #3a3a3a; }

.card.done-card { opacity: 0.5; }

.card-body { flex: 1; min-width: 0; }

.card-text {
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.card.done-card .card-text {
  text-decoration: line-through;
  color: var(--text-3);
}

.card-meta {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-meta .due-time {
  color: var(--green);
  font-weight: 500;
}

.card-meta .due-soon { color: var(--warn); }
.card-meta .due-past { color: var(--danger); }

.card-meta .rrule-badge {
  font-size: 10px;
  background: #1e1b4b;
  color: #a5b4fc;
  padding: 1px 6px;
  border-radius: 6px;
}

/* ---- Botones de acción en tarjeta ---- */
.card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.action-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-3);
  transition: all 0.15s;
}

.action-btn:hover { background: var(--surface2); color: var(--text); }
.action-btn.done-btn:hover { color: var(--green); }
.action-btn.del-btn:hover { color: var(--danger); }

/* ---- TAB HOY ---- */
.digest-box {
  background: linear-gradient(135deg, #052E16, #0D1117);
  border: 1px solid #166534;
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  font-size: 14px;
  line-height: 1.7;
  color: #BBF7D0;
  white-space: pre-wrap;
  font-family: 'Inter', sans-serif;
}

.digest-box .digest-header {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--green);
  font-size: 15px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- TAB RECORDATORIOS ---- */
.reminder-icon { font-size: 18px; }

/* ---- TAB LISTAS ---- */
.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
}

.list-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.list-card-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: var(--white);
  flex: 1;
}

.list-items { padding: 8px 14px; }

.list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid #1a1a1a;
}

.list-item:last-child { border-bottom: none; }

.list-checkbox {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s;
  font-size: 11px;
  color: var(--bg);
}

.list-checkbox.checked {
  background: var(--green);
  border-color: var(--green);
}

.list-item-text {
  font-size: 13px;
  color: var(--text);
  flex: 1;
}

.list-item.done-item .list-item-text {
  text-decoration: line-through;
  color: var(--text-3);
}

.list-item-del {
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: all 0.15s;
}
.list-item-del:hover { color: var(--danger); background: #1f1010; }

.list-add-row {
  display: flex;
  gap: 6px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: #0e1117;
}

.list-add-input {
  flex: 1;
  height: 32px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.2s;
}
.list-add-input:focus { border-color: var(--green); }
.list-add-input::placeholder { color: var(--text-3); }

.list-add-btn {
  height: 32px;
  padding: 0 12px;
  background: var(--green);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.list-add-btn:hover { background: var(--green-dim); }

/* ---- TAB NOTAS ---- */
.note-card .note-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.note-tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 6px;
  background: #1e293b;
  color: #7DD3FC;
}

/* ---- TAB GASTOS ---- */
.expenses-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 18px;
}

.summary-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  color: var(--text-3);
  margin-bottom: 4px;
}

.summary-total {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 12px;
}

.summary-total span { color: var(--green); font-size: 16px; }

.summary-cats { display: flex; flex-direction: column; gap: 6px; }

.cat-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cat-name { font-size: 13px; color: var(--text-2); min-width: 80px; }

.cat-bar-wrap {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.cat-bar {
  height: 100%;
  background: var(--green);
  border-radius: 3px;
  transition: width 0.6s ease;
}

.cat-amount { font-size: 12px; color: var(--text-3); min-width: 50px; text-align: right; }

/* ---- TAB AJUSTES ---- */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.settings-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.settings-label { font-size: 14px; color: var(--text); }
.settings-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.settings-input {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 6px 10px;
  outline: none;
  min-width: 0;
  width: 140px;
  transition: border-color 0.2s;
}
.settings-input:focus { border-color: var(--green); }

.settings-select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  padding: 6px 10px;
  outline: none;
  cursor: pointer;
}

.settings-save-btn {
  margin-top: 16px;
  padding: 10px 24px;
  background: var(--green);
  color: var(--bg);
  font-family: 'Space Grotesk', sans-serif;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}
.settings-save-btn:hover { background: var(--green-dim); }

.plan-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--green-bg);
  color: var(--green);
  border: 1px solid #166534;
}

/* ---- Toast / notificaciones ---- */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  animation: toast-in 0.25s ease;
  max-width: 300px;
  pointer-events: auto;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid #60A5FA; }

@keyframes toast-in {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@keyframes toast-out {
  to { transform: translateX(30px); opacity: 0; }
}

/* ---- Spinner carga ---- */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Recordatorio entrante: notificación en chat ---- */
.reminder-alert {
  align-self: stretch;
  background: linear-gradient(90deg, #052E16, #0D1117);
  border: 1px solid #166534;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slide-in 0.3s ease;
}

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

/* ============================================
   RESPONSIVE: móvil (< 768px)
   ============================================ */
@media (max-width: 767px) {
  html, body { overflow: auto; }

  #app { height: auto; min-height: 100vh; overflow: auto; }

  #main {
    flex-direction: column;
    overflow: visible;
    height: auto;
  }

  #chat-col {
    width: 100%;
    min-width: 0;
    border-right: none;
    border-bottom: 1px solid var(--border);
    height: 60vh;
    flex-shrink: 0;
  }

  #panel-col {
    height: auto;
    overflow: visible;
  }

  #tab-content {
    overflow: visible;
    max-height: none;
  }

  #tabs-nav { overflow-x: auto; }

  .tab-btn { padding: 12px 12px; }

  #header .subtitle { display: none; }

  #toast-container { bottom: 12px; right: 12px; left: 12px; }
  .toast { max-width: 100%; }
}

@media (max-width: 480px) {
  #chat-col { height: 55vh; }
  #tab-content { padding: 14px; }
  .summary-total { font-size: 22px; }
}
