@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@300;400;500;600&display=swap");

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "IBM Plex Sans", sans-serif;
}

:root {
  /* Dark mode colors */
  --text-color: #FFFFFF;
  --text-secondary: #b5b5b5;
  --subheading-color: #fff;
  --placeholder-color: #b5b5b5;
  --placeholder-secundary-color: #2a2d3d;
  --primary-color: #0a051a;
  --secondary-color: #171923cc;
  --secondary-hover-color: #171923;
  --brand-color: #98C105; /* Monom Corporate Green */
  --user-bubble-background: rgba(152, 193, 5, 0.15); /* Light green for User bubble in dark mode */
  --background-table-odd: #212330;
  --background-table-even: #2a2d3d;
  --table-header-background: #12141c; /* NEW: Darker header for tables */
  --error: #d0345c;
  --feedback-positive-color: #38a169; /* Verde para feedback positivo */
  --input-wrapper-background: #171923;
  --feedback-negative-color: #e53e3e; /* Rojo para feedback negativo */
}

.light_mode {
  /* Light mode colors */
  --text-color: #000000;
  --text-secondary: #6c6c6c;
  --subheading-color: #fff;
  --placeholder-color: #6c6c6c;
  --placeholder-secundary-color: #dbdbdb;
  --primary-color: #fff;
  --secondary-color: #f2f2f2;
  --secondary-hover-color: #fafafa;
  --brand-color: #83A604; /* Darker Monom Green for high contrast in light mode */
  --user-bubble-background: rgba(131, 166, 4, 0.12); /* Light green for User bubble in light mode */
  --background-table-odd: #ededed;
  --background-table-even: #dbdbdb;
  --table-header-background: #d0d1d3; /* NEW: Darker header for tables */
  --error: #d0345c;
  --feedback-positive-color: #48bb78; /* Verde mÃ¡s brillante para modo claro */
  --input-wrapper-background: #f2f2f2;
  --feedback-negative-color: #f56565; /* Rojo mÃ¡s brillante para modo claro */
}




/* --- NEW LAYOUT STYLES --- */
body {
  background: var(--primary-color);
  min-height: 100vh;
  overflow: hidden; /* El scroll se gestiona en los hijos */
}

/* NEW: Embedded mode styles - Hide project selector globally */
body.embedded-mode .sidebar-header,
body.embedded-mode #collapsed-project-icon-wrapper,
body.embedded-mode .top-right-actions {
  display: none !important;
}

/* NEW: Overlay for mobile sidebar */
.sidebar-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999; /* Below sidebar, above content */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* NEW: Top right actions */
.top-right-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.top-right-actions .icon {
  color: var(--text-color);
  cursor: pointer;
  font-size: 1.5rem;
  border: none; /* Remove border from settings icon */
  background: transparent; /* Ensure no background box */
}

.user-initials {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--brand-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
}

.sidebar {
  width: 260px;
  background-color: var(--secondary-color);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--placeholder-secundary-color);
  transition: width 0.3s ease;
  flex-shrink: 0;
  z-index: 1000; /* Increased to ensure it stays above main content context */
  /* overflow: hidden; <-- REMOVED: This was hiding the project dropdown */
}

.sidebar-top {
  display: flex; /* Changed to flex */
  flex-direction: column; /* Stack logo and button */
  align-items: flex-start;
  padding: 1rem;
  text-align: center; /* Center the logo */
  flex-shrink: 0;
  gap: 1rem; /* Space between logo and button */
}

.sidebar-logo {
  font-family: 'IBM Plex Sans', sans-serif; /* Or a more specific font if you have one */
  font-weight: 300; /* Thin font */
  font-size: 1.8rem;
  color: var(--text-color);
  letter-spacing: 0.3em; /* Spaced out letters */
  margin: 0;
  width: 100%; /* Make it span the full width */
}

.sidebar-logo-collapsed {
  display: none; /* Hide by default */
  font-family: 'IBM Plex Sans', sans-serif;
  font-weight: 300;
  font-size: 1.8rem;
  color: var(--text-color);
  margin: 0;
  width: 100%;
  text-align: center;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between; /* This will push the expand icon to the right */
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--placeholder-secundary-color);
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: background-color 0.2s ease;
  /* NEW: Rounded purple border like the image */
  border: 1px solid var(--brand-color);
  border-radius: 8px;
  margin: 0 1rem; /* Add horizontal margin */
}
.sidebar-header:hover, .sidebar-item:hover {
  background-color: var(--secondary-hover-color);
}

.project-selector-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  white-space: nowrap;
  flex-grow: 1; /* Allow it to take up space */
  overflow: hidden; /* Prevent content from overflowing */
}

.project-selector-wrapper:hover {
  background-color: var(--secondary-hover-color);
}

.project-selector-wrapper .expand-icon {
  margin-left: auto;
  transition: transform 0.3s ease;
}

.sidebar-header.open .expand-icon {
  transform: rotate(180deg);
}

.project-dropdown {
  display: none; /* Hidden by default */
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  background-color: var(--secondary-hover-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 1001; /* Above sidebar overlay (999) and sidebar (1000) */
  max-height: 300px;
  overflow-y: auto;
}

.project-dropdown-item {
  padding: 0.8rem 1.5rem;
  color: var(--text-color);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-dropdown-item:hover {
  background-color: var(--brand-color);
}

.project-initial {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--brand-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  flex-shrink: 0;
}

.project-name-sidebar {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-color);
  margin: 0;
}

/* --- NEW: Agent Selector Styles --- */
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  color: var(--text-color);
  font-weight: 500;
}

.sidebar-item.active {
  color: var(--brand-color);
  font-weight: 600;
}

/* NEW: Fill the star icon when the favorites filter is active */
.sidebar-item.active#starred-conversations-btn .material-symbols-rounded {
  font-variation-settings: 'FILL' 1;
  color: var(--brand-color);
}

.sidebar-item .material-symbols-rounded {
  color: var(--placeholder-color);
}

/* NEW: Style for custom SVG icons inside sidebar items */
.sidebar-item .icon-svg {
    width: 24px; /* Match Material Symbols size */
    height: 24px;
    /* En modo oscuro, el SVG ya es blanco (fill="white"), asÃ­ que no se necesita filtro. */
    filter: none;
}

.light_mode .sidebar-item .icon-svg {
    /* En modo claro, el SVG (que es blanco) necesita ser invertido a negro. */
    filter: invert(100%); /* Convierte blanco a negro */
}

.agent-dropdown {
  /* Reuses .project-dropdown styles */
  /* This is just a placeholder if you need specific overrides */
}

.agent-selector-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 2400; /* Below agent editor, above everything else */
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.agent-selector-overlay.show {
  display: flex;
}

/* --- AGENT SELECTOR MODAL --- */
.agent-selector-modal {
  background: var(--primary-color);
  width: 90%;
  max-width: 900px;
  max-height: 85vh;
  border-radius: 1.5rem;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  animation: modalSlideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.agent-selector-header {
  padding: 1.25rem 2rem;
  border-bottom: 1px solid var(--secondary-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  gap: 1.5rem;
}

.agent-selector-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-color);
  margin: 0;
  flex-grow: 1;
}

.agent-selector-header .icon-button {
  color: var(--text-color);
  transition: transform 0.2s ease;
}

.agent-selector-header .icon-button:hover {
  background-color: var(--secondary-hover-color);
  transform: scale(1.1);
}

.agent-selector-header #back-to-selector-btn {
    margin-right: 0.5rem;
}

.agent-selector-header #back-to-list-btn {
    margin-right: 0.5rem;
}

.agent-search-container {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

.agent-search-container .material-symbols-rounded {
  position: absolute;
  left: 1rem;
  color: var(--placeholder-color);
  pointer-events: none;
  font-size: 1.25rem;
}

#agent-search-input {
  width: 100% !important;
  padding: 0.75rem 1rem 0.75rem 3rem !important;
  border-radius: 2rem !important;
  border: 1px solid var(--secondary-color) !important;
  background: var(--secondary-color) !important;
  color: var(--text-color) !important;
  font-size: 1rem !important;
  transition: all 0.2s !important;
  outline: none !important;
}

#agent-search-input:focus {
  background: var(--primary-color) !important;
  border-color: var(--brand-color) !important;
  box-shadow: 0 0 0 3px rgba(152, 193, 5, 0.15) !important;
}

.agent-card-container {
  padding: 1rem 2rem 2rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* Custom Scrollbar for cards */
.agent-card-container::-webkit-scrollbar {
  width: 6px;
}
.agent-card-container::-webkit-scrollbar-thumb {
  background: var(--secondary-color);
  border-radius: 10px;
}

.agent-category-title {
  grid-column: 1 / -1;
  margin: 1.5rem 0 0.75rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1rem;
  color: var(--placeholder-color);
  font-weight: 700;
}

.agent-card {
  background: var(--input-wrapper-background);
  border: 1px solid var(--secondary-color);
  border-radius: 1.25rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
}

.agent-card:hover {
  transform: translateY(-5px);
  background: var(--secondary-hover-color);
  border-color: var(--brand-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.agent-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brand-color);
  opacity: 0;
  transition: opacity 0.2s;
}

.agent-card:hover::before {
  opacity: 1;
}

.agent-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 1rem;
  background: var(--secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.5rem;
  color: var(--brand-color);
  font-size: 1.5rem;
  transition: transform 0.3s;
}

.agent-card:hover .agent-card-icon {
  transform: scale(1.1) rotate(5deg);
}

.agent-card-name {
  font-weight: 600;
  font-size: 1.1rem;
  color: var(--text-color);
}

.agent-card-description {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3; /* Allow 3 lines */
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: auto; /* Let it breathe */
  max-height: 3.9rem; /* Exactly 3 lines (1.3 * 3) or similar */
}

.agent-card-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  background: rgba(152, 193, 5, 0.1);
  color: var(--brand-color);
  font-weight: 700;
  text-transform: uppercase;
}

.agent-selector-footer {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--secondary-color);
  display: flex;
  justify-content: flex-end;
  background: var(--primary-color);
  flex-shrink: 0;
}

.manage-agents-btn {
  background-color: transparent;
  border: 1px solid var(--placeholder-color);
  color: var(--placeholder-color);
  /* Re-uses styles from .new-conversation-btn */
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
}

/* --- NEW: Agent Editor Form Styles --- */
.agent-editor-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem; /* Increased space between form groups */
}

.agent-editor-form .form-label-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.agent-editor-form label .required-asterisk {
    color: var(--error);
    margin-left: 4px;
    font-weight: bold;
}

.agent-editor-form .icon-button {
    background: none;
    border: none;
    color: var(--placeholder-color);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    display: flex;
}

.agent-editor-form .icon-button:not(:disabled):hover {
    background-color: var(--secondary-hover-color);
    color: var(--brand-color);
}

.agent-editor-form label {
    font-weight: 500;
    color: var(--placeholder-color) !important;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem !important;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.agent-editor-form label .material-symbols-rounded {
    color: var(--placeholder-color) !important;
}

.agent-form-section .form-group {
    margin-bottom: 1.25rem !important; /* Reducido para evitar scroll innecesario */
}

.agent-editor-form input[type="text"],
.agent-editor-form input[type="datetime-local"],
.agent-editor-form select,
.agent-editor-form textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--placeholder-secundary-color);
    background-color: var(--primary-color);
    color: var(--text-color);
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.agent-editor-form input:focus,
.agent-editor-form select:focus,
.agent-editor-form textarea:focus {
    border-color: var(--brand-color);
    background-color: var(--secondary-hover-color);
    box-shadow: 0 0 0 2px rgba(152, 193, 5, 0.2);
}

.agent-editor-form select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24' fill='%23b5b5b5'%3E%3Cpath d='M480-345 240-585l56-56 184 184 184-184 56 56-240 240Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1.25rem;
}

.agent-editor-form textarea {
    resize: vertical;
    min-height: 80px;
    line-height: 1.5;
}

/* Fix for the agent prompt input which is wrapped in a container for mentions */
.agent-editor-form .typing-area-container {
    border: 1px solid var(--placeholder-secundary-color);
    background-color: var(--primary-color);
    border-radius: 8px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.agent-editor-form .typing-area-container:focus-within {
    border-color: var(--brand-color);
    background-color: var(--secondary-hover-color);
    box-shadow: 0 0 0 2px rgba(152, 193, 5, 0.2);
}

/* NEW: Form layout classes */
.form-row {
    display: flex;
    gap: 1.5rem;
    width: 100%;
}

.form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Responsive Form Layout */
@media (max-width: 1024px) {
    .form-row {
        flex-direction: column;
        gap: 1.25rem;
    }

    .agent-selector-modal {
        width: 95% !important;
        max-height: 90vh !important;
    }

    .agent-editor-content {
        padding: 1rem;
    }
}

/* Modal Action Buttons Styles */
.modal-btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border: none;
}

