/* =========================================================
   Auditel Institucional · Basado en SIFEET Estatales
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;500;600;700&family=Source+Serif+4:wght@400;600;700&display=swap');

:root {
  --color-ink: #1f2937;
  --color-accent: #1f3b2c;
  --color-accent-soft: #e6efe9;
  --color-gold: #c8a048;
  --color-bg: #f4f5f2;
  --color-surface: #ffffff;
  --color-border: #d7ded7;
  --color-muted: #5f6b63;
  --color-shadow: rgba(15, 23, 42, 0.08);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --font-sans: "Source Sans 3", "Segoe UI", sans-serif;
  --font-serif: "Source Serif 4", "Times New Roman", serif;
  --transition: 0.25s ease;
}

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

body {
  font-family: var(--font-sans);
  color: var(--color-ink);
  background:
    radial-gradient(circle at top right, rgba(200, 160, 72, 0.12), transparent 55%),
    radial-gradient(circle at 10% 20%, rgba(31, 59, 44, 0.08), transparent 45%),
    var(--color-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(10px);
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 1rem;
  align-items: center;
}

.ofs-logo {
  width: 58px;
  height: auto;
}

.header-text h1 {
  font-family: var(--font-serif);
  font-size: 1.7rem;
  line-height: 1.1;
  color: var(--color-accent);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12rem;
  font-size: 0.68rem;
  color: var(--color-muted);
  font-weight: 700;
}

.subtitle {
  color: var(--color-muted);
  font-size: 0.86rem;
  margin-top: 0.2rem;
}

.header-badge {
  background: var(--color-accent-soft);
  border: 1px solid rgba(31, 59, 44, 0.2);
  color: var(--color-accent);
  padding: 0.7rem 1rem;
  border-radius: 999px;
  min-width: 140px;
  text-align: center;
}

.header-badge span {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.08rem;
  text-transform: uppercase;
}

.header-badge strong {
  font-size: 0.95rem;
}

.main-container {
  width: min(1240px, calc(100% - 2rem));
  margin: 1.25rem auto;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid var(--color-border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  min-height: calc(100vh - 190px);
}

.sidebar {
  width: 300px;
  background: #f8fbf8;
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-header h2 {
  font-family: var(--font-serif);
  color: var(--color-accent);
  font-size: 1.4rem;
}

.sidebar-subtitle {
  color: var(--color-muted);
  font-size: 0.85rem;
}

.sidebar-section {
  padding: 1rem 0;
  border-bottom: 1px solid var(--color-border);
}

.sidebar-section h3 {
  margin: 0 1rem 0.75rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08rem;
  color: var(--color-muted);
}

.sidebar-button {
  width: calc(100% - 1rem);
  margin: 0.3rem 0.5rem;
  border: 1px solid transparent;
  border-radius: 11px;
  background: transparent;
  color: var(--color-ink);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.sidebar-button:hover {
  background: #eff5ef;
  border-color: #d9e4d9;
}

.sidebar-button.active {
  background: var(--color-accent-soft);
  border-color: rgba(31, 59, 44, 0.24);
  color: var(--color-accent);
  font-weight: 600;
}

.button-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #e5ece6;
  color: var(--color-accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02rem;
}

.badge {
  margin-left: auto;
  background: #f6ead1;
  color: #8a6730;
  border-radius: 999px;
  font-size: 0.67rem;
  padding: 0.15rem 0.5rem;
}

.database-info {
  margin: 0.45rem 0.8rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 11px;
  background: #fff;
}

.db-header {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.db-name {
  font-weight: 700;
  color: var(--color-accent);
}

.db-records {
  font-size: 0.8rem;
  color: #2c6a4c;
  font-weight: 600;
}

.db-desc {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--color-muted);
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-muted);
  font-size: 0.85rem;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #27a256;
}

.version {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.72);
}

.top-bar-left h1 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--color-accent);
}

.top-bar-subtitle {
  font-size: 0.9rem;
  color: var(--color-muted);
  margin-top: 0.15rem;
}

.clear-button,
.send-button,
.btn-secondary,
.btn-primary {
  border: 1px solid rgba(31, 59, 44, 0.28);
  background: #f5f8f5;
  color: var(--color-accent);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  font-family: inherit;
}

.clear-button:hover,
.send-button:hover,
.btn-secondary:hover,
.btn-primary:hover {
  background: var(--color-accent-soft);
  border-color: rgba(31, 59, 44, 0.4);
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.disclaimer-message {
  background: #fff8e8;
  border: 1px solid #ecd8a2;
  color: #6f5a2b;
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.chat-message {
  max-width: min(86%, 820px);
  border-radius: 14px;
  border: 1px solid var(--color-border);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-soft);
}

.chat-message.user {
  margin-left: auto;
  background: #f7faf7;
}

.chat-message.bot {
  margin-right: auto;
  background: #ffffff;
}

.message-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
}

.message-sender {
  font-weight: 700;
  color: var(--color-accent);
}

.message-time {
  margin-left: auto;
  color: var(--color-muted);
  font-size: 0.75rem;
}

.message-content {
  font-size: 0.95rem;
}

.message-content p,
.message-content ul,
.message-content ol {
  margin: 0.5rem 0;
}

.message-content code {
  background: #eef3ee;
  border: 1px solid #d8e2d8;
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
}

.message-content pre {
  overflow-x: auto;
  background: #f7f9f7;
  border: 1px solid var(--color-border);
  border-radius: 9px;
  padding: 0.75rem;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  color: var(--color-accent);
  font-family: var(--font-serif);
  margin: 0.7rem 0 0.35rem;
}

.message-context {
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px dashed #d9e2d9;
  color: var(--color-muted);
  font-size: 0.78rem;
}

.selection-buttons {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.5rem;
}

.selection-buttons button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fbfcfb;
  color: var(--color-accent);
  padding: 0.65rem 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.selection-buttons button:hover {
  border-color: rgba(31, 59, 44, 0.45);
  background: var(--color-accent-soft);
}

.welcome-message {
  border: 1px dashed #cad8cb;
  background: #fafcfa;
  border-radius: 14px;
  padding: 1.15rem;
}

.welcome-header h3 {
  font-family: var(--font-serif);
  color: var(--color-accent);
}

.welcome-header p {
  color: var(--color-muted);
  margin-top: 0.3rem;
}

.welcome-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.65rem;
  margin-top: 0.9rem;
}

.feature-card {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #fff;
  padding: 0.75rem;
  display: flex;
  gap: 0.55rem;
}

.feature-icon {
  font-size: 1rem;
}

.feature-text strong {
  color: var(--color-accent);
  display: block;
}

.feature-text span {
  font-size: 0.86rem;
  color: var(--color-muted);
}

.welcome-stats {
  margin-top: 0.85rem;
  display: flex;
  gap: 1.25rem;
}

.stat strong {
  display: block;
  color: var(--color-accent);
}

.stat span {
  font-size: 0.82rem;
  color: var(--color-muted);
}

.input-area {
  border-top: 1px solid var(--color-border);
  background: #fff;
  padding: 1rem 1.2rem 1.15rem;
}

.institutional-form-head {
  background: #f7f9f7;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.75rem;
}

.institutional-form-head h3 {
  font-family: var(--font-serif);
  font-size: 1.03rem;
  color: var(--color-accent);
}

.institutional-form-head p {
  margin-top: 0.2rem;
  color: var(--color-muted);
  font-size: 0.86rem;
}

.ask-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.input-wrapper {
  display: flex;
  gap: 0.6rem;
  align-items: flex-end;
}

.input-wrapper textarea {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.75rem 0.85rem;
  font-size: 0.95rem;
  font-family: var(--font-sans);
  background: #fbfcfb;
  resize: none;
  min-height: 56px;
  max-height: 120px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrapper textarea:focus {
  outline: none;
  border-color: rgba(31, 59, 44, 0.55);
  box-shadow: 0 0 0 3px rgba(31, 59, 44, 0.12);
}

.send-button {
  min-width: 46px;
  height: 46px;
  border-radius: 12px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.send-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.ai-indicator,
.input-hints {
  color: var(--color-muted);
  font-size: 0.8rem;
}

.ai-badge {
  color: #2b6b4b;
  font-weight: 700;
  margin-right: 0.35rem;
}

.input-hints {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.character-counter {
  text-align: right;
  font-size: 0.76rem;
  color: var(--color-muted);
  margin-top: 0.25rem;
}

.validation-error,
.error-message {
  background: #fff0f0;
  border: 1px solid #f2c7c7;
  color: #8a3030;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.loading-message {
  background: #f2f7f2;
  border: 1px solid #d6e5d7;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
}

.loading-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #d0dfd1;
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  display: inline-block;
  margin-right: 0.45rem;
}

.internet-search {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: #f8fbf8;
}

.search-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.5rem;
}

.search-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  color: var(--color-accent);
  text-decoration: none;
  background: #fff;
}

.search-link:hover {
  background: var(--color-accent-soft);
}

.search-note {
  margin-top: 0.55rem;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.inactivity-warning,
.detection-badge,
.context-info {
  background: #f7f9f7;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
}

.coming-features {
  margin-top: 0.5rem;
}

.feature-item {
  color: var(--color-muted);
  font-size: 0.88rem;
}

.site-footer {
  text-align: center;
  color: var(--color-muted);
  font-size: 0.8rem;
  padding: 0.75rem 1rem 1rem;
}

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

@media (max-width: 1080px) {
  .main-container {
    width: calc(100% - 1rem);
    margin: 0.8rem auto;
    min-height: calc(100vh - 170px);
  }

  .sidebar {
    width: 265px;
  }

  .top-bar-left h1 {
    font-size: 1.18rem;
  }
}

@media (max-width: 900px) {
  .header-inner {
    grid-template-columns: auto 1fr;
  }

  .header-badge {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .main-container {
    flex-direction: column;
    min-height: auto;
  }

  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .chat-message {
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .header-inner {
    padding: 0.85rem;
    gap: 0.7rem;
  }

  .ofs-logo {
    width: 46px;
  }

  .header-text h1 {
    font-size: 1.28rem;
  }

  .main-container {
    width: calc(100% - 0.5rem);
    border-radius: 12px;
  }

  .top-bar,
  .chat-box,
  .input-area {
    padding-left: 0.8rem;
    padding-right: 0.8rem;
  }

  .input-wrapper {
    flex-direction: column;
    align-items: stretch;
  }

  .send-button {
    width: 100%;
    height: 42px;
  }
}
