/* =========================================================================
   ESTILOS GENERALES Y SISTEMA DE DISEÑO: AGENTE MEMORIA MALVINAS
   ========================================================================= */

:root {
  --bg-deep: #070d18;
  --bg-card: rgba(15, 23, 42, 0.85);
  --bg-card-header: rgba(30, 41, 59, 0.7);
  --border-color: rgba(255, 255, 255, 0.1);
  --border-highlight: rgba(56, 189, 248, 0.35);

  --sky-blue: #38bdf8;
  --sky-blue-hover: #0ea5e9;
  --sky-blue-subtle: rgba(56, 189, 248, 0.12);
  --argentina-sun: #fbbf24;
  --argentina-white: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --user-bubble: #1e3a8a;
  --assistant-bubble: #1e293b;

  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --font-heading: 'Cinzel', serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.6);
}

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

body.malvinas-theme {
  background: radial-gradient(circle at 50% 0%, #0e1e38 0%, #070d18 75%);
  color: var(--argentina-white);
  font-family: var(--font-sans);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* =========================================================================
   BARRA SUPERIOR INSTITUCIONAL
   ========================================================================= */

.main-header {
  background: rgba(10, 19, 36, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.flag-symbol {
  width: 44px;
  height: 30px;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.2);
}

.flag-stripe {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flag-stripe.sky {
  background: #75aadb;
}

.flag-stripe.white {
  background: #ffffff;
}

.sun-icon {
  font-size: 8px;
  line-height: 1;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--argentina-white);
  line-height: 1.1;
}

.brand-subtitle {
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--sky-blue);
  font-weight: 600;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.status-pill.connected {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.3);
}

.status-pill.local {
  background: rgba(56, 189, 248, 0.12);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.25);
}

.pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 6px currentColor;
  animation: pulse-dot 2s infinite ease-in-out;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* =========================================================================
   BOTONES
   ========================================================================= */

.btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn-primary {
  background: var(--sky-blue);
  color: #070d18;
}

.btn-primary:hover {
  background: var(--sky-blue-hover);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #334155;
  color: var(--argentina-white);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-outline-light {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--argentina-white);
}

.btn-outline-light:hover {
  border-color: var(--sky-blue);
  background: var(--sky-blue-subtle);
  color: var(--sky-blue);
}

.btn-outline-danger {
  background: transparent;
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.btn-outline-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--danger);
  color: #f87171;
}

/* =========================================================================
   LAYOUT PRINCIPAL
   ========================================================================= */

.app-container {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.main-content-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
}

/* =========================================================================
   SECCIÓN DE CHAT
   ========================================================================= */

.chat-section {
  display: flex;
  flex-direction: column;
}

.chat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  overflow: hidden;
}

.chat-card-header {
  padding: 1rem 1.5rem;
  background: var(--bg-card-header);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agent-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.agent-avatar {
  width: 38px;
  height: 38px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid var(--border-highlight);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.agent-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--argentina-white);
}

.agent-status-label {
  font-size: 0.72rem;
  color: var(--sky-blue);
  display: block;
}

.session-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mono-code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* LISTA DE MENSAJES */
.chat-messages-container {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.message-row {
  display: flex;
  gap: 0.75rem;
  max-width: 85%;
  animation: fadeIn 0.25s ease-out;
}

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

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

.message-row.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  background: #1e293b;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.message-bubble {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  line-height: 1.6;
}

.message-row.assistant .message-bubble {
  background: var(--assistant-bubble);
  border: 1px solid var(--border-color);
  color: #e2e8f0;
  border-top-left-radius: 2px;
}

.message-row.user .message-bubble {
  background: var(--user-bubble);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #ffffff;
  border-top-right-radius: 2px;
}

.message-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.message-row.user .message-meta {
  color: #93c5fd;
}

.sender-name {
  font-weight: 600;
}

/* SUGERENCIAS RÁPIDAS */
.quick-prompts-bar {
  padding: 0.6rem 1.5rem;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
}

.quick-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 9999px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.quick-btn:hover {
  background: var(--sky-blue-subtle);
  border-color: var(--sky-blue);
  color: var(--sky-blue);
}

/* COMPOSITOR */
.chat-composer-form {
  padding: 1rem 1.5rem;
  background: var(--bg-card-header);
  border-top: 1px solid var(--border-color);
}

.composer-wrapper {
  display: flex;
  gap: 0.75rem;
}

.chat-input {
  flex: 1;
  background: rgba(7, 13, 24, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  color: var(--argentina-white);
  font-family: var(--font-sans);
  font-size: 0.92rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-input:focus {
  border-color: var(--sky-blue);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15);
}

.composer-footnote {
  font-size: 0.72rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
  text-align: center;
}

/* =========================================================================
   BARRA LATERAL Y TARJETAS
   ========================================================================= */

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.side-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-card);
}

.side-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.6rem;
  margin-bottom: 0.75rem;
}

.side-card-header h3 {
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--argentina-white);
}

.badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
}

.badge-sky {
  background: var(--sky-blue-subtle);
  color: var(--sky-blue);
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-success {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

.witness-summary p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.witness-summary strong {
  color: #e2e8f0;
}

/* TARJETA GOOGLE SHEETS */
.sheets-card {
  border-color: var(--border-highlight);
}

.btn-refresh {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--sky-blue);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-refresh:hover {
  background: var(--sky-blue-subtle);
  transform: rotate(180deg);
}

.sheets-info-box {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.78rem;
  background: rgba(0, 0, 0, 0.3);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.6rem;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.info-label {
  color: var(--text-dim);
}

.info-val {
  color: #e2e8f0;
  font-weight: 500;
}

.sheets-note {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-style: italic;
}

/* EVENTOS GEORREFERENCIADOS */
.events-scroll-container {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding-right: 0.25rem;
}

.event-card {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  transition: border-color 0.2s ease;
}

.event-card:hover {
  border-color: var(--sky-blue);
}

.event-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.3rem;
}

.event-place {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--sky-blue);
}

.event-date {
  font-size: 0.72rem;
  color: var(--argentina-sun);
  font-weight: 600;
}

.event-coords {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.event-units {
  font-size: 0.75rem;
  color: #cbd5e1;
  margin-bottom: 0.35rem;
}

.event-quote {
  font-size: 0.75rem;
  color: #94a3b8;
  font-style: italic;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.35rem 0.5rem;
  border-left: 2px solid var(--sky-blue);
  border-radius: 2px;
  margin-bottom: 0.4rem;
}

.event-status-footer {
  display: flex;
  justify-content: flex-end;
}

.no-events-placeholder {
  font-size: 0.78rem;
  color: var(--text-dim);
  text-align: center;
  padding: 1.5rem 0.5rem;
  line-height: 1.5;
}

/* =========================================================================
   MODAL DE PERFIL
   ========================================================================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0,0,0,0.8);
  overflow: hidden;
}

.modal-header {
  padding: 1.15rem 1.5rem;
  background: #1e293b;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

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

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.form-input, .form-select {
  background: #070d18;
  border: 1px solid var(--border-color);
  color: var(--argentina-white);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
}

.form-input:focus, .form-select:focus {
  border-color: var(--sky-blue);
}

.form-group-checkbox label {
  font-size: 0.78rem;
  color: #cbd5e1;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  cursor: pointer;
}

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

/* =========================================================================
   RESPONSIVIDAD
   ========================================================================= */

@media (max-width: 1024px) {
  .main-content-grid {
    grid-template-columns: 1fr;
    padding: 1rem;
  }
  .chat-card {
    height: 600px;
  }
}