.modal-btn-primary {
    background-color: var(--brand-color);
    color: white;
}

.modal-btn-primary:hover {
    background-color: #85b004;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(152, 193, 5, 0.3);
}

.modal-btn-secondary {
    background-color: transparent;
    color: var(--placeholder-color);
    border: 1px solid var(--placeholder-secundary-color);
}

.modal-btn-secondary:hover {
    background-color: var(--secondary-hover-color);
    color: var(--text-color);
    border-color: var(--placeholder-color);
}

.agent-editor-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-color);
}

/* --- NEW: Agent Editor List Styles --- */
.agent-editor-content {
    overflow-y: auto;
    padding: 2rem 2rem 1rem;
    flex-grow: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.agent-editor-content::-webkit-scrollbar {
    width: 6px;
}

.agent-editor-content::-webkit-scrollbar-track {
    background: transparent;
}

.agent-editor-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: content-box;
}

.agent-editor-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid transparent;
    background-clip: content-box;
}

.agent-editor-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-radius: 1rem;
    background: var(--input-wrapper-background);
    margin-bottom: 0.75rem;
    border: 1px solid var(--secondary-color);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.agent-editor-item:hover {
    background: var(--secondary-hover-color);
    border-color: var(--brand-color);
    transform: translateX(5px);
}

.agent-item-details {
    flex-grow: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agent-item-name {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.05rem;
}

.agent-item-description {
    color: var(--placeholder-color);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-item-actions {
    display: flex;
    gap: 0.75rem;
}

.agent-action-btn {
    background: var(--secondary-color);
    border: none;
    color: var(--placeholder-color);
    cursor: pointer;
    padding: 0.6rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.agent-action-btn:hover {
    background: var(--brand-color);
    color: white;
    transform: scale(1.1);
}

.agent-action-btn.delete:hover {
    background: var(--error);
}

/* Agent Form Sections Styling */
.agent-form-section {
    background: var(--input-wrapper-background);
    padding: 1.75rem 1.75rem 1rem;
    border-radius: 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--secondary-color);
    transition: border-color 0.3s;
}

.agent-form-section:focus-within {
    border-color: rgba(152, 193, 5, 0.3);
}

.agent-form-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--placeholder-color);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.agent-form-section-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--secondary-color);
}

.generate-ai-btn {
    background: linear-gradient(135deg, #8500d3 0%, #d688ff 100%) !important;
    border: none !important;
    color: white !important;
    padding: 0.6rem 1.25rem !important;
    border-radius: 2rem !important;
    font-weight: 600 !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.5rem !important;
    transition: all 0.3s !important;
    box-shadow: 0 4px 15px rgba(133, 0, 211, 0.3) !important;
    cursor: pointer;
}

.generate-ai-btn:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 25px rgba(133, 0, 211, 0.4) !important;
}

.generate-ai-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.suggestions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.agent-editor-modal {
    background: var(--primary-color);
    width: 95%;
    max-width: 850px;
    max-height: 90vh;
    border-radius: 1.5rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,0.4);
    animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-btn {
    padding: 0.8rem 1.75rem;
    border-radius: 2rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
}

.modal-btn-primary {
    background: var(--brand-color);
    color: white;
}

.modal-btn-primary:hover {
    background: #85b004;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(152, 193, 5, 0.3);
}

.modal-btn-secondary {
    background: transparent;
    color: var(--placeholder-color);
    border: 1px solid var(--secondary-color);
}

.modal-btn-secondary:hover {
    background: var(--secondary-color);
    color: var(--text-color);
    border-color: var(--placeholder-color);
}


/* BotÃ³n de toggle del menÃº (posiciÃ³n gestionada por JS) */
#toggle-sidebar-btn {
  margin-left: 0.5rem; /* Align with logo */
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 8px; /* Aumentado para un mejor Ã¡rea de clic */
  border-radius: 50%;
  display: flex;
  /* order: 2; /* No longer needed, position is handled by parent container */
}

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

/* NEW: Wrapper for scrollable content */
.sidebar-scrollable-area {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  overflow: visible; /* Changed from hidden to allow tooltips to pop out */
  min-height: 0; /* Allow the area to shrink and enable scrolling in children */
}

.sidebar-content {
  padding: 0.5rem 1rem; /* Adjust padding for alignment */
  flex-shrink: 0; /* Prevent this from shrinking */
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem;
  border-top: 1px solid var(--placeholder-secundary-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.navigation-help-sidebar {
  position: relative;
  cursor: pointer;
}

.navigation-help-sidebar .help-tooltip {
  bottom: -10px;
  top: auto;
  left: calc(100% + 15px); /* Expand to the right of the sidebar */
  right: auto;
  width: 350px;
  transform: translateY(0);
}

/* Arrow pointing left towards the sidebar */
.navigation-help-sidebar .help-tooltip::after {
  top: 20px;
  bottom: auto;
  right: 100%;
  left: auto;
  border-color: transparent var(--brand-color) transparent transparent;
}

.sidebar.collapsed .navigation-help-sidebar span:not(.material-symbols-rounded) {
  display: none;
}

.conversations-list-container {
  flex-grow: 1; /* This will take up the available space */
  overflow-y: auto; /* And only this will scroll */
  padding: 0 1rem; /* Horizontal padding */
  min-height: 0; /* Important: allow the container to shrink to enable scrolling */
}

/* NEW: Scrollbar styling for conversations list */
.conversations-list-container::-webkit-scrollbar {
  width: 8px;
}

.conversations-list-container::-webkit-scrollbar-track {
  background: transparent; /* Make track invisible */
}

.conversations-list-container::-webkit-scrollbar-thumb {
  background-color: var(--placeholder-secundary-color);
  border-radius: 10px;
  border: 2px solid var(--secondary-color); /* Creates padding around thumb */
}

.conversations-list-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--placeholder-color);
}

/* For Firefox */
.conversations-list-container {
  scrollbar-width: thin;
  scrollbar-color: var(--placeholder-secundary-color) transparent;
}


.settings-popup {
  display: none; /* Hidden by default */
  position: fixed;
  top: 5rem; /* Position below the gear icon */
  right: 1.5rem;
  width: 300px;
  background-color: var(--secondary-hover-color);
  border-radius: 12px;
  box-shadow: 0 0 12px 0 rgba(41, 41, 61, 0.08);
  z-index: 1000;
  border: 1px solid var(--placeholder-secundary-color);
  /* overflow: hidden; <-- REMOVED to allow tooltips to show */
}

.settings-popup.show {
  display: block;
}

.settings-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--placeholder-secundary-color);
  gap: 10px; /* Added gap for elements */
}

.settings-popup-header h4 {
  color: var(--text-color);
  margin: 0;
  flex: 1; /* Title takes available space */
}

/* NEW: Style for the help icon in settings header */
.help-icon-wrapper.settings-help-header {
  position: relative;
  top: 0;
  right: 0;
  color: var(--text-secondary);
}

.help-icon-wrapper.settings-help-header .material-symbols-rounded {
  font-size: 1.2rem;
}

/* Specific positioning for settings header tooltip (Downwards) */
.help-icon-wrapper.settings-help-header .help-tooltip {
  width: 320px !important;
  right: -10px !important;
  top: calc(100% + 15px) !important;
  bottom: auto !important;
  text-align: left !important;
}

.help-icon-wrapper.settings-help-header .help-tooltip p {
  color: var(--text-secondary) !important;
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
  font-weight: 400 !important;
}

.help-icon-wrapper.settings-help-header .help-tooltip h3 {
  color: var(--brand-color) !important;
  font-size: 1.1rem !important;
  margin-bottom: 0.8rem !important;
}

/* Flip the arrow for settings header tooltip */
.help-icon-wrapper.settings-help-header .help-tooltip::after {
  top: auto;
  bottom: 100%; /* Arrow at the top of the tooltip */
  right: 15px;
  border-color: transparent transparent var(--brand-color) transparent;
}

.settings-popup-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-popup-content .setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--text-color); /* Ensure text is readable in dark mode */
}

/* NEW: Container for label and help icon */
.setting-label-container {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

/* NEW: Specific sizing for help icons in settings */
.help-icon-wrapper.settings-help {
  position: relative; /* Inside settings, use relative to stay next to label */
  top: 0;
  right: 0;
}

.help-icon-wrapper.settings-help .material-symbols-rounded {
  font-size: 1.1rem; /* Smaller icons for settings */
  opacity: 0.6;
}

.help-icon-wrapper.settings-help:hover .material-symbols-rounded {
  opacity: 1;
}

/* Position tooltip within settings modal */
.help-icon-wrapper.settings-help .help-tooltip {
  width: 240px; /* Narrower for the settings modal */
  right: -10px;
  bottom: calc(100% + 10px);
  padding: 0.8rem;
  font-size: 0.85rem;
}

.help-icon-wrapper.settings-help .help-tooltip p {
  margin: 0;
  color: var(--text-color);
  font-weight: 400;
}

/* Ensure the arrow is aligned */
.help-icon-wrapper.settings-help .help-tooltip::after {
  right: 15px;
}

.settings-popup-content .setting-item label {
        color: var(--text-color);
}



.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  user-select: none; /* Prevent text selection on click */
}

.settings-header:hover {
  background-color: var(--secondary-hover-color);
}

.settings-title {
  color: var(--placeholder-color);
  font-size: 0.9rem;
  margin: 0; /* Remove margin from title */
  text-transform: uppercase;
}

.settings-toggle-icon {
  transition: transform 0.3s ease;
  color: var(--placeholder-color); /* Ensure the icon is visible in both themes */
}

.sidebar-settings.open .settings-toggle-icon {
  transform: rotate(180deg);
}

.sidebar-settings.open .settings-content {
  max-height: 300px; /* Adjust as needed */
  padding-top: 1rem; /* Add padding when open */
}

.sidebar-settings .setting-item.response-length {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
}

.response-length-options {
  display: flex;
  gap: 10px;
  align-items: center;
}

.response-length-options label {
  font-size: 0.85rem;
}

.sidebar-settings .setting-item label[for="usetable"] {
  flex-grow: 1; /* Allow label to take space */
}

/* NEW: Ensure theme label also takes available space */
.sidebar-settings .setting-item label[for="theme-toggle-button"] {
  flex-grow: 1;
}

.sidebar-settings #theme-toggle-button {
  cursor: pointer;
  font-size: 1.4rem;
  padding: 5px;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.sidebar-settings #theme-toggle-button:hover {
  background-color: var(--secondary-hover-color);
}

.sidebar.collapsed .sidebar-footer {
  display: none; /* Footer is hidden when collapsed */
}

.conversations-header {
  display: flex;
  align-items: center;
  padding: 1rem 1rem 0.5rem 1rem; /* Space from the elements above */
  margin-bottom: 0.5rem;
  justify-content: flex-start; /* Align help icon next to title */
  gap: 8px; /* Small gap between title and icon */
}

/* NEW: History help icon positioning */
.help-icon-wrapper.history-help {
  position: relative;
  top: 0;
  right: 0;
  color: var(--text-secondary);
}

.help-icon-wrapper.history-help .material-symbols-rounded {
  font-size: 1.1rem;
}

.help-icon-wrapper.history-help .help-tooltip {
  width: 300px;
  left: calc(100% + 15px); /* Expand to the right of the sidebar */
  right: auto;
  top: 0;
  bottom: auto;
  z-index: 9999; /* Maximum z-index to ensure visibility */
}

.help-icon-wrapper.history-help .help-tooltip::after {
  top: 10px;
  bottom: auto;
  right: 100%;
  left: auto;
  border-color: transparent var(--brand-color) transparent transparent;
}

.conversations-header h4.active {
  color: var(--text-color);
  font-weight: 600;
}
.conversations-header h4 {
  cursor: pointer;
}

.conversations-header h4 {
  color: var(--placeholder-color);
  font-size: 0.9rem;
  text-transform: uppercase;
  margin: 0; /* Remove default margin */
  font-weight: 500;
}

/* NEW: Search input inside sidebar */
.search-wrapper {
  position: relative;
  padding: 0 1rem 0.5rem;
}
.search-wrapper .material-symbols-rounded {
  position: absolute;
  left: 1.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--placeholder-color);
  font-size: 1.2rem;
}
.search-wrapper input {
  width: 100%;
  padding-left: 2.2rem; /* Space for the icon */
}
.search-wrapper #close-search-btn {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  padding: 2px;
  color: var(--placeholder-color);
}

.sidebar.collapsed .conversations-header {
  display: none;
}

/* NEW: Style for the "No conversations" message */
.no-conversations-message {
  color: var(--placeholder-color);
  padding: 0.5rem 0.2rem;
  font-style: italic;
}

