/**
 * fragmennts - Estilo inspirado en diseño innsite (verde, limpio)
 * Paleta: verde #8BD23D, fondo gris claro
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --green-primary: #8BD23D;
  --green-dark: #6BA82A;
  --green-hover: #7bc434;
  --gray-50: #fafafa;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --header-bg: #ffffff;
  --header-border: #e5e7eb;
  --card-bg: #ffffff;
  --card-border: #eaeded;
  --card-shadow: 0 1px 1px 0 rgba(0,28,36,.1);
  --card-radius: 8px;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --danger: #dc2626;
  --success: #10b981;
  --warning: #f59e0b;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Dark mode */
body.dark {
  --gray-50: #0b1220;
  --gray-100: #0f172a;
  --gray-200: #1f2937;
  --gray-300: #334155;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --header-bg: #0f172a;
  --header-border: #1f2937;
  --card-bg: #0f172a;
  --card-border: #1f2937;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
}

body.dark .rt-wrapper,
body.dark .rt-toolbar,
body.dark .rt-btn,
body.dark .rt-select,
body.dark .rt-editor,
body.dark .card,
body.dark .search-results {
  background: var(--card-bg);
  color: var(--text-primary);
}

body.dark .rt-btn,
body.dark .rt-select,
body.dark .form-group input,
body.dark .form-group textarea,
body.dark .form-group select,
body.dark .search-input-wrap input {
  background: #0b1220;
  border-color: var(--gray-300);
  color: var(--text-primary);
}


* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--gray-50);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Animaciones suaves entre bloques */
.card, .metric-card, .doc-list-item, table.data-table tr {
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.06); transform: translateY(-1px); }

/* Layout sin sidebar - todo en top bar */
.app-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Header superior fijo */
.top-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 24px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  text-decoration: none;
  color: var(--text-primary);
}

.header-logo-icon {
  width: 40px;
  height: 40px;
  background: var(--green-primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.header-logo-text h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}

.header-logo-text span {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
}

/* Buscador centrado */
.search-wrapper {
  flex: 1;
  max-width: 520px;
  margin: 0 24px;
}

.search-input-wrap {
  position: relative;
}

.search-input-wrap input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: var(--gray-50);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-wrap input:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 2px rgba(139,210,61,.2);
}

.search-input-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  max-height: 400px;
  overflow-y: auto;
  z-index: 1000;
}

.search-results .result-item {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  text-decoration: none;
  color: var(--text-primary);
  transition: background 0.15s;
}

.search-results .result-item:hover {
  background: var(--gray-50);
}

.search-results .result-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  margin-right: 12px;
  flex-shrink: 0;
}

.result-badge.wiki { background: #dbeafe; color: #1e40af; }
.result-badge.recurso { background: #fef3c7; color: #92400e; }
.result-badge.leccion { background: #d1fae5; color: #065f46; }
.result-badge.credencial { background: #e9d5ff; color: #6b21a8; }

/* Header actions */
.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-600);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.header-btn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}

.header-btn.notifications {
  position: relative;
}

.header-btn .badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
}

/* User dropdown con avatar verde */
.user-dropdown {
  position: relative;
}

.user-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-700);
  transition: background 0.15s;
  font-family: inherit;
  font-size: 14px;
}

.user-dropdown-trigger:hover {
  background: var(--gray-100);
}

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--green-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 14px;
}

.user-info {
  text-align: left;
}

.user-info .name {
  display: block;
  font-weight: 500;
  color: var(--text-primary);
}

.user-info .role {
  display: block;
  font-size: 12px;
  color: var(--green-dark);
}

.user-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 8px;
  min-width: 220px;
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  padding: 8px 0;
  z-index: 200;
  border: 1px solid var(--gray-200);
}

.user-dropdown.open .user-dropdown-menu {
  display: block;
}

.user-dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  color: var(--text-primary);
  text-decoration: none;
  transition: background 0.15s;
  font-size: 14px;
}

.user-dropdown-menu a:hover {
  background: var(--gray-50);
}

.user-dropdown-menu a.logout {
  color: var(--danger);
}

/* Barra navegación horizontal */
.nav-tabs {
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  padding: 0 24px;
}

.nav-tabs-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  gap: 4px;
}

.nav-tabs a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 500;
  font-size: 14px;
  border-bottom: 3px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.nav-tabs a:hover {
  color: var(--text-primary);
}

.nav-tabs a.active {
  color: var(--green-primary);
  border-bottom-color: var(--green-primary);
}

.nav-tabs .nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.9;
}

/* Contenido */
.page-content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text-primary);
}

.page-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 14px;
}

/* Tarjetas */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  box-shadow: var(--card-shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--gray-200);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

/* Métricas - 5 tarjetas compactas */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

