/*
 * assets/css/style.css
 * Version: 7.1 - Ajustes de espaciado y mejoras de UI.
 */

/* --- PALETA CORPORATIVA MEDICAL PC --- */
:root {
  /* Marca (rojo) */
  --c-primary-dark:    #A10000;  /* rojo profundo (bordes/sombras) */
  --c-primary:         #E10600;  /* rojo marca */
  --c-primary-light:   #FF6B6B;  /* rojo claro para hovers/gradientes */
  --c-user-bubble:     #E10600;

  /* Fondos / superficies */
  --c-background:      #E6E6E6;  /* gris claro del lienzo */
  --c-surface:         #FFFFFF;  /* tarjetas/inputs */
  --c-bot-bubble:      #F3F3F3;  /* burbuja bot gris clara */

  /* Tipografías */
  --c-text-primary:    #111111;  /* negro principal */
  --c-text-secondary:  #5A5A5A;  /* gris texto secundario */
  --c-text-inverse:    #FFFFFF;

  /* Bordes / sombras */
  --c-border:          #D9D9D9;
  --c-shadow:          rgba(0, 0, 0, 0.08);

  /* Tipos y escalas (sin cambios) */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-family-code: 'Fira Code', Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
  --fs-base: clamp(14px, 1.5vw, 16px);
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-bold: 700;
  --spacing-unit: 8px;
  --header-height: 65px;
  --input-area-height: 70px;
  --footer-bar-height: 30px;
  --max-width: 960px;
  --container-padding: calc(var(--spacing-unit) * 3);
  --radius-sm: 8px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-tail: 4px;
  --shadow-sm: 0 1px 3px var(--c-shadow);
  --shadow-md: 0 4px 10px var(--c-shadow);
  --shadow-lg: 0 8px 24px var(--c-shadow);
  --transition-fast: 150ms ease-in-out;
  --transition-normal: 250ms ease-in-out;
}

/* Modo oscuro con la misma identidad de marca */
@media (prefers-color-scheme: dark) {
  :root {
    --c-primary-dark:    #7A0000;
    --c-primary:         #A10000;
    --c-primary-light:   #FF6B6B;
    --c-user-bubble:     #A10000;

    --c-background:      #111111;
    --c-surface:         #1A1A1A;
    --c-bot-bubble:      #262626;

    --c-text-primary:    #ECECEC;
    --c-text-secondary:  #B0B0B0;
    --c-text-inverse:    #FFFFFF;

    --c-border:          #303030;
    --c-shadow:          rgba(0, 0, 0, 0.30);
  }
}

/* Reset básico */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
html { font-size: 100%; }
body { background: var(--c-primary-dark); font-family: var(--font-family); color: var(--c-text-primary); display: flex; justify-content: center; align-items: center; height: 100vh; padding: var(--spacing-unit); }

/* Estructura principal */
.chat-app { width: 100%; max-width: var(--max-width); height: 100%; max-height: calc(100vh - (var(--spacing-unit) * 4)); background: var(--c-background); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; }
.chat-app__header { height: var(--header-height); background: var(--c-primary); color: var(--c-text-inverse); display: flex; align-items: center; justify-content: space-between; padding: 0 var(--container-padding); font-size: calc(var(--fs-base) + 2px); font-weight: var(--fw-bold); border-bottom: 1px solid var(--c-border); flex-shrink: 0; z-index: 10; }
.chat-app__window { flex: 1; padding: var(--container-padding); overflow-y: auto; background: var(--c-background); }
.chat-app__window::-webkit-scrollbar { width: 8px; }
.chat-app__window::-webkit-scrollbar-track { background: transparent; }
.chat-app__window::-webkit-scrollbar-thumb { background: var(--c-text-secondary); border-radius: 4px; }
.chat-app__window::-webkit-scrollbar-thumb:hover { background: var(--c-primary-light); }
.header__title i { margin-right: calc(var(--spacing-unit) * 1.5); vertical-align: -2px; }
.header__btn { color: var(--c-text-inverse); background: transparent; }
.header__btn:hover { background: rgba(255, 255, 255, 0.1); }

/* Mensajes */
.messages { display: flex; flex-direction: column; gap: var(--spacing-unit); }
.messages .message:first-child { margin-top: 0; }

@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.message { display: flex; align-items: flex-end; max-width: 80%; animation: slideIn 300ms ease-out; gap: var(--spacing-unit); margin-top: calc(var(--spacing-unit) * 2); }
.message--user { align-self: flex-end; flex-direction: row-reverse; }
.message--bot { align-self: flex-start; }
.message.is-grouped .message__avatar { visibility: hidden; }
.message.is-grouped { margin-top: 0; }