/* NEW: Style for conversation list items */
.conversation-item {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 0.5rem 1rem; /* FIX: Align with sidebar-item horizontal padding */
  border-radius: 4px;
  position: relative;
  gap: 0.5rem;
}

.conversation-item:hover {
  background-color: var(--secondary-hover-color);
}

.conversation-item-title {
  color: var(--text-color);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-grow: 1; /* Take available space */
}
.conversation-item .material-symbols-rounded {
  color: var(--placeholder-color);
  font-size: 1.2rem;
  cursor: pointer; /* Make icon clickable */
}
/* NEW: Style for favorite conversation icon */
.conversation-item .favorite-star {
  color: var(--text-color); /* Use default text color to be less prominent */
  font-variation-settings: 'FILL' 1; /* Filled star */
}


.conversation-menu-btn {
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto; /* Push to the far right */
  opacity: 0; /* Hidden by default */
  transition: opacity 0.2s ease, background-color 0.2s ease;
}

/* NEW: Adjust SVG icon size specifically for the conversation menu if needed */
.conversation-menu-btn .icon-svg {
    width: 18px;
    height: 18px;
}

.conversation-item:hover .conversation-menu-btn {
  opacity: 1; /* Show on hover */
}

.conversation-menu-btn:hover {
  background-color: var(--secondary-color); /* A bit darker than the item hover */
}

/* NEW: Context menu for conversation items */
.conversation-item .shared-icon {
  font-size: 16px;
  opacity: 0.7;
  flex-shrink: 0;
  margin-right: 6px;
  color: var(--text-secondary); /* Default for light theme */
  transition: all 0.2s ease;
}

[data-theme='dark'] .shared-icon {
  color: var(--text-color);
  opacity: 0.5;
}

.conversation-item:hover .shared-icon {
  opacity: 1;
  color: var(--brand-color);
}

.conversation-context-menu {
  display: none; /* Hidden by default */
  position: absolute;
  right: 10px; /* Position near the menu button */
  top: 35px;   /* Position below the menu button */
  background-color: var(--secondary-hover-color); /* Same as dropdowns */
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 110; /* Below project dropdown but above most content */
  min-width: 180px;
  padding: 0.5rem 0;
  border: 1px solid var(--placeholder-secundary-color);
}

.conversation-context-menu.show {
  display: block;
}

.context-menu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 1.4rem;
  width: 100%;
  text-align: left;
  font-size: 0.9rem;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.context-menu-item.delete {
  color: var(--error);
}

.context-menu-item.delete:hover {
  background-color: var(--error);
  color: #fff;
}

/* --- NEW: In-place Rename Input --- */
.rename-input {
  width: 100%;
  background-color: var(--secondary-hover-color);
  border: 1px solid var(--brand-color);
  border-radius: 4px;
  color: var(--text-color);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: inherit; /* Inherit font size from the list item */
  padding: 2px 6px;
  outline: none;
  box-shadow: 0 0 5px rgba(152, 193, 5, 0.5);
  /* Ensure it takes up the same space as the title */
  margin: 0;
  flex-grow: 1;
}


/* --- NEW CONVERSATION BUTTON --- */
.new-conversation-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background-color: var(--brand-color);
  color: white;
  border: none;
  cursor: pointer;
  border-radius: 2rem; /* Fully rounded */
  padding: 0.75rem 1rem;
  margin: 0 1rem 1rem 1rem; /* Margin around the button */
  margin-top: 1rem; /* FIX: Add top margin to separate from project selector */
  transition: background-color 0.2s ease;
  text-decoration: none;
}

.new-conversation-btn:hover {
  background-color: #85b004; /* Darker purple on hover */
}

.sidebar.open .new-conversation-btn {
    justify-content: flex-start;
}


/* Collapsed state for sidebar */
.sidebar.collapsed {
  width: 90px;
}

.sidebar.collapsed .sidebar-logo,
.sidebar.collapsed .project-name-sidebar,
.sidebar.collapsed .sidebar-content,
.sidebar.collapsed .expand-icon {
  display: none;
}
.sidebar.collapsed .sidebar-header {
  display: none;
}

.sidebar.collapsed .sidebar-logo-collapsed {
  display: block; /* Show the 'H' when collapsed */
}

/* NEW: Adjust new conversation button size when collapsed */
.sidebar.collapsed .new-conversation-btn {
  width: 48px; /* Make it a square-ish button */
  height: 48px;
  padding: 0; /* Remove padding to center the icon */
  margin: 1rem auto; /* Center it horizontally */
}

/* NEW: Hide text on all sidebar items when collapsed */
.sidebar.collapsed .sidebar-item span:not(.material-symbols-rounded) {
  display: none;
}

.sidebar.collapsed .sidebar-item {
  justify-content: center;
}

.sidebar.collapsed .new-conv-text {
  display: none;
}

/* NEW: Styles for collapsed agent icons */
.collapsed-agent-wrapper {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 0.5rem 0;
}
.sidebar.collapsed .collapsed-agent-wrapper {
  display: flex;
}
.collapsed-agent-wrapper .sidebar-item {
  justify-content: center;
  width: 100%;
}
.sidebar.collapsed .new-conversation-btn .new-conv-text {
  display: none;
}

/* NEW: Styles for the collapsed project icon */
.collapsed-project-icon-wrapper {
  display: none; /* Hidden by default */
  padding: 0.5rem 1rem; /* Match header padding */
  cursor: pointer;
  justify-content: center; /* Align icon to the center */
}
.sidebar.collapsed .collapsed-project-icon-wrapper {
  display: flex; /* Shown only when sidebar is collapsed */
}

/* NEW: Hide icons and menu buttons in collapsed state to prevent horizontal scroll */
.sidebar.collapsed .shared-icon,
.sidebar.collapsed .conversation-menu-btn {
  display: none !important;
}

.main-content {
  display: flex;
  width: 100%;
  height: 100vh; /* Take full viewport height */
}

.chat-area-wrapper {
  flex-grow: 1;
  display: flex; /* This is key for vertical centering */
  flex-direction: column;
  padding-top: 60px;  /* FIX: Apply padding here to always reserve space for the top-bar */
}

/* FIX: Apply max-width and centering to the containers, not individual messages */
/* When a conversation is active, the header disappears and the chat list grows */
.header,
.chat-list,
.typing-form {
  max-width: 1080px;
  width: 100%; /* <-- AÃ‘ADIDO: Esta es la correcciÃ³n clave */
  margin: 0 auto; /* This centers the containers horizontally */
}
body.hide-header .header,
body.hide-header .suggestion-list {
  display: none;
}
/* The padding is now on chat-area-wrapper, so this is no longer needed */


/* NEW: Wrapper to center header content vertically and horizontally */
.header-center-content {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* NEW: Styles for the simplified header */
.header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end; /* Align content to the bottom */
  padding: 2rem 2rem 0; /* Remove bottom padding to get closer to input */
  flex-shrink: 0;
  position: relative; /* For the pseudo-element */
  color: var(--text-color);
  min-height: 200px; /* Give it some space */
  /* NEW: This makes the header take up the available space, pushing the typing-area down */
  flex-grow: 1;
  justify-content: center; /* This centers the content vertically */
}

/* NEW: Blurred radial background effect */
.header::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 500px;
  height: 300px; /* Made it a bit taller */
  background: radial-gradient(circle, rgba(152, 193, 5, 0.15) 0%, rgba(152, 193, 5, 0) 70%);
  filter: blur(50px);
  z-index: -1;
}

.header .title {
  text-align: center;
  width: 100%;
}

.header .subtitle {
  color: var(--placeholder-color);
  font-size: 1rem;
  margin-top: 0.5rem;
}

.suggestion-list {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 20px;
  flex-shrink: 0; /* Prevent it from shrinking */
  max-width: 1080px; /* Match other containers */
  margin: 0 auto; /* Center it */
}

/* NEW: Chip style for suggestions */
.suggestion-list .suggestion {
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 20px;
  background-color: var(--secondary-color);
  border: 1px solid var(--placeholder-secundary-color);
  color: var(--text-color);
  font-size: 0.9rem;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.suggestion-list .suggestion:hover {
  background: var(--secondary-hover-color);
  border-color: var(--brand-color);
}

.chat-list {
  padding: 1rem;
  flex-grow: 1; /* Make chat list take available space */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(128, 128, 128, 0.3) transparent;
}

.chat-list::-webkit-scrollbar {
  width: 6px;
}

.chat-list::-webkit-scrollbar-track {
  background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
  background: rgba(128, 128, 128, 0.3);
  border-radius: 10px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
  background: rgba(128, 128, 128, 0.5);
}

.chat-list .message {
  scroll-margin-top: 70px; /* Compensa la barra superior fija de 50px en tablets/móviles */
}

/* FIX: Make incoming messages a flex container to align avatar, text, and action buttons */
.chat-list .message.incoming {
  display: flex;
  align-items: flex-start; /* Align items to the top (avatar, text, buttons) */
  gap: 1.5rem; /* Space between avatar/text and action buttons */
  margin-top: 1.5rem;
  width: 100%;
  /* No specific padding-left here, it's handled by .chat-list padding */
}

.chat-list .message.incoming .ai-response-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.5rem;
  flex-grow: 1;
  max-width: calc(100% - 40px - 1.5rem);
}

.chat-list .message.incoming .ai-response-body {
  display: flex;
  flex-direction: column; /* Stack text/charts and actions vertically */
  flex-grow: 1; /* Take available horizontal space */
  background-color: var(--secondary-color); /* AI bubble background */
  padding: 10px 15px;
  border-radius: 15px;
  position: relative; /* For the triangle pseudo-element */
  width: 100%;
}

/* Triangle for AI message bubble */
.chat-list .message.incoming .ai-response-wrapper .ai-response-body::before {
  content: "";
  position: absolute;
  left: -10px; /* Position to the left of the bubble */
  top: 15px;
  border: 8px solid transparent;
  border-right: 10px solid var(--secondary-color); /* Color of the bubble */
}

.chat-list .message.outgoing {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin-top: 1.5rem;
  align-items: flex-start;
  gap: 0.5rem;
}

/* Action buttons on outgoing messages */
.outgoing-message-actions {
    display: flex;
    flex-direction: row; /* Position icons horizontally */
    align-items: center;
    gap: 0.25rem; /* Small gap between them */
}

.outgoing-message-actions .icon {
    visibility: hidden; /* Hide icons by default */
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.chat-list .message.outgoing:hover .outgoing-message-actions .icon {
    visibility: visible; /* Show on message hover */
}

.outgoing-message-actions .icon:hover {
    opacity: 1;
}

.chat-list .message .message-content {
  /* This class is for outgoing messages. It makes the bubble shrink to fit the text. */
  /* For incoming messages, .ai-response-body handles the layout */
  max-width: 85%; /* The bubble won't exceed 85% of the container width */
  width: fit-content;
}

.chat-list .message .text {
  color: var(--text-color);
}

.chat-list .message.outgoing .message-content .text {
  background-color: var(--user-bubble-background);
  padding: 10px 15px;
  border-radius: 15px;
  position: relative;
  text-align: left; /* The text inside the bubble aligns left, but the bubble itself is on the right */
  word-wrap: break-word;
  white-space: pre-wrap;
}

.message-timestamp {
  font-size: 0.75rem;
  color: var(--placeholder-color);
  margin-top: 4px;
  display: block;
  width: 100%;
}

.message.outgoing .message-timestamp {
  text-align: right;
  padding-right: 5px;
}

.message.incoming .message-timestamp {
  text-align: left;
  padding-left: 5px;
  margin-bottom: 8px; /* Separación de las acciones */
}

.chat-list .message.outgoing .text::after {
  content: "";
  position: absolute;
  right: -10px;
  top: 15px;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 10px solid var(--user-bubble-background);
}

.chat-list .message.error .text {
  color: var(--error);
}

.chat-list .message.loading .ai-response-body {
  display: none !important;
}

/* Ensure the wrapper itself stays visible to show progress messages */
.chat-list .message.loading .ai-response-wrapper {
  display: flex !important;
}

.chat-list .message .avatar {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 50%;
  align-self: flex-start;
  transition: transform 0.3s ease;
}

.chat-list .message.loading .avatar {
  animation: avatarPulse 2s infinite ease-in-out;
  border: 2px solid var(--brand-color);
  box-shadow: 0 0 15px var(--brand-color);
}

@keyframes avatarPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(152, 193, 5, 0.4);
    border-color: rgba(152, 193, 5, 0.6);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 25px rgba(191, 255, 0, 0.8);
    border-color: rgba(191, 255, 0, 1);
  }
}

/* HannaH SVG Avatar Sparkles Animation during Loading */
.chat-list .message.loading .avatar .sparkle {
  transform-origin: center;
  transform-box: fill-box;
}

