/* ═══════════════════════════════════════════
   APP CONSOLE (Post-Login)
   Fintech Light Theme Adaptation
═══════════════════════════════════════════════ */

#app-console {
  display: none;
  height: 100vh;
  width: 100vw;
  background: var(--bg-alt); /* Light gray background */
  color: var(--text-main);
  overflow: hidden;
  display: flex;
}

/* ── SIDEBAR (Dark Navy for contrast) ── */
.app-sidebar {
  width: 280px;
  background: var(--bg-deep); /* Navy */
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.5rem 0;
  margin-bottom: 1.5rem;
}

.sidebar-logo {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 1.5rem;
  color: white;
}
.sidebar-logo span {
  color: var(--secondary); /* Teal accent */
}

.sidebar-scrollable {
  flex: 1;
  overflow-y: auto;
  padding: 0 1.5rem;
}

.nav-section-title {
  font-size: 0.75rem;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 1.5rem 0 0.8rem;
  font-weight: 700;
}

.nav-item {
  padding: 0.8rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  color: #CBD5E1;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  transition: all 0.2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

/* Sidebar Bottom (Usage & Profile) */
.sidebar-bottom {
  padding: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.2);
}

.usage-container {
  margin-bottom: 1rem;
}

.usage-text {
  font-size: 0.8rem;
  color: #94A3B8;
  margin-bottom: 0.4rem;
  display: flex;
  justify-content: space-between;
}

.usage-bar-bg {
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.8rem;
}

.usage-bar-fill {
  height: 100%;
  background: var(--secondary);
  transition: width 0.3s;
}

