/* ===================================================
   EduAI Docente - Estilos Principales (Inspirado en Gemini)
   =================================================== */

:root {
  --bg-main: #0c0f17;
  --bg-sidebar: #10141f;
  --bg-surface: #171d2b;
  --bg-surface-hover: #1f273b;
  --bg-input: #1a2030;
  --border-subtle: #242e42;
  --border-focus: #3b82f6;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-blue: #38bdf8;
  --accent-purple: #818cf8;
  --accent-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  --shadow-popup: 0 16px 36px -4px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 72px;
  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* App Container */
.app-layout {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

/* =========================================
   BARRA LATERAL (SIDEBAR)
   ========================================= */
.sidebar {
  width: var(--sidebar-width);
  height: 100%;
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s ease;
  z-index: 50;
  user-select: none;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-header {
  padding: 18px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  white-space: nowrap;
}

.brand-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
}

.brand-text {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.sidebar-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.sidebar-toggle-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

/* Botón Nueva Conversación */
.new-chat-container {
  padding: 10px 16px;
}

.btn-new-chat {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-pill);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-weight: 500;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.2s ease;
  overflow: hidden;
  white-space: nowrap;
}

.btn-new-chat:hover {
  background: var(--bg-surface-hover);
  border-color: var(--accent-blue);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.15);
}

.btn-new-chat svg {
  flex-shrink: 0;
  color: var(--accent-blue);
}

/* Enlaces del Menú */
.sidebar-nav {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  margin-bottom: 2px;
  transition: all 0.2s;
  white-space: nowrap;
}

.nav-item:hover, .nav-item.active {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.nav-item svg {
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.nav-item:hover svg, .nav-item.active svg {
  color: var(--accent-blue);
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 14px 14px 6px;
}

/* Perfil de Usuario Docente */
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sidebar);
}

.user-profile-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.2s;
}

.user-profile-card:hover {
  background: var(--bg-surface);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =========================================
   ÁREA PRINCIPAL DE CONTENIDO
   ========================================= */
.main-content {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  background: radial-gradient(circle at 50% 15%, #151d30 0%, #0c0f17 75%);
  overflow: hidden;
}

/* Barra Superior */
.top-nav {
  height: 56px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
  z-index: 20;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  padding: 6px;
}

.top-badge-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  color: var(--accent-blue);
  font-weight: 500;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-admin-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  text-decoration: none;
  transition: all 0.2s;
}

.btn-admin-link:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--accent-purple);
}

/* Chat Stream Container */
.chat-scroll-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 140px;
  display: flex;
  flex-direction: column;
  align-items: center;
  scroll-behavior: smooth;
}

.chat-container {
  width: 100%;
  max-width: 860px;
}

/* Bienvenida / Estado Vacío (Igual a la imagen) */
.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 10vh;
  margin-bottom: 40px;
}

.welcome-title {
  font-size: 2.4rem;
  font-weight: 500;
  color: #e2e8f0;
  letter-spacing: -0.03em;
  margin-bottom: 24px;
}

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 720px;
}

.chip-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.chip-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--accent-blue);
  transform: translateY(-1px);
}

/* Mensajes */
.message-row {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease;
}

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

.message-row.user-row {
  justify-content: flex-end;
}

.message-bubble {
  max-width: 85%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.6;
}

.user-row .message-bubble {
  background: #2563eb;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.assistant-row .message-bubble {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  width: 100%;
}

.assistant-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 0.8rem;
  color: var(--accent-blue);
  font-weight: 600;
}

/* Markdown formatting */
.message-bubble h1, .message-bubble h2, .message-bubble h3, .message-bubble h4 {
  color: #fff;
  margin-top: 14px;
  margin-bottom: 8px;
  font-weight: 600;
}
.message-bubble h3 { font-size: 1.2rem; }
.message-bubble h4 { font-size: 1.05rem; }

.message-bubble p {
  margin-bottom: 12px;
}

.message-bubble ul, .message-bubble ol {
  margin-left: 20px;
  margin-bottom: 12px;
}

.message-bubble li {
  margin-bottom: 6px;
}

.message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 0.88rem;
}

.message-bubble th, .message-bubble td {
  border: 1px solid var(--border-subtle);
  padding: 10px 12px;
  text-align: left;
}

.message-bubble th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: var(--accent-blue);
}

.message-bubble blockquote {
  border-left: 3px solid var(--accent-purple);
  padding-left: 14px;
  margin: 12px 0;
  color: var(--text-secondary);
  font-style: italic;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.msg-action-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.msg-action-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--accent-blue);
}

/* =========================================
   VISOR INTERACTIVO DE DIAPOSITIVAS
   ========================================= */
.slide-deck-viewer {
  background: #0f172a;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 16px 0;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.deck-header {
  background: #1e293b;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
}

.deck-title-group h4 {
  margin: 0;
  font-size: 1rem;
  color: #f8fafc;
}

.deck-subtitle {
  font-size: 0.78rem;
  color: #94a3b8;
}

.deck-counter-badge {
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent-blue);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
}

.slide-canvas {
  min-height: 280px;
  padding: 32px 36px;
  background: linear-gradient(135deg, #131d33 0%, #0d1322 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.slide-hero-icon {
  font-size: 2.2rem;
  margin-bottom: 12px;
}

.slide-heading {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 16px;
  line-height: 1.3;
}

.slide-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.slide-bullets li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  color: #cbd5e1;
  line-height: 1.5;
}