.message__avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; color: var(--c-text-inverse); box-shadow: var(--shadow-sm); }
.message--bot .message__avatar { background: var(--c-primary); }
.message--user .message__avatar { background: var(--c-primary-light); }

.message__bubble { position: relative; padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 2); font-size: var(--fs-base); line-height: 1.6; word-wrap: break-word; white-space: pre-wrap; flex-grow: 1; }
.message--bot .message__bubble { background: var(--c-bot-bubble); color: var(--c-text-primary); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-tail); }
.message--user .message__bubble { background: linear-gradient(135deg, var(--c-primary-light), var(--c-user-bubble)); color: var(--c-text-inverse); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-tail) var(--radius-lg); }

.message--thinking .message__bubble { font-style: italic; color: var(--c-text-secondary); }
@keyframes blink { 50% { opacity: 0; } }
.typing-cursor { display: inline-block; width: 8px; height: 1.2em; background-color: var(--c-text-secondary); animation: blink 1s step-end infinite; vertical-align: -2px; }

.message__actions { position: absolute; top: 4px; right: 4px; opacity: 0; transition: opacity var(--transition-fast); }
.message__bubble:hover .message__actions { opacity: 1; }
.copy-btn { background: rgba(0,0,0,0.1); border: none; border-radius: 50%; width: 32px; height: 32px; color: var(--c-text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 14px; }
.copy-btn:hover { background: rgba(0,0,0,0.2); }
.message--user .copy-btn { background: rgba(255,255,255,0.15); color: var(--c-text-inverse); }
.message--user .copy-btn:hover { background: rgba(255,255,255,0.3); }

/* Tablas dentro de burbuja */
.message__bubble .table-container { overflow-x: auto; margin: var(--spacing-unit) 0; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); border: 1px solid var(--c-border); }
.message__bubble table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: calc(var(--fs-base) - 1px); }
.message__bubble th, .message__bubble td { padding: calc(var(--spacing-unit) * 1.5); text-align: left; vertical-align: top; border-bottom: 1px solid var(--c-border); }
.message__bubble tr:last-child td { border-bottom: none; }
.message__bubble th { font-weight: var(--fw-bold); background-color: var(--c-surface); border-bottom-width: 2px; }

/* Input */
.chat-app__bottom-bar { flex-shrink: 0; z-index: 10; box-shadow: 0 -2px 10px rgba(0,0,0,0.05); }
.chat-app__input-area { min-height: var(--input-area-height); display: flex; align-items: center; padding: var(--spacing-unit) var(--container-padding); background: var(--c-surface); border-top: 1px solid var(--c-border); gap: var(--spacing-unit); }
.chat-input { flex: 1; display: flex; align-items: center; background: var(--c-background); border-radius: var(--radius-lg); padding: 0 calc(var(--spacing-unit) * 2); box-shadow: var(--shadow-sm); transition: box-shadow var(--transition-fast); }
.chat-input:focus-within { box-shadow: 0 0 0 2px var(--c-primary-light); }
.chat-input__field { flex: 1; min-height: 44px; border: none; background: transparent; outline: none; font-size: var(--fs-base); color: var(--c-text-primary); font-family: inherit; }
.chat-input__field::placeholder { color: var(--c-text-secondary); opacity: 1; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--c-text-secondary); font-size: 20px; cursor: pointer; flex-shrink: 0; transition: all var(--transition-fast); }
.icon-btn:hover, .icon-btn:focus-visible { background-color: var(--c-primary-light); color: var(--c-text-inverse); transform: scale(1.1); outline: none; }
.icon-btn:active { transform: scale(0.95); }
.fa-microphone.recording { color: var(--c-system-error); transform: scale(1.2); }
.chat-app__footer { height: var(--footer-bar-height); background: var(--c-primary); color: var(--c-text-inverse); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: var(--fw-medium); opacity: 0.9; }

@media (max-width: 600px) {
  body { padding: 0; }
  .chat-app { height: 100vh; max-height: 100vh; border-radius: 0; }
  .chat-app__header { position: sticky; top: 0; }
  .chat-app__bottom-bar { position: sticky; bottom: 0; }
  .message { max-width: 90%; }
  .header__title { font-size: 16px; margin-right: 0; text-align: left; }
  .header__btn { position: absolute; right: 10px; }
  .message__actions { opacity: 0.5; }
}
