:root {
  --bg-deep: #060B18;
  --bg-card: #0D1626;
  --bg-glass: rgba(255,255,255,0.04);
  --border: rgba(255,255,255,0.07);
  --brand: #1E40AF;
  --brand-light: #3B82F6;
  --gold: #F59E0B;
  --gold-light: #FCD34D;
  --text: #F1F5F9;
  --text-muted: #64748B;
  --success: #10B981;
  --danger: #EF4444;
  --shadow-glow: 0 4px 20px rgba(59, 130, 246, 0.15);
}

.light {
  --bg-deep: #F8FAFC;
  --bg-card: #FFFFFF;
  --bg-glass: rgba(255,255,255,0.7);
  --border: rgba(0,0,0,0.1);
  --text: #0F172A;
  --text-muted: #475569;
  --shadow-glow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-deep);
  color: var(--text);
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
  overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-deep);
}
::-webkit-scrollbar-thumb {
  background: var(--brand);
  border-radius: 4px;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.text-center { text-align: center; }
.hidden { display: none !important; }

/* Typography */
.gradient-text {
  background: linear-gradient(135deg, var(--brand-light), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.huge-title {
  font-size: 3.5rem;
  font-weight: 700;
  margin-bottom: 1rem;
  line-height: 1.2;
}

.subtitle {
  font-size: 1.2rem;
  color: var(--text-muted);
  max-width: 800px;
  margin: 0 auto 3rem;
}

/* Header */
.glass-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

.header-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.logo {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.main-nav ul {
  list-style: none;
  display: flex;
  gap: 1.5rem;
}

.main-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  position: relative;
}

.main-nav a:hover, .main-nav a.active {
  color: var(--text);
}

.main-nav a.active::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 0;
  width: 100%;
  height: 2px;
  background: var(--brand-light);
  border-radius: 2px;
}

/* Hero */
.hero {
  padding: 5rem 0 3rem;
}

.stats-container {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-top: 3rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem 2rem;
  min-width: 200px;
  box-shadow: var(--shadow-glow);
  position: relative;
}
.stat-card h3 {
  font-size: 2.5rem;
  color: var(--brand-light);
  margin-bottom: 0.5rem;
}
.stat-card p {
  color: var(--text-muted);
  font-weight: 500;
}

/* Global Search */
.global-search {
  margin: -2rem auto 4rem;
  position: relative;
  z-index: 10;
}

.glass-panel {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  box-shadow: var(--shadow-glow);
}

.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
}

.form-group {
  position: relative;
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 1rem;
  pointer-events: none;
}

input[type="text"], select {
  width: 100%;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0.75rem 1rem 0.75rem 2.5rem;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.3s ease;
}

input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--brand-light);
}

.primary-btn, .secondary-btn, .icon-btn {
  font-family: inherit;
  cursor: pointer;
  border-radius: 8px;
  font-weight: 600;
  transition: all 0.3s ease;
}

.primary-btn {
  background: var(--brand);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
}
.primary-btn:hover {
  background: var(--brand-light);
  transform: translateY(-2px);
}
.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.secondary-btn {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.secondary-btn:hover {
  background: var(--bg-glass);
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 1.25rem;
  padding: 0.5rem;
  color: var(--text);
}

.form-actions {
  display: flex;
  gap: 0.5rem;
}

/* Sections */
.content-section {
  padding: 4rem 0;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.content-section.visible {
  opacity: 1;
  transform: translateY(0);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-size: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Results Grid */
.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.result-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
}

.result-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 12px;
  padding: 2px;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.result-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.4;
}

.card-summary {
  font-size: 0.9rem;
  color: var(--text-muted);
  flex-grow: 1;
}

.card-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-source {
  background: rgba(59, 130, 246, 0.1);
  color: var(--brand-light);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-sector {
  background: rgba(245, 158, 11, 0.1);
  color: var(--gold);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
}

.card-actions button, .card-actions a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  font-size: 0.9rem;
  padding: 0.5rem;
}

/* Shimmer Loading */
.shimmer {
  animation: shimmer 2s infinite linear;
  background: linear-gradient(to right, var(--bg-card) 4%, var(--border) 25%, var(--bg-card) 36%);
  background-size: 1000px 100%;
}

@keyframes shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}