.chat-list .message.loading .avatar .sparkle-large {
  animation: sparkleLargeAnim 2s infinite ease-in-out;
}

.chat-list .message.loading .avatar .sparkle-medium {
  animation: sparkleMediumAnim 2s infinite ease-in-out 0.4s;
}

.chat-list .message.loading .avatar .sparkle-small {
  animation: sparkleSmallAnim 2s infinite ease-in-out 0.8s;
}

@keyframes sparkleLargeAnim {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.7) rotate(45deg);
    opacity: 0.6;
  }
}

@keyframes sparkleMediumAnim {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.6) rotate(-45deg);
    opacity: 0.5;
  }
}

@keyframes sparkleSmallAnim {
  0%, 100% {
    transform: scale(1) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(0.5) rotate(30deg);
    opacity: 0.4;
  }
}

/* NEW: Styles for the "Show More" button to match the wireframe */
#show-more-conversations-btn {
  background: none;
  border: none;
  color: var(--placeholder-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  width: 100%;
  justify-content: flex-start; /* Align to the left */
}

#show-more-conversations-btn:hover {
  color: var(--text-color);
}

/* NEW: Styles for the li container of the show more button */
#show-more-li {
  list-style-type: none; /* Remove bullet point */
  padding: 0;
}

/* FIX: Vertically align the expand icon with the text */
#show-more-conversations-btn .material-symbols-rounded {
  font-size: 1.2rem; /* Match other icons */
}


.icon-button {
    background: none;
    border: none;
    color: var(--placeholder-color);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
}

.chat-list .message .icon {
  color: var(--text-color);
  cursor: pointer;
  height: 35px;
  width: 35px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  font-size: 1.25rem;
  flex-shrink: 0; /* Prevent icons from shrinking */ /* Visibility handled by specific rules */
}

/* Specific styles for outgoing message icons */
.chat-list .message.outcoming .icon {
  margin: 0; /* Spacing is now handled by 'gap' on the parent */
}

/* FIX: Ensure the actions wrapper and its contents are visible in incoming messages */
/* NEW: Styles for the actions container within AI response body */
.chat-list .message.incoming .ai-message-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  justify-content: flex-start; /* Align buttons to the left */
  padding-left: 5px;
}

/* Ensure icons within ai-message-actions and outgoing copy button are visible */
.chat-list .message.incoming .ai-message-actions .icon,
.chat-list .message.incoming .ai-message-actions .feedback-controls,
.chat-list .message.outgoing .icon { /* This now targets the dynamically added copy button for outgoing messages */
  visibility: visible;
}

.chat-list .message .icon.hide {
  visibility: hidden;
}
.chat-list .message .loading-indicator {
  display: none;
  gap: 0.6rem;
  width: 100%;
  flex-direction: column;
  padding: 0.5rem 0;
}

.chat-list .message.loading .loading-indicator {
  display: flex;
}

.chat-list .message .loading-indicator .loading-bar {
  height: 8px;
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, 
    rgba(152, 193, 5, 0.15) 0%, 
    rgba(152, 193, 5, 0.8) 25%, 
    rgba(191, 255, 0, 1) 50%, 
    rgba(152, 193, 5, 0.8) 75%, 
    rgba(152, 193, 5, 0.15) 100%
  );
  background-size: 200% 100%;
  box-shadow: 0 0 12px rgba(152, 193, 5, 0.25);
  animation: waveFlow 1.6s infinite linear;
}

/* Multi-layered organic wave flow with offset speeds and scaling pulses */
.chat-list .message .loading-indicator .loading-bar:nth-child(1) {
  animation: waveFlow 1.6s infinite linear, wavePulse 2s infinite ease-in-out;
  width: 90%;
}

.chat-list .message .loading-indicator .loading-bar:nth-child(2) {
  animation: waveFlow 1.2s infinite linear, wavePulse 1.6s infinite ease-in-out 0.2s;
  width: 100%;
  height: 6px;
  opacity: 0.8;
}

.chat-list .message .loading-indicator .loading-bar:nth-child(3) {
  animation: waveFlow 2s infinite linear, wavePulse 2.4s infinite ease-in-out 0.4s;
  width: 75%;
  height: 5px;
  opacity: 0.6;
}

@keyframes waveFlow {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes wavePulse {
  0%, 100% {
    transform: translateY(0) scaleY(1);
  }
  50% {
    transform: translateY(-3px) scaleY(1.15);
    box-shadow: 0 0 18px rgba(191, 255, 0, 0.45);
  }
}

/* === SECCIÃ“N MODIFICADA PARA SOLUCIONAR EL OVERLAP Y PERMITIR MULTILÃNEA === */

.typing-area {
  position: relative; /* Cambiado de fixed a relative */
  flex-shrink: 0; /* Evita que se encoja */
  padding: 1rem;
  margin: 0 auto 1rem; /* Center the typing area and add bottom margin */
  background: var(--primary-color);
  z-index: 20;
  transition: all 0.3s ease;
}

.typing-area.drag-over .input-wrapper {
  border-color: var(--brand-color) !important;
  background: rgba(152, 193, 5, 0.05);
  box-shadow: 0 0 15px rgba(152, 193, 5, 0.2);
}

.typing-area :where(.typing-form, .action-buttons) {
  display: flex;
  gap: 0.75rem;
}

/* Contenedor principal que envuelve toda la barra de entrada */
.typing-form .input-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column; /* Apila las previsualizaciones y la fila del input */
  position: relative;
  background: var(--input-wrapper-background);
  backdrop-filter: blur(10px); /* Blurred background effect */
  -webkit-backdrop-filter: blur(10px); /* For Safari */
  border-radius: 12px; /* Redondeo como en el diseÃ±o */
  padding: 0; /* No padding on the main wrapper */
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  max-width: 800px; /* Widen the input box */
  margin: 0 auto; /* Center the input box */
  border: 1px solid var(--placeholder-secundary-color);
}

/* --- HELP ICON & TOOLTIP (Unified & Theme-Aware) --- */
/* --- UNIFIED HELP ICON & TOOLTIP STYLES --- */
.help-icon-wrapper {
  position: absolute;
  top: 12px;
  right: 15px;
  z-index: 20;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.help-icon-wrapper:hover {
  color: var(--brand-color);
}

.help-icon-wrapper .material-symbols-rounded {
  font-size: 1.2rem; /* Unified icon size */
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.help-tooltip {
  position: absolute;
  bottom: calc(100% + 15px);
  right: -5px;
  width: 320px;
  background-color: var(--secondary-hover-color);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid var(--brand-color);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 0 12px 0 rgba(41, 41, 61, 0.08);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 9999;
  max-height: 450px;
  overflow-y: auto;
  text-align: left;
  color: var(--text-color);
  font-family: "IBM Plex Sans", sans-serif;
}

.help-tooltip h3 {
  margin: 0 0 1rem 0;
  font-size: 1.1rem;
  color: var(--brand-color) !important;
  border-bottom: 1px solid rgba(152, 193, 5, 0.2);
  padding-bottom: 0.5rem;
  text-transform: none;
  font-weight: 600;
}

.help-section {
  margin-bottom: 1rem;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section h4 {
  font-size: 0.95rem;
  margin: 0 0 0.4rem 0;
  color: var(--text-color);
  font-weight: 600;
  text-transform: none;
}

.help-section p, .help-section li {
  font-size: 0.85rem;
  color: var(--text-secondary) !important;
  line-height: 1.5;
  margin: 0;
  text-transform: none;
  font-weight: 400;
}

.help-section ul {
  padding-left: 1.2rem;
  margin-top: 0.3rem;
}

.help-section li {
  margin-bottom: 0.4rem;
}

/* Custom scrollbar for tooltip */
.help-tooltip::-webkit-scrollbar {
  width: 4px;
}
.help-tooltip::-webkit-scrollbar-track {
  background: transparent;
}
.help-tooltip::-webkit-scrollbar-thumb {
  background: var(--brand-color);
  border-radius: 10px;
}

.help-icon-wrapper:hover .help-tooltip,
.help-icon-wrapper.active .help-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(-5px);
  pointer-events: auto;
}

/* Tooltip Arrow Base */
.help-tooltip::after {
  content: "";
  position: absolute;
  border-width: 8px;
  border-style: solid;
}

/* --- SPECIFIC HELP POSITIONING --- */

/* 1. History help (Sidebar) */
.help-icon-wrapper.history-help {
  position: relative;
  top: 0;
  right: 0;
  color: var(--text-secondary);
}

.help-icon-wrapper.history-help .help-tooltip {
  left: calc(100% + 15px);
  right: auto;
  top: 0;
  bottom: auto;
  transform: translateX(0);
}

.help-icon-wrapper.history-help .help-tooltip::after {
  top: 10px;
  bottom: auto;
  right: 100%;
  left: auto;
  border-color: transparent var(--brand-color) transparent transparent;
}

/* 2. Settings help (Popup Header) */
.help-icon-wrapper.settings-help-header {
  position: relative;
  top: 0;
  right: 0;
}

.help-icon-wrapper.settings-help-header .help-tooltip {
  top: calc(100% + 15px);
  bottom: auto;
  right: -10px;
  left: auto;
}

.help-icon-wrapper.settings-help-header .help-tooltip::after {
  top: auto;
  bottom: 100%;
  right: 15px;
  left: auto;
  border-color: transparent transparent var(--brand-color) transparent;
}

/* 3. Chat Input Help (Default arrow) */
.typing-form .help-icon-wrapper .help-tooltip::after {
  top: 100%;
  right: 20px;
  left: auto;
  border-color: var(--brand-color) transparent transparent transparent;
}




.help-section p, .help-section li {
  font-size: 0.85rem;
  color: var(--text-secondary) !important;
  line-height: 1.5;
  margin: 0;
  text-transform: none;
}

.help-section ul {
  padding-left: 1.2rem;
  margin-top: 0.3rem;
}

.help-section li {
  margin-bottom: 0.4rem;
}

/* --- END HELP ICON --- */


/* Contenedor para previsualizaciÃ³n de archivos */
#file-preview-container {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 10px;
  width: 100%;
  max-height: 100px;
  overflow-y: auto;
}

#file-preview-container:not(:empty) {
    margin-bottom: 5px; /* Add margin only when there are files */
}

/* FIX: AÃ±adir los estilos para los elementos de previsualizaciÃ³n de archivos */
.file-preview-item {
  border: 1px solid var(--placeholder-color);
  border-radius: 5px;
  padding: 3px 8px;
  margin: 2px;
  display: flex;
  align-items: center;
  font-size: 0.75em;
  background-color: var(--secondary-color);
  max-width: calc(50% - 10px);
  color: var(--text-color);
}

.file-preview-thumbnail {
  width: 30px;
  height: 30px;
  object-fit: cover;
  margin-right: 10px;
  cursor: pointer;
}

.file-preview-name {
  margin-right: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
  cursor: pointer;
}

.file-preview-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  font-size: 1.2em;
  line-height: 1;
  padding: 0 5px;
}

#file-preview-container > div {
  border: 1px solid var(--placeholder-color);
  border-radius: 5px;
  padding: 3px 8px;
  margin: 2px;
  display: flex;
  align-items: center;
  font-size: 0.75em;
  background-color: var(--secondary-color);
  max-width: calc(50% - 10px);
  color: var(--text-color); /* Make text color adapt to theme */
}
#file-preview-container > div span {
  max-width: 100px;
}

/* Fila que contiene el textarea y los botones, ahora usa flexbox */

.typing-form .input-wrapper:focus-within {
  box-shadow: 0 0 0 2px var(--brand-color);
}


/* Estilos para el TEXTAREA que admite mÃºltiples lÃ­neas */
.typing-form .typing-input {
  flex-grow: 1;
  min-height: 70px;
  height: auto;
  border: none;
  outline: none;
  resize: none;
  font-size: 1rem;
  color: var(--text-color) !important;
  padding: 1rem;
  background: transparent;
  line-height: 1.5;
  max-height: 200px;
  overflow-y: auto;
}

.typing-form .typing-input::placeholder {
  color: var(--placeholder-color);
}

/* NEW: Styles for the bottom action row */
.typing-form .bottom-actions-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 8px;
        min-height: 44px;
}
.typing-form .bottom-actions-row .left-actions,
.typing-form .bottom-actions-row .right-actions {
        display: flex;
        align-items: center;
        gap: 4px;
}


/* NEW: File counter style */
.typing-form .left-actions #file-counter {
  color: var(--placeholder-color);
  font-size: 0.85rem;
  margin: 0 8px;
  white-space: nowrap;
  background-color: var(--secondary-color);
  padding: 4px 8px;
  border-radius: 6px;
}