.slide-bullets li::before {
  content: "•";
  color: var(--accent-blue);
  font-weight: bold;
  font-size: 1.2rem;
  line-height: 1;
}

.slide-teacher-notes {
  margin-top: 20px;
  padding: 10px 14px;
  background: rgba(129, 140, 248, 0.1);
  border-left: 3px solid var(--accent-purple);
  border-radius: 4px;
  font-size: 0.82rem;
  color: #c7d2fe;
}

.deck-footer {
  background: #1e293b;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
}

.deck-nav-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}

.deck-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

.deck-btn:hover:not(:disabled) {
  background: var(--bg-surface-hover);
  border-color: var(--accent-blue);
}

.deck-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.deck-btn-download {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border: none;
  color: white;
  font-weight: 500;
}

.deck-btn-download:hover {
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4);
}

/* =========================================
   VISOR DE IMAGEN DIDÁCTICA
   ========================================= */
.educational-image-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin: 14px 0;
}

.educational-image-preview {
  width: 100%;
  max-height: 480px;
  display: block;
  object-fit: contain;
  background: #090d16;
}

.educational-image-details {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
}

/* =========================================
   BARRA DE CHAT CÁPSULA (IDÉNTICA A LA IMAGEN)
   ========================================= */
.chat-input-wrapper {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  padding: 16px 20px 24px;
  background: linear-gradient(to top, var(--bg-main) 60%, rgba(12, 15, 23, 0) 100%);
  display: flex;
  justify-content: center;
  z-index: 30;
}

.chat-input-capsule {
  width: 100%;
  max-width: 840px;
  background: var(--bg-input);
  border: 1px solid #2a344a;
  border-radius: 28px;
  padding: 8px 12px 8px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.chat-input-capsule:focus-within {
  border-color: #3b82f6;
  box-shadow: 0 8px 30px rgba(59, 130, 246, 0.15), 0 0 0 1px #3b82f6;
}

/* Botón Plus / Modos Docentes */
.btn-plus-mode {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-plus-mode:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.mode-badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: var(--accent-blue);
  font-size: 0.76rem;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

.btn-remove-mode {
  background: transparent;
  border: none;
  color: var(--accent-blue);
  cursor: pointer;
  padding: 0 2px;
  font-size: 0.8rem;
}

/* Textarea adaptable */
.chat-textarea {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.98rem;
  resize: none;
  max-height: 140px;
  line-height: 1.4;
  padding: 6px 0;
}

.chat-textarea::placeholder {
  color: #64748b;
}

/* Controles del Lado Derecho del Input */
.chat-right-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* Botón Píldora Selector de Modelo (Estilo "Thinking ^" de la imagen) */
.model-pill-btn {
  background: #222b3d;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  user-select: none;
}

.model-pill-btn:hover {
  background: #2b364c;
  border-color: #475569;
}

.model-pill-btn svg {
  transition: transform 0.2s;
}

.model-pill-btn.open svg {
  transform: rotate(180deg);
}

/* Dropdown de Modelos Flotante (Igual a la imagen de referencia) */
.model-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  right: 12px;
  width: 280px;
  background: #171f2f;
  border: 1px solid #2e3a50;
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: var(--shadow-popup);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
  animation: popupSlide 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.model-dropdown-menu.visible {
  display: flex;
}

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

.model-option-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.15s;
}

.model-option-item:hover {
  background: #222b3e;
}

.model-option-item.selected {
  background: #1e293b;
}

.model-check-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-blue);
  flex-shrink: 0;
  margin-top: 2px;
}

.model-info-block {
  flex: 1;
}

.model-info-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 6px;
}

.model-info-desc {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
  line-height: 1.3;
}

/* Menú Emergente de Modos Docentes (+) */
.modes-dropdown-menu {
  position: absolute;
  bottom: calc(100% + 12px);
  left: 12px;
  width: 260px;
  background: #171f2f;
  border: 1px solid #2e3a50;
  border-radius: var(--radius-lg);
  padding: 8px;
  box-shadow: var(--shadow-popup);
  display: none;
  flex-direction: column;
  gap: 4px;
  z-index: 100;
}

.modes-dropdown-menu.visible {
  display: flex;
}

.mode-option-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.88rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.mode-option-btn:hover {
  background: #222b3e;
}

/* Botón Micrófono y Enviar */
.btn-mic-input {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-mic-input:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.btn-mic-input.listening {
  color: var(--accent-rose);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.btn-send-message {
  background: var(--accent-blue);
  border: none;
  color: #0c0f17;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-send-message:hover {
  background: #7dd3fc;
  transform: scale(1.05);
}

.btn-send-message:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* =========================================
   RESPONSIVIDAD Y DISPOSITIVOS MÓVILES
   ========================================= */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.7);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .mobile-menu-btn {
    display: flex;
  }

  .chat-scroll-area {
    padding: 16px 14px 130px;
  }

  .chat-input-wrapper {
    padding: 10px 12px 16px;
  }

  .model-pill-btn span {
    max-width: 90px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 480px) {
  .welcome-title {
    font-size: 1.8rem;
  }

  .chip-btn {
    font-size: 0.8rem;
    padding: 8px 14px;
  }

  .model-dropdown-menu {
    right: 0;
    left: 0;
    width: auto;
  }

  .slide-canvas {
    padding: 20px 18px;
    min-height: 240px;
  }

  .slide-heading {
    font-size: 1.2rem;
  }
}