.skeleton-card {
  height: 250px;
  border-radius: 12px;
}

/* AI Resumen Section */
.ai-summary-panel {
  padding: 2rem;
}
.ai-controls {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
.ai-controls input {
  flex-grow: 1;
}
.ai-content {
  min-height: 200px;
  background: var(--bg-deep);
  border-radius: 8px;
  padding: 1.5rem;
  border: 1px solid var(--border);
}
.placeholder-text {
  color: var(--text-muted);
  text-align: center;
  font-style: italic;
  margin-top: 3rem;
}

/* Footer */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 4rem;
  color: var(--text-muted);
}

/* Modal */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.modal-content {
  width: 90%;
  max-width: 800px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border-radius: 16px;
  position: relative;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.map-container {
  flex-grow: 1;
  position: relative;
  overflow: hidden;
}
.map-container svg {
  width: 100%;
  height: 100%;
}
.map-container path {
  fill: var(--bg-card);
  stroke: var(--border);
  stroke-width: 1;
  cursor: pointer;
  transition: all 0.3s ease;
}
.map-container path:hover {
  fill: var(--gold);
}
.map-container path.selected {
  fill: var(--brand-light);
}

/* Calendar */
.date-picker-group { position: relative; }
.calendar-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  z-index: 50;
  width: 300px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.cal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.cal-day-name {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  padding-bottom: 0.5rem;
}
.cal-day {
  padding: 0.5rem 0;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}
.cal-day:hover:not(.empty):not(.disabled) {
  background: var(--bg-glass);
}
.cal-day.today {
  color: var(--gold);
  font-weight: bold;
}
.cal-day.selected {
  background: var(--brand);
  color: white;
}
.cal-day.disabled {
  color: var(--border);
  cursor: not-allowed;
}
.cal-day.empty { cursor: default; }

/* Chatbot */
#chatbot-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 100;
}
.chat-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
  animation: pulse 2s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4); }
  70% { box-shadow: 0 0 0 15px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
.chat-panel {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  height: 520px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s ease, opacity 0.3s ease;
}
.chat-panel.hidden {
  transform: scale(0.8);
  opacity: 0;
  pointer-events: none;
}
.chat-header {
  padding: 1rem;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.chat-messages {
  flex-grow: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.message {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.4;
}
.msg-user {
  align-self: flex-end;
  background: var(--brand);
  color: white;
  border-bottom-right-radius: 4px;
}
.msg-bot {
  align-self: flex-start;
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.msg-bot p { margin-bottom: 0.5em; }
.msg-bot p:last-child { margin-bottom: 0; }
.msg-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.25rem;
  text-align: right;
}
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.suggestion-chip {
  background: transparent;
  border: 1px solid var(--brand-light);
  color: var(--brand-light);
  padding: 0.5rem;
  border-radius: 16px;
  font-size: 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.suggestion-chip:hover {
  background: rgba(59, 130, 246, 0.1);
}
.chat-input {
  display: flex;
  padding: 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
}
.chat-input input {
  flex-grow: 1;
  border: none;
  background: transparent;
  padding: 0.5rem;
  color: var(--text);
}
.chat-input input:focus { outline: none; }
.chat-send {
  background: transparent;
  border: none;
  color: var(--brand-light);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.5rem;
}

/* Typing indicator */
.typing-dots { display: flex; gap: 4px; padding: 0.5rem; }
.typing-dots span {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
@keyframes typing {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Toasts */
#toast-container {
  position: fixed;
  top: 2rem;
  right: 2rem;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-light);
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  animation: slideInRight 0.3s ease forwards;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
  .huge-title { font-size: 2.5rem; }
  .main-nav { display: none; } /* Mobile menu could be added */
  .chat-panel {
    width: 300px;
    height: 450px;
  }
}