/* Estilos especÃ­ficos para los botones DENTRO de la barra de input */
.typing-form .attach-file-btn,
.typing-form #copy-conversation-button,
.typing-form .right-actions #stop-button,
.typing-form .right-actions #send-message-button {
  flex-shrink: 0; /* Evita que los botones se encojan */
  position: static; /* Importante: quitamos el posicionamiento absoluto */
  width: 36px;
  height: 36px;
  border: none;
  color: var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  cursor: pointer;
  margin: 0 2px;
  border-radius: 50%;
}

.typing-form .bottom-actions-row .icon:hover {
  color: var(--text-color);
  background-color: var(--secondary-hover-color);
}

/* --- NEW: Model Selector Styles --- */
.model-selector-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.model-selector-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--secondary-color);
  border: 1px solid var(--placeholder-secundary-color);
  border-radius: 20px;
  padding: 4px 12px;
  color: var(--text-color);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  height: 32px;
}

.model-selector-btn:hover {
  background: var(--secondary-hover-color);
  border-color: var(--brand-color);
}

.model-selector-btn .material-symbols-rounded {
  font-size: 1.2rem;
  transition: transform 0.2s ease;
}

.model-selector-wrapper.open .model-selector-btn .material-symbols-rounded {
  transform: rotate(180deg);
}

.model-selector-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  width: 280px;
  background: var(--secondary-hover-color);
  border: 1px solid var(--placeholder-secundary-color);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 1000;
  padding: 8px;
  flex-direction: column;
}

.model-selector-wrapper.open .model-selector-dropdown {
  display: flex;
}

.model-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.model-option:hover {
  background: rgba(255, 255, 255, 0.05);
}

.model-option.active {
  background: rgba(152, 193, 5, 0.1);
  border: 1px solid rgba(152, 193, 5, 0.2);
}

.model-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-option-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
}

.model-option-desc {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.model-option .check-icon {
  font-size: 1.2rem;
  color: var(--brand-color);
  display: none;
}

.model-option.active .check-icon {
  display: block;
}

.typing-form #copy-conversation-button,
.typing-form #stop-button,
.typing-form .attach-file-btn {
  background: transparent;
}

.typing-form .right-actions #stop-button:hover {
    background-color: var(--secondary-hover-color);
}

.typing-form .right-actions #stop-button {
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.typing-form .right-actions #send-message-button {
  width: 36px; /* Slightly smaller */
  height: 36px;
  outline: none;
  display: none; /* Oculto por defecto para que no ocupe espacio */
  background-color: var(--brand-color);
  color: white;
  transition: opacity 0.2s ease, transform 0.2s ease;
  opacity: 0;
}

/* La clase .input-valid (gestionada por JS) muestra el botÃ³n de enviar */
/* This now targets the right-actions container to show/hide the button */
.typing-form .right-actions.input-valid #send-message-button {
    display: flex;
    transform: scale(1);
    opacity: 1;
}
.typing-form .right-actions.input-valid #send-message-button:hover {
    background-color: #85b004;
}

/* --- Visibilidad de botones de acciÃ³n --- */

/* Por defecto, el botÃ³n de parar estÃ¡ oculto */
.typing-form .right-actions #stop-button {
    display: none;
}

/* Cuando se estÃ¡ generando respuesta, mostramos 'parar' y ocultamos los otros */
.typing-form.is-generating .bottom-actions-row {
    justify-content: flex-end; /* Alinea todo el contenido a la derecha */
}
.typing-form.is-generating .left-actions,
.typing-form.is-generating .right-actions #send-message-button {
    display: none;
}
.typing-form.is-generating .right-actions #stop-button {
    display: flex; /* Muestra el botÃ³n de stop */
}
/* --- Feedback UI --- */
.feedback-controls {
    display: flex;
    align-items: center;
    gap: 0.25rem; /* Espacio reducido entre pulgares */
}

.feedback-btn {
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 1.25rem; /* Mismo tamaÃ±o que el de copiar */
    color: var(--text-color);
}

.feedback-btn:hover {
    background-color: var(--secondary-hover-color);
}

/* Estilo para cuando un botÃ³n de feedback estÃ¡ activo */
.feedback-btn.thumb-up-btn.selected {
    color: var(--feedback-positive-color);
}

.feedback-btn.thumb-down-btn.selected {
    color: var(--feedback-negative-color);
}

.feedback-btn.selected .material-symbols-rounded {
    font-variation-settings: 'FILL' 1; /* Icono relleno */
}

/* Contenedor para el input de texto del feedback negativo */
.feedback-input-container {
    display: none; /* Oculto por defecto */
    position: absolute;
    bottom: calc(100% + 15px); /* Posicionado encima de los botones de feedback con un margen de 15px */
    left: 50%;
    transform: translateX(-50%); /* Centrado horizontalmente respecto a su padre */
    width: 350px;
    max-width: 90vw;
    background-color: var(--secondary-hover-color);
    border: 1px solid var(--placeholder-secundary-color);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.25);
    z-index: 150;
    padding: 1rem;
    animation: fadeInScaleUpCentered 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

@keyframes fadeInScaleUp {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes fadeInScaleUpCentered {
    from { opacity: 0; transform: translateX(-50%) scale(0.9); }
    to { opacity: 1; transform: translateX(-50%) scale(1); }
}

/* Flecha que apunta hacia abajo */
.feedback-input-container::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 8px;
    border-style: solid;
    border-color: var(--secondary-hover-color) transparent transparent transparent;
}

.feedback-input-container textarea {
    width: 100%;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--placeholder-secundary-color);
    background-color: var(--secondary-color);
    color: var(--text-color);
    font-size: 0.9rem;
    resize: vertical;
    min-height: 80px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.feedback-input-container textarea:focus {
    border-color: var(--brand-color);
    box-shadow: 0 0 0 2px rgba(152, 193, 5, 0.3);
}

.feedback-popup-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.feedback-popup-btn {
    background-color: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.feedback-popup-btn:hover {
    background-color: var(--secondary-color);
}

/* === FIN DE LA SECCIÃ“N MODIFICADA === */

.typing-area .disclaimer-text {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 1rem;
  color: var(--placeholder-color);
}

.link {
  color: var(--text-color);
  text-decoration: none;
}
.link:hover {
  color: var(--brand-color);
  text-decoration: none;
}

strong {
  font-size: 1.1em; /* Un poco mÃ¡s grande que el texto normal */
  display: inline-block; /* Permite aplicar padding vertical */
  padding-top: 0.3em; /* Espacio superior dentro de la lÃ­nea */
  padding-bottom: 0.3em; /* Espacio inferior dentro de la lÃ­nea */
  /* NEW: Prevent long words in strong tags from overflowing */
  overflow-wrap: break-word;
  max-width: 100%;
}

hr {
  border: 0;
  border-top: 1px solid var(--placeholder-secundary-color);
  margin: 2em 0;
  padding: 0;
}

input[type="checkbox"] {
  accent-color: var(--brand-color);
}

.form-control {
  background: transparent;
  border: none;
  color: var(--text-color);
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  padding: 1.1rem 1.5rem;
  border-radius: 50px;
  cursor: pointer;
  appearance: auto;
}

.form-control option {
  background-color: var(--secondary-hover-color);
}

/* Responsive media query code for small screen */
@media (max-width: 1240px) {
  .hide-if-mobile {
      display: none;
  }

  #scroll-to-bottom-btn {
    right: 20px;
    width: 40px;
    height: 40px;
  }

  .header :is(.title, .subtitle) {
    font-size: 2rem;
    line-height: 2.6rem;
  }

  .header .subtitle {
    font-size: 1.7rem;
  }

  .typing-area :where(.typing-form, .action-buttons) {
    gap: 0.4rem;
  }

  .typing-area .disclaimer-text {
    font-size: 0.75rem;
    margin-top: 0.5rem;
  }

}

@media (max-height: 1000px) {
  .suggestion-list {
    padding: 10px;
    gap: 10px;
  }
}
@media (max-height: 780px) {
  .suggestion-list {
    display: none;
  }
}

@media (max-width: 989px) {
  .suggestion-list {
    display: none;
  }
}

/* --- MOBILE OPTIMIZATIONS (1024px and below) --- */
@media (max-width: 1024px) {
  html, body {
    height: 100%;
    overflow: hidden; /* Prevent body scrolling */
  }

  .main-content {
    height: 100%; /* Fill body */
    flex-direction: column;
  }

  .chat-area-wrapper {
    flex: 1; /* Grow to fill main-content */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Contain children */
    padding-top: 50px; /* Space for the fixed top-bar */
  }

  .header {
    flex-shrink: 0; /* Don't shrink header */
    padding: 1rem 1rem 0;
    min-height: 0;
  }

  .header::before {
    display: none; /* Disable large gradient on mobile */
  }

  .header .title {
      font-size: 1.5rem;
      line-height: 2rem;
  }

  .header .subtitle {
      font-size: 0.9rem;
  }

  .suggestion-list {
      flex-shrink: 0;
  }

  .chat-list {
    flex-grow: 1; /* Take up all available space */
    overflow-y: auto; /* And be the only scrolling element */
    padding: 1rem;
  }

  .typing-area {
    flex-shrink: 0; /* Don't shrink typing area */
    position: static; /* Override desktop styles if any */
    padding: 0.5rem;
    border-top: 1px solid var(--placeholder-secundary-color);
    background-color: var(--primary-color);
  }

  .typing-area {
    padding: 0.5rem 0.75rem;
  }

  .typing-form .typing-input {
    font-size: 0.95rem;
    min-height: 38px;
    padding: 0.4rem 0.75rem;
    overflow-y: auto;
    color: var(--text-color) !important;
  }

  .typing-form .disclaimer-text {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    line-height: 1.1;
  }

  /* NEW: Hide disclaimer when keyboard is likely up (input focused) */
  .typing-form:focus-within .disclaimer-text {
    display: none;
  }

  .typing-form .action-button {
    padding: 6px;
  }

  .typing-form .action-button .material-symbols-rounded {
    font-size: 1.25rem;
  }

  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    height: 100%;
    z-index: 1000;
    transition: left 0.3s ease;
    background-color: var(--secondary-hover-color);
    border-right: 1px solid var(--placeholder-secundary-color);
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
  }

  .top-bar #toggle-sidebar-btn {
    order: -1;
    margin-right: 10px;
  }

  body.mobile-view .top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 101;
    padding: 10px 15px;
    background-color: var(--primary-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .chat-list .message .text {
    font-size: 0.95rem;
  }

  .chat-list .message.incoming,
  .chat-list .message.outgoing {
    margin-top: 1rem;
  }

  .chat-list .message.incoming {
    gap: 0.75rem;
  }

  /* NEW: Hide top right actions (settings, initials) in embedded mode on mobile */
  body.embedded-mode .top-right-actions {
    display: none !important;
  }
}

/* NEW: Scroll to bottom button */
#scroll-to-bottom-btn {
  position: fixed;
  /* 'bottom' is set dynamically by JavaScript to stay above the typing area */
  right: 30px;
  z-index: 50;

  width: 45px;
  height: 45px;
  border-radius: 50%;
  background-color: var(--secondary-color);
  color: var(--text-color);
  border: 1px solid var(--placeholder-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;

  /* Visibility & Animation */
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  /* Also transition the 'bottom' property for smooth repositioning */
  transition: opacity 0.3s ease, transform 0.3s ease, bottom 0.2s ease;
}

#scroll-to-bottom-btn.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#scroll-to-bottom-btn:hover {
  background-color: var(--secondary-hover-color);
  border-color: var(--brand-color);
}
/* END: Scroll to bottom button */


.table-container {
  max-width: 90%; /* Aumentado para que sea mÃ¡s ancho y adaptable */
  overflow-x: auto;
  margin: 1em auto 1em; /* AÃ‘ADIDO: Margen superior para separar del texto, centrado horizontalmente y con margen inferior */     
  scrollbar-color: #999 transparent;
}