@media (max-width: 1024px) {
  .metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-card {
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  padding: 20px;
  position: relative;
  overflow: hidden;
  min-height: 100px;
}

.metric-card .metric-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  min-width: 40px;
  min-height: 40px;
  max-width: 40px;
  max-height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.metric-card .metric-icon.wiki { background: #dbeafe; color: #1e40af; }
.metric-card .metric-icon.recurso { background: #fef3c7; color: #92400e; }
.metric-card .metric-icon.leccion { background: #fef3c7; color: #92400e; }
.metric-card .metric-icon.pendientes { background: #fee2e2; color: #dc2626; }
.metric-card .metric-icon.usuarios { background: #dbeafe; color: #1e40af; }

.metric-value {
  font-size: 28px;
  font-weight: 700;
  margin: 4px 0;
  color: var(--text-primary);
}

.metric-label {
  font-size: 13px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Dashboard grid 2 columnas */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
}

/* Document list items */
.doc-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  transition: background 0.15s;
}

.doc-list-item:hover {
  background: var(--gray-50);
}

.doc-list-item .doc-icon {
  width: 20px;
  height: 20px;
  color: #3b82f6;
  flex-shrink: 0;
  margin-top: 2px;
}

.doc-list-item .lesson-icon {
  color: #eab308;
}

.doc-list-item .doc-title {
  font-weight: 500;
  color: var(--text-primary);
}

.doc-list-item .doc-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Tablas */
.table-wrap {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
}

table.data-table th,
table.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
}

table.data-table th {
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table.data-table tr:hover td {
  background: var(--gray-50);
}

table.data-table a {
  color: var(--green-dark);
  text-decoration: none;
}

table.data-table a:hover {
  text-decoration: underline;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-primary {
  background: var(--green-primary);
  color: white;
}

.btn-primary:hover {
  background: var(--green-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(139,210,61,.3);
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Formularios */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--gray-700);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(139,210,61,.1);
}

.form-group textarea {
  min-height: 120px;
  resize: vertical;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.alert-success {
  background: #d1fae5;
  color: #065f46;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
}

.alert-warning {
  background: #fef3c7;
  color: #92400e;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
  font-weight: 500;
  text-transform: uppercase;
}

.badge-draft { background: #e5e7eb; color: #374151; }
.badge-published { background: #d1fae5; color: #065f46; }
.badge-analisis { background: #fef3c7; color: #92400e; }
.badge-cerrado { background: #d1fae5; color: #065f46; }
.badge-documented { background: #d1fae5; color: #065f46; }
.badge-new { background: #dbeafe; color: #1e40af; }

/* Login page */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-50);
  padding: 24px;
}

.login-container {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  border: 1px solid var(--gray-200);
  padding: 40px;
}

.login-header {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  width: 64px;
  height: 64px;
  background: var(--green-primary);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  color: white;
  font-weight: 700;
  font-size: 24px;
}

.login-header h1 {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 8px 0;
}

.login-header p {
  font-size: 14px;
  color: var(--gray-500);
  margin: 0;
}

.login-form .form-group:last-of-type {
  margin-bottom: 20px;
}

.login-demo {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: var(--gray-500);
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
  font-weight: 500;
}

/* Footer */
.page-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--header-border);
  background: var(--header-bg);
  color: var(--text-secondary);
  font-size: 13px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state p {
  margin: 8px 0 20px 0;
}

/* PIN modal */
.pin-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Rich text editor */
.rt-wrapper {
  border: 1px solid var(--gray-300);
  border-radius: 12px;
  overflow: hidden;
  background: white;
}

.rt-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}

.rt-btn {
  border: 1px solid var(--gray-200);
  background: white;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--gray-700);
}

.rt-btn:hover {
  border-color: rgba(139,210,61,.6);
  box-shadow: 0 0 0 2px rgba(139,210,61,.15);
}

.rt-select {
  border: 1px solid var(--gray-200);
  background: white;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
}

.rt-editor {
  padding: 14px;
  min-height: 220px;
  outline: none;
}

.rt-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(139,210,61,.2);
}

.rt-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
}

.rt-table td, .rt-table th {
  border: 1px solid var(--gray-200);
  padding: 8px;
}

.pin-modal {
  background: white;
  border-radius: 12px;
  padding: 32px;
  max-width: 360px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.pin-modal h3 {
  margin: 0 0 8px 0;
  font-size: 18px;
}

.pin-modal p {
  color: var(--gray-500);
  margin-bottom: 20px;
  font-size: 14px;
}

.pin-input {
  font-size: 24px;
  letter-spacing: 12px;
  text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
  .top-header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 0;
  }

  .search-wrapper {
    order: 3;
    width: 100%;
    margin: 12px 0 0 0;
  }

  .nav-tabs {
    overflow-x: auto;
  }

  .nav-tabs a span:not(.nav-icon) {
    display: none;
  }

  .metrics-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-content {
    padding: 16px;
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}