.btn-upgrade-sidebar {
  width: 100%;
  background: rgba(0, 209, 178, 0.15); /* Teal tint */
  color: var(--secondary);
  border: 1px solid rgba(0, 209, 178, 0.3);
  padding: 0.6rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-upgrade-sidebar:hover {
  background: var(--secondary);
  color: white;
}

/* ── HISTORIAL DE CONVERSACIONES ── */
.history-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.history-refresh-btn {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.history-refresh-btn:hover {
  color: white;
  background: rgba(255,255,255,0.06);
}

.btn-new-conv {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.6rem;
  background: rgba(0, 209, 178, 0.12);
  color: var(--secondary);
  border: 1px dashed rgba(0, 209, 178, 0.35);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-new-conv:hover {
  background: rgba(0, 209, 178, 0.22);
  border-style: solid;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 280px;
  overflow-y: auto;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}

.history-empty {
  font-size: 0.78rem;
  color: #94A3B8;
  padding: 0.5rem 0.3rem;
  font-style: italic;
}

.history-item {
  display: flex;
  align-items: stretch;
  border-radius: 7px;
  overflow: hidden;
  transition: background 0.15s;
}
.history-item:hover {
  background: rgba(255,255,255,0.05);
}
.history-item.active {
  background: rgba(37, 99, 235, 0.25);
  border-left: 3px solid var(--primary, #2563EB);
}
.history-item.loading {
  opacity: 0.5;
}

.history-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  background: transparent;
  border: none;
  color: #CBD5E1;
  text-align: left;
  cursor: pointer;
  font: inherit;
}
.history-item-main:hover { color: white; }

.history-item-title {
  font-size: 0.82rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  width: 100%;
  line-height: 1.2;
}
.history-item-date {
  font-size: 0.68rem;
  color: #94A3B8;
}

.history-item-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding-right: 0.3rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.history-item:hover .history-item-actions,
.history-item.active .history-item-actions {
  opacity: 1;
}

.history-action-btn {
  background: transparent;
  border: none;
  color: #94A3B8;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.15rem 0.35rem;
  border-radius: 4px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.history-action-btn:hover {
  color: white;
  background: rgba(255,255,255,0.08);
}
.history-action-btn.danger:hover {
  color: #FCA5A5;
  background: rgba(239, 68, 68, 0.15);
}

.user-profile-strip {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 8px;
  transition: background 0.2s;
}

.user-profile-strip:hover {
  background: rgba(255,255,255,0.05);
}

.avatar-mini {
  width: 35px;
  height: 35px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
  color: white;
}

/* ── MAIN WORKSPACE ── */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  background: var(--bg-alt); /* Light gray */
}

/* ── CHAT CONTAINER ── */
.chat-container {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 15%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  scroll-behavior: smooth;
}

.chat-message {
  display: flex;
  gap: 1rem;
  max-width: 85%;
  animation: fadeIn 0.3s ease-out forwards;
}

.chat-message.msg-bot {
  align-self: flex-start;
}

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

.msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.msg-bot .msg-avatar {
  background: white;
  border: 1px solid #E2E8F0;
  box-shadow: var(--shadow-sm);
}

.msg-user .msg-avatar {
  background: var(--primary);
  color: white;
}

.msg-content {
  padding: 1.2rem;
  border-radius: 12px;
  line-height: 1.6;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

.msg-bot .msg-content {
  background: white;
  border: 1px solid #E2E8F0;
  color: var(--text-main);
  border-top-left-radius: 2px;
}

.msg-user .msg-content {
  background: var(--primary);
  color: white;
  border-top-right-radius: 2px;
}

/* ── INPUT AREA ── */
.input-area-wrapper {
  padding: 1.5rem 15%;
  background: var(--bg-alt);
  border-top: 1px solid #E2E8F0;
}

.chat-input-box {
  background: white;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 0.5rem;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow-md);
  transition: border-color 0.3s;
}
.chat-input-box:focus-within {
  border-color: var(--primary);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  padding: 0.8rem;
  font-family: var(--font-body);
  font-size: 1rem;
  resize: none;
  max-height: 150px;
  outline: none;
}
#chat-input::placeholder {
  color: #94A3B8;
}

.btn-send {
  background: var(--primary);
  color: white;
  width: 45px;
  height: 45px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  margin-bottom: 0.2rem;
  margin-right: 0.2rem;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(37,99,235,0.2);
}
.btn-send:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
}

/* ── SMART CARD PANEL ── */
.smart-card-panel {
  position: absolute;
  top: 0; right: -450px;
  width: 400px;
  height: 100%;
  background: white;
  border-left: 1px solid #E2E8F0;
  box-shadow: -10px 0 30px rgba(0,0,0,0.05);
  transition: right 0.3s ease;
  z-index: 50;
  overflow-y: auto;
}

.smart-card-panel.open {
  right: 0;
}

.sc-header {
  padding: 1.5rem;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #F8FAFC;
}

.sc-header h3 {
  font-size: 1.2rem;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sc-close {
  background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
}

.sc-body {
  padding: 1.5rem;
}

/* Forms in Smart Cards */
.sc-form-group {
  margin-bottom: 1.2rem;
}
.sc-form-group label {
  display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.5rem; font-weight: 500;
}
.sc-form-group input, .sc-form-group select {
  width: 100%; padding: 0.8rem; background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 8px; color: var(--text-main); font-family: var(--font-body);
}

/* ── MOBILE RESPONSIVENESS ── */
.mobile-header {
  display: none;
  padding: 1rem 1.5rem;
  background: var(--bg-deep); /* Navy */
  color: white;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}

.mobile-menu-btn {
  background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer;
}

.sidebar-close-btn { display: none; }

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar-close-btn { display: block; }
  
  .app-sidebar {
    position: absolute;
    top: 0; bottom: 0; left: -100%;
    width: 85%;
    max-width: 320px;
    transition: left 0.3s ease;
    box-shadow: 10px 0 30px rgba(0,0,0,0.8);
  }
  .app-sidebar.open { left: 0; }
  
  .smart-card-panel {
    width: 100%;
    right: -100%;
  }
  
  .chat-input-box {
    margin: 0;
    width: 100%;
  }
  .input-area-wrapper {
    padding: 1rem;
  }
  .chat-container {
    padding: 1rem;
  }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