/* NEW: Container for table action buttons */
.table-actions-container {
  text-align: right;
  margin-top: 8px; /* Space between table and buttons */
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

table {
  width: 100%;
  border-collapse: separate;
  background-color: var(--primary-color);
  border-spacing: 0 6px;
}

th, td {
  padding: 8px;
  text-align: left;
  color: var(--text-color);
  border: none;
  font-size: 14px;
  font-weight: 400;
}

tr {
  background-color: var(--background-table-odd);
}

tr:nth-child(even) {
  background-color: var(--background-table-even);
}

tr td:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

tr td:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

th {
  background-color: var(--table-header-background);
  color: var(--text-color);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

th:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

th:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

tbody tr:hover {
  background-color: var(--secondary-hover-color);
  cursor: pointer;
}

/* Specific styles for tables within chat messages to handle overflow */
.chat-list .message .text-and-chart-wrapper  {
  display: block;
  max-width: 100%; /* Override generic max-width to fit container */

  margin-left: 0; /* Reset margin for chat context */
  margin-right: 0;
  /* NEW: Allow long words to break to prevent overflow */
  overflow-wrap: break-word;
}
.chat-list .message .text-and-chart-wrapper .table-container {
  text-align: right; /* Align the export button to the right */
}


.chat-list .message .text-and-chart-wrapper td,
.chat-list .message .text-and-chart-wrapper th {
  /* Allow content to wrap and break long words to prevent overflow */
  white-space: normal;
  word-break: break-word;
}

.conversation-title-container {
  display: flex;
  flex-grow: 1;
  align-items: center;
  /* NEW: Prevent the container from shrinking and ensure it can be centered */
  min-width: 0;
}

.conversation-title-container p {
  color: var(--text-color);
  font-size: 1rem;
  font-weight: bold;
  width: 100%;
  margin: 0;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* NEW: RCA Step Indicator Styles */
.rca-step-indicator {
  background-color: var(--brand-color);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 10px;
  white-space: nowrap;
}

/* NEW: RCA Step Indicator Styles */
.rca-step-indicator {
  background-color: var(--brand-color);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  margin-right: 10px;
  white-space: nowrap;
}

.message .suggestions-wrapper-inline {
  /* Estilo de "bocadillo" similar a la respuesta de la IA */
  background-color: var(--secondary-color);
  padding: 10px 15px;
  border-radius: 15px;
  position: relative;
  margin-top: 1rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px; /* Espacio entre el tÃ­tulo y las sugerencias */
}
/* TriÃ¡ngulo para el bocadillo de sugerencias */
.message .suggestions-wrapper-inline::before {
    content: "";
    display: none; /* Desactivado por ahora para un look mÃ¡s limpio, puedes activarlo si lo prefieres */
}

.message .suggestions-title-inline {
  width: 100%;
  font-size: 0.85em;
  color: var(--placeholder-color);
  margin-bottom: 5px;
  font-style: italic;
  font-weight: bold;
}
.chat-list .message .text-and-chart-wrapper ul ul,
.chat-list .message .text-and-chart-wrapper ol ol {
  margin-top: 0.25em;
  margin-bottom: 0.25em;
  padding-left: 25px;
}

.chat-list .message .text-and-chart-wrapper li {
  margin-bottom: 1.25em;
  margin-left: 20px;
  margin-top: 10px;
}

.chat-list .message .text-and-chart-wrapper ul ul,
.chat-list .message .text-and-chart-wrapper ol ol,
.chat-list .message .text-and-chart-wrapper ul ol,
.chat-list .message .text-and-chart-wrapper ol ul {
  margin-top: 1.25em;
  margin-bottom: 1.25em;
  padding-left: 20px;
}

.message .clickable-suggestion-inline {
  display: flex; /* Usamos flex para alinear el icono y el texto */
  align-items: center;
  gap: 10px; /* Espacio entre el icono y el texto */
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-color);
  font-size: 0.85em;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  width: 100%;
  border: 1px solid transparent; /* Borde transparente para mantener el tamaÃ±o en hover */
}

.message .clickable-suggestion-inline .suggestion-icon {
  color: var(--brand-color); /* Color morado para la lupa */
  font-size: 1.2rem;
}

.message .clickable-suggestion-inline:hover {
  background-color: var(--secondary-hover-color);
  border-color: var(--brand-color);
}


/* FIX: Correctly target the chart wrapper and ensure it has flex properties to grow */
/* This combination of styles ensures the container has a defined space for Chart.js to render into. */
.chat-list .message.incoming .text-and-chart-wrapper {
  display: flex;          /* Re-establish flex context like in the working version */
  flex-direction: column;   /* Stack chart elements vertically */
  width: 100%;            /* Take full width */
}

.message-content .text-and-chart-wrapper .text {
  width: 100%;
  word-wrap: break-word;
  margin-bottom: 1.25em;
}

.chat-list .message .text-and-chart-wrapper,
.chat-list .message .text-and-chart-wrapper p {
  color: var(--text-color);
}

.chat-list .message .text-and-chart-wrapper h2,
.chat-list .message .text-and-chart-wrapper h3,
.chat-list .message .text-and-chart-wrapper h4 {
  color: var(--text-color);
  font-weight: 600;
  margin-top: 1.5em;
  margin-bottom: 0.75em;
  padding-bottom: 0.25em;
  border-bottom: 1px solid var(--placeholder-secundary-color);
  font-size: 1.2em; /* Aumenta el tamaÃ±o para que destaque mÃ¡s */
}

.chat-list .message .text-and-chart-wrapper code {
  background-color: var(--secondary-color); /* Un fondo sutil que ya usas */
  color: var(--text-color); /* El color de texto normal */
  padding: 0.2em 0.5em;
  border-radius: 5px;
  font-size: 0.85em;
  white-space: nowrap;
  border: 1px solid var(--placeholder-secundary-color); /* Un borde ligero para definirlo */
}

.message-content .text-and-chart-wrapper .ai-chart {
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.message-content .text-and-chart-wrapper .loading-indicator {
  width: 100%;
}

.export-chart-button {
  background-color: var(--brand-color);
  color: #FFFFFF;
  border: none;
  padding: 8px 15px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 0.8em;
  margin-top: 8px;
  margin-left: 55px;
  cursor: pointer;
  border-radius: 4px;
  transition: opacity 0.3s ease;
}

.export-chart-button:hover {
  opacity: 0.8;
}

.export-table-button {
  background-color: transparent; /* Hacemos el fondo transparente */
  color: var(--text-color); /* Color del icono como el texto normal */
  border: none;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 0.8em;
  cursor: pointer;
  transition: background-color 0.3s ease, opacity 0.3s ease;
  /* NEW: Make buttons circular for icon-only display */
  border-radius: 50%;
  width: 32px;
  height: 32px;
}

.export-table-button:hover {
  background-color: var(--secondary-hover-color); /* Un fondo sutil al pasar el ratÃ³n */
  opacity: 1; /* Aseguramos opacidad completa */
}

.export-table-button.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center; /* Center the icon inside the circle */
  padding: 0; /* Remove padding */
}

/* NEW: Adjust icon size inside the smaller button */
.export-table-button.icon-button .material-symbols-rounded {
  font-size: 1.1rem;
}

/* NEW: Generic style for SVG icons inside buttons */
.icon-button .icon-svg {
  width: 22px; /* Adjust size as needed */
  height: 22px;
  /* The filter will be applied by theme-specific rules if needed */
  filter: none;
}

.light_mode .icon-button .icon-svg {
  filter: invert(1); /* Keep original color for light mode */
}


.export-table-button:disabled {
  background-color: transparent; /* Mantenemos el fondo transparente */
  opacity: 1;
  color: #4cae4c; /* El icono se pone verde */
  cursor: default;
}

/* Hide export buttons when printing or copying rich content */
@media print {
  .export-table-button,
  .export-chart-button,
  .table-actions-container {
    display: none !important;
  }
}

.message-content .text-and-chart-wrapper > div > .export-chart-button {
    margin-left: 0;
}

/* NEW: Placeholder for chart rendering */
.chart-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  width: 100%;
  background-color: var(--primary-color);
  border: 1px dashed var(--placeholder-secundary-color);
  border-radius: 8px;
  color: var(--placeholder-color);
  font-style: italic;
  margin: 10px 0;
}

/* NEW: Styles for the chart rendering error message */
.text.error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 100px;
    width: 100%;
    background-color: var(--primary-color);
    border: 1px dashed var(--error);
    border-radius: 8px;
    color: var(--error);
    font-style: italic;
    margin: 10px 0;
    padding: 1rem;
    text-align: center;
}

/* --- NEW: File Preview Modal Styles --- */
.file-preview-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  z-index: 3000; /* Extremely high z-index */
  display: none;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.file-preview-overlay.show {
  display: flex;
  opacity: 1;
}

.file-preview-modal {
  background-color: var(--secondary-color);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  width: 95%;
  height: 90%;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.file-preview-overlay.show .file-preview-modal {
  transform: scale(1);
}

.file-preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 2rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--placeholder-secundary-color);
  flex-shrink: 0;
}

.preview-filename-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 70%;
}

.preview-filename {
  color: var(--text-color);
  font-weight: 600;
  font-size: 1.1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preview-actions {
  display: flex;
  gap: 1rem;
}

.preview-actions .icon {
  color: var(--text-color);
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.2s ease;
  text-decoration: none;
}

.preview-actions .icon:hover {
  background: var(--brand-color);
  color: white;
  transform: translateY(-2px);
}

.preview-content {
  flex-grow: 1;
  overflow: auto;
  padding: 2rem;
  background-color: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-content img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.preview-content embed,
.preview-content iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: white;
  border-radius: 8px;
}

.preview-content pre {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.5rem;
  background: #1e1e1e;
  color: #d4d4d4;
  border-radius: 8px;
  font-family: 'Fira Code', 'Courier New', monospace;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow: auto;
}

.light_mode .preview-content pre {
  background: #f5f5f5;
  color: #333;
}

.top-bar {
  position: fixed;
  top: 0;
  right: 0; /* Pin to the right edge */
  color: var(--text-color);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  /* NEW: Use space-between to push menu/title and right-actions apart */
  justify-content: space-between;
  gap: 1rem; /* Add space between items */
  z-index: 1100; /* Higher than sidebar */
  /* NEW: Ensure it has a background on mobile to cover content scrolling underneath */
  background-color: var(--primary-color);
  /* NEW: Define a fixed height for mobile layout consistency */
  height: 50px;
  /* --- DESKTOP LAYOUT --- */
  left: 260px; /* Start where the sidebar ends */
  width: auto; /* Let left/right positioning define the width */
  transition: left 0.3s ease; /* Animate the left position on sidebar collapse */
}

/* NEW: Adjust top-bar when sidebar is collapsed */
body.sidebar-collapsed .top-bar {
  left: 90px; /* Match the collapsed sidebar width */
}

/* NEW: Navigation Help Icon in Top Bar */
.help-icon-wrapper.navigation-help {
  position: relative;
  top: 0;
  right: 0;
  margin-left: 5px;
  color: var(--text-secondary);
}

.help-icon-wrapper.navigation-help .material-symbols-rounded {
  font-size: 1.3rem;
}

.help-icon-wrapper.navigation-help .help-tooltip {
  top: calc(100% + 15px);
  bottom: auto;
  left: -10px; /* Expands to the right */
  right: auto;
  width: 320px;
}

.help-icon-wrapper.navigation-help .help-tooltip::after {
  top: auto;
  bottom: 100%;
  left: 20px;
  right: auto;
  border-color: transparent transparent var(--brand-color) transparent;
}

/* --- NEW: Generated File Chips --- */
.generated-files-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  padding: 5px 0;
}

.generated-file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 16px;
  background-color: var(--secondary-color);
  border: 1px solid var(--placeholder-secundary-color);
  color: var(--text-color);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  max-width: 250px;
}

.generated-file-chip:hover {
  background-color: var(--secondary-hover-color);
  border-color: var(--brand-color);
}

.generated-file-chip .material-symbols-rounded {
  font-size: 1.2rem;
  color: var(--placeholder-color);
}

.generated-file-chip .file-chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* --- NEW: Collapsible Status Steps Styles --- */
.status-steps-container {
  /* The container itself is now transparent */
  border-radius: 8px;
  margin-top: 0.75rem; /* NEW: Space between the bubble and the status steps */
  overflow: hidden;
  width: 100%; /* Take full width of the wrapper */
}

.status-steps-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px;
  cursor: pointer;
  user-select: none;
  transition: background-color 0.2s ease;
}

.status-steps-header:hover {
  background-color: var(--secondary-hover-color);
}

/* NEW: Ensure text inside the header (like .status-text) is always visible */
.status-steps-header .status-text {
    color: var(--text-color);
    font-style: normal; /* Remove italics from the header view */
    font-size: 0.95rem; /* Igualado al texto de la conversación */
}

.status-steps-header::after {
  content: 'expand_more';
  font-family: 'Material Symbols Rounded';
  margin-left: auto;
  transition: transform 0.3s ease;
}

.status-steps-container.open .status-steps-header::after {
  transform: rotate(180deg);
}

.status-steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
  background-color: var(--primary-color);
  border-top: 1px solid transparent;
}

.status-steps-container.open .status-steps-list {
  max-height: 500px; /* Allow space for the list to expand */
  padding: 10px 15px;
  border-top-color: var(--placeholder-secundary-color);
}

.status-step-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 0.95rem; /* Igualado al texto de la conversación */
  color: var(--placeholder-color);
  font-style: italic;
}

.status-step-item .status-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.status-step-item .status-icon .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--placeholder-color);
  border-top-color: var(--brand-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--placeholder-secundary-color);
  border-top-color: var(--brand-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 1rem auto;
}

.status-step-item .status-icon .material-symbols-rounded {
  font-size: 18px;
  color: var(--feedback-positive-color); /* Green checkmark */
}

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

/* --- NEW: Sources / Citations Styles --- */
.sources-container {
  margin-top: 1rem;
  border-top: 1px solid var(--placeholder-secundary-color);
  padding-top: 0.5rem;
}

.sources-toggle-btn {
  background: none;
  border: none;
  color: var(--brand-color);
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  font-weight: 500;
}

.sources-toggle-btn:hover {
  text-decoration: underline;
}

.sources-list {
  display: none; /* Hidden by default */
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.sources-list.show {
  display: flex;
}

.source-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 4px 10px;
  border-radius: 16px;
  background-color: var(--secondary-color);
  border: 1px solid var(--placeholder-secundary-color);
  color: var(--text-color);
  font-size: 0.8rem;
  text-decoration: none;
  transition: background-color 0.2s ease, border-color 0.2s ease;
  max-width: 100%;
}

.source-chip:hover {
  background-color: var(--secondary-hover-color);
  border-color: var(--brand-color);
}

.source-chip .source-icon {
  font-size: 1rem;
}

/* Error Notification above Input */
.input-error-notification {
  background-color: rgba(208, 52, 92, 0.1);
  border: 1px solid var(--error);
  color: var(--error);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  text-align: center;
  width: 100%;
  max-width: 800px;
  margin-left: auto;
  margin-right: auto;
}

/* --- FULL SCREEN SEARCH OVERLAY --- */
.search-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  animation: fadeInOverlay 0.2s ease-out;
}

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

.search-overlay-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.search-overlay-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.search-input-container {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--secondary-color);
  border-radius: 2rem;
  padding: 0.5rem 1.5rem;
  gap: 0.75rem;
  border: 1px solid transparent;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-container:focus-within {
  border-color: var(--brand-color);
  box-shadow: 0 0 0 2px rgba(152, 193, 5, 0.2);
}

.search-input-container .material-symbols-rounded {
  color: var(--placeholder-color);
}

.search-input-container input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-color);
  font-size: 1.1rem;
  padding: 0.5rem 0;
}

.search-results-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.results-section h5 {
  color: var(--brand-color);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  margin: 1.5rem 0 1rem 0.5rem;
}

.results-section ul {
  list-style: none;
  padding: 0;
}

.search-result-item {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 0.5rem;
  background: var(--input-wrapper-background);
  position: relative; /* Para posicionar la fecha respecto al item */
}

.search-result-date {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 0.75rem;
    color: var(--placeholder-color);
    font-weight: 400;
}

.search-result-item:hover {
  background: var(--secondary-color);
}

.search-result-title {
  font-weight: 500;
  color: var(--text-color);
  margin-bottom: 0.25rem;
  padding-right: 5rem; /* Space for the date */
}

.search-result-snippet {
  font-size: 0.85rem;
  color: var(--placeholder-color);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.no-results {
  text-align: center;
  margin-top: 4rem;
  color: var(--placeholder-color);
}

.search-overlay .icon-button {
  background: transparent;
  border: none;
  color: var(--text-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background 0.2s;
}

.search-overlay .icon-button:hover {
  background: var(--secondary-color);
}

/* Mobile adjustments */
@media (max-width: 1024px) {
  .search-overlay-content {
    padding: 1rem;
  }

  .search-overlay-header {
    margin-bottom: 1rem;
  }

  .search-input-container {
    padding: 0.25rem 1rem;
    border-radius: 1.5rem;
  }

  .search-input-container input {
    font-size: 1rem;
  }

  .search-result-item {
    padding: 0.75rem;
  }
}

/* --- SURGICAL FIXES FOR AGENT MODALS --- */
.agent-selector-modal {
  background-color: var(--primary-color) !important;
  border: 1px solid var(--placeholder-secundary-color) !important;
  border-radius: 1.5rem !important;
  box-shadow: 0 0 12px 0 rgba(41, 41, 61, 0.08) !important;
}

.agent-selector-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  padding: 1.25rem 2rem !important;
  border-bottom: 1px solid var(--placeholder-secundary-color) !important;
  gap: 1.5rem !important;
}

.agent-search-container {
  flex: 1 !important;
  position: relative !important;
  display: flex !important;
  align-items: center !important;
}

.agent-search-container .material-symbols-rounded {
  position: absolute !important;
  left: 1rem !important;
  color: var(--placeholder-color) !important;
  font-size: 1.25rem !important;
}

#agent-search-input {
  width: 100% !important;
  padding: 0.75rem 1rem 0.75rem 3rem !important;
  border-radius: 2rem !important;
  border: 1px solid var(--placeholder-secundary-color) !important;
  background-color: var(--secondary-color) !important;
  color: var(--text-color) !important;
  outline: none !important;
}

.agent-card {
  background-color: var(--input-wrapper-background) !important;
  border: 1px solid var(--placeholder-secundary-color) !important;
  border-radius: 1.25rem !important;
  padding: 1.5rem !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 0.75rem !important;
  min-height: 220px !important;
  cursor: pointer;
  transition: all 0.2s ease;
}

.agent-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 0.25rem;
}

.agent-card-badge {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 1rem;
  background: rgba(152, 193, 5, 0.1);
  color: var(--brand-color);
  font-weight: 700;
  text-transform: uppercase;
}

.agent-card-name {
  font-weight: 600 !important;
  font-size: 1.1rem !important;
}

.agent-card-description {
  font-size: 0.85rem !important;
  line-height: 1.5 !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 3 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  height: auto !important;
  max-height: 3.9rem !important;
  color: var(--text-secondary) !important;
}

.agent-editor-tabs {
  display: flex !important;
  padding: 0 2rem !important;
  border-bottom: 1px solid var(--placeholder-secundary-color) !important;
  gap: 1.5rem !important;
}

.agent-tab {
  padding: 1rem 0.5rem !important;
  cursor: pointer !important;
  font-weight: 600 !important;
  border: none !important;
  background: none !important;
  color: var(--placeholder-color) !important;
}

.agent-tab.active {
  color: var(--brand-color) !important;
  border-bottom: 2px solid var(--brand-color) !important;
}

.agent-form-section {
  padding: 1.5rem 1.5rem 0.75rem !important;
  border-radius: 1.25rem !important;
  border: 1px solid var(--secondary-color) !important;
  margin-bottom: 1.5rem !important;
}

.agent-editor-form label .material-symbols-rounded,
.agent-form-section-title .material-symbols-rounded {
    color: var(--placeholder-color) !important;
}

.agent-editor-form label {
  display: flex !important;
  align-items: center !important;
  gap: 0.5rem !important;
  font-size: 0.8rem !important;
  font-weight: 700 !important;
  color: var(--placeholder-color) !important;
  margin-bottom: 0.8rem !important; /* Aún más espacio */
  text-transform: uppercase !important;
}

.ai-button-wrapper {
  display: flex !important;
  justify-content: space-between !important;
  align-items: flex-end !important;
  margin-bottom: 0.4rem !important;
}

.ai-button-wrapper label { margin-bottom: 0 !important; }

.generate-ai-btn {
  background: linear-gradient(135deg, #a777e3 0%, #6e8efb 100%) !important;
  color: white !important;
  border-radius: 20px !important;
  padding: 6px 14px !important;
  font-weight: 600 !important;
  border: none !important;
  cursor: pointer !important;
}

.agent-selector-footer {
  padding: 1.25rem 2rem !important;
  border-top: 1px solid var(--placeholder-secundary-color) !important;
  display: flex !important;
  justify-content: flex-end !important;
  gap: 1rem !important;
  background: var(--primary-color) !important;
  flex-shrink: 0 !important;
}

.knowledge-base-upload-zone {
  border: 2px dashed var(--secondary-color);
  border-radius: 1rem;
  padding: 2rem;
  text-align: center;
  transition: all 0.3s ease;
  background: var(--secondary-color);
  opacity: 0.8;
}

.knowledge-base-upload-zone.drag-over {
  border-color: var(--brand-color);
  background: rgba(152, 193, 5, 0.1);
  opacity: 1;
  transform: scale(1.02);
}

/* --- AGENT MODALS MOBILE OPTIMIZATIONS --- */
@media (max-width: 1024px) {
  .agent-selector-overlay, .agent-editor-overlay {
    padding: 0 !important;
    background-color: var(--primary-color) !important;
  }

  .agent-selector-modal, .agent-editor-modal {
    width: 100% !important;
    max-width: 100% !important;
    height: 100dvh !important; /* Use dynamic viewport height for mobile */
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  .agent-selector-header, .agent-editor-header {
    padding: 1rem !important;
    gap: 0.75rem !important;
  }

  .agent-selector-header h2, .agent-editor-header h2 {
    font-size: 1.2rem !important;
  }

  .agent-card-container, .agent-editor-content {
    padding: 1rem !important;
    grid-template-columns: 1fr !important;
  }

  .agent-selector-footer {
    padding: 1rem !important;
    background: var(--primary-color) !important;
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
    gap: 0.5rem !important;
  }

  .agent-selector-footer .modal-btn {
    flex: 1;
    font-size: 0.85rem !important;
    padding: 0.75rem !important;
  }

  .agent-editor-tabs {
    padding: 0 1rem !important;
    gap: 1rem !important;
  }

  .agent-tab {
    padding: 0.75rem 0.25rem !important;
    font-size: 0.9rem !important;
  }

  /* Hide text in 'Generate with AI' button on mobile */
  .generate-ai-btn .btn-text {
    display: none !important;
  }

  .generate-ai-btn {
    padding: 8px !important;
    min-width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
  }

  /* Reduce width of notifications and dialogs on mobile */
  .input-error-notification {
    width: 90% !important;
    max-width: 90% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }

  .global-dialog-modal {
    width: 92% !important;
    max-width: 92% !important;
    padding: 1.5rem !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}


/* --- ENHANCED AGENT CARDS (BIGGER & BETTER) --- */
.agent-card {
  min-height: 220px !important; /* Más altura para evitar cortes */
  padding: 1.75rem !important;
  gap: 0.75rem !important;
}

.agent-card-container {
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)) !important; /* Tarjetas un poco más anchas */
}

.agent-card-description {
  height: auto !important;
  max-height: 6em !important; /* Espacio para hasta 4 líneas */
  -webkit-line-clamp: 4 !important; 
  line-height: 1.5 !important;
  font-size: 0.9rem !important;
}

.agent-card-name {
  font-size: 1.2rem !important; /* Nombre un poco más grande */
  margin-top: 0.25rem !important;
}

/* --- Smart Actions (Chips) Styles --- */
.smart-actions-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
    width: 100%;
}

.action-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    background-color: rgba(152, 193, 5, 0.1);
    border: 1px solid var(--brand-color);
    color: var(--brand-color);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    text-decoration: none;
}

.action-chip:hover {
    background-color: var(--brand-color);
    color: white;
    box-shadow: 0 4px 12px rgba(152, 193, 5, 0.3);
    transform: translateY(-1px);
}

.action-chip .material-symbols-rounded {
    font-size: 1.2rem;
}

/* --- Global Dialog Modal (MonoM Style) --- */
.global-dialog-modal {
    background-color: #1e1e2e; /* Fondo exacto modo oscuro MonoM */
    width: 100%;
    max-width: 600px;
    border-radius: 8px;
    padding: 2.5rem;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideUp 0.3s ease-out;
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.1); /* Borde sutil para modo oscuro */
}

.light_mode .global-dialog-modal {
    background-color: #ffffff; /* Fondo modo claro */
    color: #333333;
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.global-dialog-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: var(--placeholder-color);
    cursor: pointer;
    padding: 5px;
    display: flex;
    transition: color 0.2s;
}

.global-dialog-close:hover {
    color: #ffffff;
}

.light_mode .global-dialog-close:hover {
    color: #000000;
}

.global-dialog-content h2 {
    margin: 0 0 1.5rem 0;
    font-size: 1.75rem;
    font-weight: 500;
    color: #ffffff;
    line-height: 1.2;
}

.light_mode .global-dialog-content h2 {
    color: #1a1a1a;
}

.global-dialog-content p {
    margin: 0 0 2.5rem 0;
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
}

.light_mode .global-dialog-content p {
    color: #4a4a4a;
}

.global-dialog-footer {
    display: flex;
    justify-content: flex-end; /* Align to the right */
    align-items: center;
    width: 100%;
    gap: 1.5rem; /* Space between buttons when both are visible */
}

.dialog-btn {
    padding: 0.75rem 2.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 160px;
    text-align: center;
}

.dialog-btn-primary {
    background-color: var(--brand-color);
    color: #ffffff;
    border: none;
}

.dialog-btn-primary:hover {
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(152, 193, 5, 0.3);
}

.dialog-btn-secondary {
    background-color: transparent;
    color: var(--brand-color);
    border: 1px solid var(--brand-color);
}

.dialog-btn-secondary:hover {
    background-color: rgba(152, 193, 5, 0.1);
}


/* --- AGENT MENTION AUTOCOMPLETE --- */
.agent-mention-dropdown {
    position: absolute;
    display: none;
    z-index: 9999;
    max-height: 220px;
    width: 280px;
    overflow-y: auto;
    background-color: var(--bg-card) !important;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    font-family: inherit;
    padding: 6px;
}

.agent-mention-item {
    padding: 10px 14px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    transition: background-color 0.2s ease;
    margin-bottom: 2px;
    background-color: var(--bg-card);
}

.agent-mention-item:hover, .agent-mention-item.selected {
    background-color: var(--bg-selected) !important;
}


/* ==========================================================================
   --- KIOSK MODE PREMIUM STYLES ---
   ========================================================================== */

.kiosk-welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 3rem 2rem;
  text-align: center;
  gap: 2rem;
  max-width: 800px;
  margin: 0 auto;
  animation: kioskFadeIn 0.5s ease-out;
}

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

.kiosk-welcome-icon-wrapper {
  font-size: 5rem;
  color: var(--brand-color);
  background: rgba(152, 193, 5, 0.1);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: 0 8px 32px rgba(152, 193, 5, 0.15);
  animation: kioskPulse 3s infinite ease-in-out;
}

@keyframes kioskPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 32px rgba(152, 193, 5, 0.15); }
  50% { transform: scale(1.05); box-shadow: 0 12px 40px rgba(152, 193, 5, 0.3); }
}

.kiosk-welcome-title {
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--text-color);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0;
  /* Premium brand gradient text */
  background: linear-gradient(135deg, #ffffff 30%, var(--brand-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.light_mode .kiosk-welcome-title {
  background: linear-gradient(135deg, #000000 30%, var(--brand-color) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kiosk-welcome-subtitle {
  font-size: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 600px;
  margin: 0;
}

.kiosk-welcome-cta {
  background: var(--brand-color);
  color: #ffffff;
  border: none;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 1.25rem 3rem;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(152, 193, 5, 0.3);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.kiosk-welcome-cta:hover, .kiosk-welcome-cta:active {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 35px rgba(152, 193, 5, 0.5);
  background: #a8d400;
}

.kiosk-suggestions-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 900px;
  width: 100%;
  margin: 2rem auto;
  padding: 0 2rem;
  animation: kioskFadeIn 0.4s ease-out;
}

.kiosk-suggestions-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.kiosk-suggestions-header h2 {
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--text-color);
}

.kiosk-suggestions-header p {
  font-size: 1rem;
  color: var(--text-secondary);
}

.kiosk-suggestions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.kiosk-suggestion-card {
  background: var(--input-wrapper-background);
  border: 1px solid var(--secondary-color);
  border-radius: 1.25rem;
  padding: 1.5rem;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  position: relative;
  overflow: hidden;
  text-align: left;
}

.kiosk-suggestion-card:hover, .kiosk-suggestion-card:active {
  transform: translateY(-5px);
  background: var(--secondary-hover-color);
  border-color: var(--brand-color);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.kiosk-suggestion-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--brand-color);
  opacity: 0;
  transition: opacity 0.2s;
}

.kiosk-suggestion-card:hover::before, .kiosk-suggestion-card:active::before {
  opacity: 1;
}

.kiosk-suggestion-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 0.75rem;
  background: rgba(152, 193, 5, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-color);
  font-size: 1.25rem;
  transition: transform 0.3s;
}

.kiosk-suggestion-card:hover .kiosk-suggestion-card-icon,
.kiosk-suggestion-card:active .kiosk-suggestion-card-icon {
  transform: scale(1.1) rotate(5deg);
}

.kiosk-suggestion-card-text {
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-color);
}

/* Touch state micro-animations for tablet/touch devices */
@media (hover: none) {
  .kiosk-suggestion-card:active {
    transform: scale(0.98);
    background: var(--secondary-hover-color);
    border-color: var(--brand-color);
  }
}


/* --- FULLSCREEN IMMERSIVE KIOSK WELCOME SCREEN --- */
body.kiosk-welcome-active {
  background: radial-gradient(circle at center, #081401 0%, var(--primary-color) 100%) !important;
}

body.kiosk-welcome-active.light_mode {
  background: radial-gradient(circle at center, #f6fcf0 0%, var(--primary-color) 100%) !important;
}

body.kiosk-welcome-active .sidebar,
body.kiosk-welcome-active .top-bar,
body.kiosk-welcome-active .typing-area,
body.kiosk-welcome-active .suggestion-list {
  display: none !important;
}

body.kiosk-welcome-active .main-content {
  width: 100vw !important;
  height: 100vh !important;
  margin-left: 0 !important;
  padding: 0 !important;
  flex-direction: column !important;
}

body.kiosk-welcome-active .chat-area-wrapper {
  padding-top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  justify-content: center !important;
  align-items: center !important;
}

body.kiosk-welcome-active .chat-list {
  max-width: 100% !important;
  height: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

/* Premium full-bleed glassmorphic design overrides for welcome container */
body.kiosk-welcome-active .kiosk-welcome-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 700px;
  width: 90%;
  margin: auto !important;
  padding: 4rem 3rem !important;
  background: rgba(23, 25, 35, 0.45) !important;
  backdrop-filter: blur(25px) !important;
  -webkit-backdrop-filter: blur(25px) !important;
  border: 1px solid rgba(152, 193, 5, 0.2) !important;
  border-radius: 2rem !important;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4) !important;
  gap: 2.5rem !important;
  animation: kioskFadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

body.kiosk-welcome-active.light_mode .kiosk-welcome-container {
  background: rgba(255, 255, 255, 0.65) !important;
  border: 1px solid rgba(131, 166, 4, 0.18) !important;
  box-shadow: 0 30px 60px rgba(131, 166, 4, 0.1) !important;
}

body.kiosk-welcome-active .kiosk-welcome-icon-wrapper {
  width: 140px !important;
  height: 140px !important;
  background: radial-gradient(circle, rgba(152, 193, 5, 0.22) 0%, rgba(152, 193, 5, 0.05) 100%) !important;
  border: 1px solid rgba(152, 193, 5, 0.35) !important;
  box-shadow: 0 0 40px rgba(152, 193, 5, 0.25) !important;
  margin-bottom: 0.5rem !important;
}

body.kiosk-welcome-active .kiosk-welcome-icon-wrapper span {
  font-size: 4.5rem !important;
  background: linear-gradient(135deg, #ffffff 0%, var(--brand-color) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

body.kiosk-welcome-active.light_mode .kiosk-welcome-icon-wrapper span {
  background: linear-gradient(135deg, #2e4300 0%, var(--brand-color) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

body.kiosk-welcome-active .kiosk-welcome-title {
  font-size: 3.5rem !important;
  font-weight: 600 !important;
  letter-spacing: -0.03em !important;
  margin: 0 !important;
  background: linear-gradient(135deg, #ffffff 20%, var(--brand-color) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  line-height: 1.1 !important;
}

body.kiosk-welcome-active.light_mode .kiosk-welcome-title {
  background: linear-gradient(135deg, #1f1f2e 20%, var(--brand-color) 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

body.kiosk-welcome-active .kiosk-welcome-subtitle {
  font-size: 1.4rem !important;
  color: var(--text-secondary) !important;
  line-height: 1.5 !important;
  font-weight: 300 !important;
  max-width: 500px !important;
  margin: -1rem 0 0.5rem 0 !important;
}

body.kiosk-welcome-active .kiosk-welcome-cta {
  font-size: 1.35rem !important;
  padding: 1.25rem 4rem !important;
  border-radius: 50px !important;
  font-weight: 600 !important;
  letter-spacing: 0.02em !important;
  background: linear-gradient(135deg, var(--brand-color) 0%, #a0c52b 100%) !important;
  box-shadow: 0 10px 30px rgba(152, 193, 5, 0.4) !important;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

body.kiosk-welcome-active .kiosk-welcome-cta:hover,
body.kiosk-welcome-active .kiosk-welcome-cta:active {
  transform: translateY(-4px) scale(1.03) !important;
  box-shadow: 0 15px 40px rgba(152, 193, 5, 0.6) !important;
  background: linear-gradient(135deg, #d9ff66 0%, var(--brand-color) 100%) !important;
}

/* Kiosk Brand Logo Styles */
.kiosk-welcome-logo-wrapper {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  margin-bottom: 2rem !important;
  width: 100% !important;
}

.kiosk-welcome-logo {
  max-width: 320px !important;
  height: auto !important;
  object-fit: contain !important;
  filter: drop-shadow(0 0 12px rgba(152, 193, 5, 0.25)) !important;
  opacity: 0.95 !important;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

.kiosk-welcome-logo:hover {
  transform: scale(1.03) !important;
  filter: drop-shadow(0 0 20px rgba(152, 193, 5, 0.5)) !important;
  opacity: 1 !important;
}

/* ========================================== */
/* RICH VISUAL RCA FLOWCHART DESIGN SYSTEMS   */
/* ========================================== */

.rca-flow {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
  margin: 20px 0 !important;
  width: 100% !important;
  max-width: 780px !important;
  animation: rcaFadeIn 0.5s ease-out !important;
}

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

.rca-step {
  display: flex !important;
  align-items: center !important;
  gap: 14px !important;
  background: var(--secondary-color, #1f2226) !important;
  border-left: 6px solid var(--brand-color, #98C105) !important;
  border-radius: 12px !important;
  padding: 14px 18px !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2) !important;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
  border: 1px solid rgba(255, 255, 255, 0.03) !important;
}

.rca-step:hover {
  transform: translateY(-3px) scale(1.01) !important;
  box-shadow: 0 10px 25px rgba(152, 193, 5, 0.15) !important;
}

.rca-step.rca-problem {
  border-left-color: #ff4d4d !important; /* Red for the initial Problem/Effect */
  background: linear-gradient(90deg, rgba(255, 77, 77, 0.08) 0%, var(--secondary-color, #1f2226) 100%) !important;
  border: 1px solid rgba(255, 77, 77, 0.1) !important;
}

.rca-step.rca-problem:hover {
  box-shadow: 0 10px 25px rgba(255, 77, 77, 0.2) !important;
}

.rca-step.rca-cause {
  border-left-color: #ff9f43 !important; /* Orange/Yellow for Intermediate Causes */
  background: linear-gradient(90deg, rgba(255, 159, 67, 0.04) 0%, var(--secondary-color, #1f2226) 100%) !important;
}

.rca-step.rca-cause:hover {
  box-shadow: 0 10px 25px rgba(255, 159, 67, 0.15) !important;
}

.rca-step.rca-root-cause {
  border-left-color: #2eb872 !important; /* Emerald Green for Root Cause */
  background: linear-gradient(90deg, rgba(46, 184, 114, 0.12) 0%, var(--secondary-color, #1f2226) 100%) !important;
  border: 1px solid rgba(46, 184, 114, 0.2) !important;
}

.rca-step.rca-root-cause:hover {
  box-shadow: 0 12px 30px rgba(46, 184, 114, 0.3) !important;
}

.rca-icon {
  font-size: 1.6rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 38px !important;
  height: 38px !important;
  background: rgba(255, 255, 255, 0.05) !important;
  border-radius: 50% !important;
  box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.05) !important;
}

.rca-step.rca-problem .rca-icon {
  background: rgba(255, 77, 77, 0.1) !important;
}

.rca-step.rca-root-cause .rca-icon {
  background: rgba(46, 184, 114, 0.15) !important;
}

.rca-step-content {
  color: var(--text-color, #ffffff) !important;
  font-size: 0.95rem !important;
  line-height: 1.5 !important;
  flex-grow: 1 !important;
}

.rca-step-content strong {
  font-weight: 700 !important;
  margin-right: 6px !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  font-size: 0.85rem !important;
}

.rca-step.rca-problem .rca-step-content strong {
  color: #ff4d4d !important;
}

.rca-step.rca-cause .rca-step-content strong {
  color: #ff9f43 !important;
}

.rca-step.rca-root-cause .rca-step-content strong {
  color: #2eb872 !important;
}

.rca-arrow {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  gap: 8px !important;
  color: var(--placeholder-color, #888) !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  font-style: italic !important;
  margin: 4px 0 4px 40px !important; /* Align arrow beautifully with the cards */
  animation: rcaArrowBounce 2s infinite !important;
}

@keyframes rcaArrowBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}



