/* ==============================================================================
   COOPCRECER JUNTOS - Panel de Administración CMS (admin.css)
   Paleta: Verde Profundo (#164A3A), Oro (#D4AF37), Slate (#0F172A), Fondo (#F8FAFC)
   ============================================================================== */

:root {
  --admin-primary: #164A3A;
  --admin-primary-hover: #123C2F;
  --admin-accent: #D4AF37;
  --admin-accent-hover: #B89726;
  --admin-dark-bg: #0B131E;
  --admin-sidebar-bg: #0F1A2A;
  --admin-sidebar-hover: #19273C;
  --admin-card-bg: #FFFFFF;
  --admin-border: #E2E8F0;
  --admin-text: #1E293B;
  --admin-text-muted: #64748B;
  --admin-success: #10B981;
  --admin-warning: #F59E0B;
  --admin-danger: #EF4444;
  --admin-info: #3B82F6;
  --admin-radius: 8px;
  --admin-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --admin-sidebar-width: 260px;
  --admin-header-height: 64px;
}

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

body.admin-body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #F1F5F9;
  color: var(--admin-text);
  min-height: 100vh;
  display: flex;
}

/* --- Layout Principal --- */
.admin-sidebar {
  width: var(--admin-sidebar-width);
  background-color: var(--admin-sidebar-bg);
  color: #F8FAFC;
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  border-right: 1px solid rgba(212, 175, 55, 0.2);
}

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  background: #0B131E;
}

.sidebar-brand a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  width: 100%;
}

.sidebar-brand img {
  height: 48px;
  max-width: 100%;
  width: auto;
  object-fit: contain;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-brand a:hover img {
  transform: scale(1.03);
  opacity: 0.95;
}

.sidebar-menu {
  list-style: none;
  padding: 1rem 0;
  flex-grow: 1;
}

.menu-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #64748B;
  padding: 0.75rem 1.5rem 0.25rem;
  font-weight: 700;
}

.menu-item a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: #CBD5E1;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.menu-item a:hover {
  background: var(--admin-sidebar-hover);
  color: #FFFFFF;
}

.menu-item.active a {
  background: rgba(22, 74, 58, 0.6);
  color: #FFFFFF;
  border-left-color: var(--admin-accent);
  font-weight: 600;
}

.menu-item .menu-badge {
  margin-left: auto;
  background: var(--admin-accent);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.admin-main {
  margin-left: var(--admin-sidebar-width);
  flex-grow: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* --- Header Superior --- */
.admin-header {
  height: var(--admin-header-height);
  background: #FFFFFF;
  border-bottom: 1px solid var(--admin-border);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 900;
}

.header-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--admin-text);
}

.header-title h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--admin-primary);
  font-family: 'Montserrat', sans-serif;
}

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

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  background: #F8FAFC;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 0.85rem;
}

.user-role-tag {
  background: var(--admin-primary);
  color: #FFFFFF;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
  text-transform: uppercase;
}

/* --- Contenedor de Contenido --- */
.admin-content {
  padding: 1.75rem;
  flex-grow: 1;
}

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

.page-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: #0F172A;
  font-family: 'Montserrat', sans-serif;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--admin-text-muted);
  margin-top: 0.2rem;
}

/* --- Métricas y Cards del Dashboard --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.metric-card {
  background: #FFFFFF;
  padding: 1.25rem;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.metric-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

.metric-icon.green { background: #DCFCE7; color: #166534; }
.metric-icon.gold  { background: #FEF3C7; color: #92400E; }
.metric-icon.blue  { background: #DBEAFE; color: #1E40AF; }
.metric-icon.red   { background: #FEE2E2; color: #991B1B; }

.metric-info h3 {
  font-size: 0.8rem;
  color: var(--admin-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-info .metric-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: #0F172A;
  font-family: 'Montserrat', sans-serif;
}

/* --- Tablas y Formularios --- */
.admin-card {
  background: #FFFFFF;
  border-radius: var(--admin-radius);
  border: 1px solid var(--admin-border);
  box-shadow: var(--admin-shadow);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.admin-table th {
  background: #F8FAFC;
  padding: 0.85rem 1rem;
  color: #475569;
  font-weight: 600;
  border-bottom: 2px solid var(--admin-border);
}

.admin-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: #F8FAFC;
}

/* Badges de Estado */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-success { background: #DEF7EC; color: #03543F; }
.badge-warning { background: #FEF08A; color: #854D0E; }
.badge-danger  { background: #FDE8E8; color: #9B1C1C; }
.badge-info    { background: #E1EFFE; color: #1E429F; }

/* Botones */
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 4px;
}

.btn-primary {
  background: var(--admin-primary);
  color: #FFFFFF;
  border: 1px solid var(--admin-primary);
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-primary:hover {
  background: var(--admin-primary-hover);
}

.btn-accent {
  background: var(--admin-accent);
  color: #000000;
  border: 1px solid var(--admin-accent);
  padding: 0.6rem 1.2rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-danger {
  background: #EF4444;
  color: #FFFFFF;
  border: 1px solid #EF4444;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
}

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

.btn-outline {
  background: transparent;
  color: var(--admin-text);
  border: 1px solid var(--admin-border);
  padding: 0.5rem 1rem;
  font-weight: 500;
  cursor: pointer;
  border-radius: 6px;
  text-decoration: none;
}

.btn-outline:hover {
  background: #F1F5F9;
}

/* Alertas Flash */
.flash-alert {
  padding: 1rem 1.25rem;
  border-radius: 6px;
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flash-success { background: #DEF7EC; border: 1px solid #31C48D; color: #03543F; }
.flash-error   { background: #FDE8E8; border: 1px solid #F98080; color: #9B1C1C; }
.flash-warning { background: #FEF08A; border: 1px solid #FACC15; color: #854D0E; }

/* Controles de Formulario CMS */
.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: #1E293B;
  margin-bottom: 0.4rem;
}

.form-control, .form-input, .form-select {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: 0.95rem;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  background-color: #FFFFFF;
  color: #1E293B;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
  display: block;
  font-family: inherit;
}

.form-control:focus, .form-input:focus, .form-select:focus {
  border-color: var(--admin-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(22, 74, 58, 0.15);
}

textarea.form-control {
  resize: vertical;
  min-height: 110px;
  line-height: 1.6;
}

.form-hint {
  font-size: 0.8rem;
  color: var(--admin-text-muted);
  margin-top: 0.35rem;
  display: block;
}

/* Visor de Vista Previa Modal (Noticias / Contenido) */
.preview-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.preview-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.preview-modal-dialog {
  background: #FFFFFF;
  border-radius: 12px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  animation: modalSlideUp 0.3s ease-out;
}

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

.preview-modal-header {
  padding: 1rem 1.5rem;
  background: #F8FAFC;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.preview-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0F172A;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.preview-modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #64748B;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.preview-modal-close:hover {
  background: #E2E8F0;
  color: #0F172A;
}

.preview-modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  line-height: 1.7;
  color: #1E293B;
}

.preview-modal-footer {
  padding: 1rem 1.5rem;
  background: #F8FAFC;
  border-top: 1px solid #E2E8F0;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Mensajes y PQRS - Hilo de Trazabilidad y Respuestas */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  position: relative;
  margin-top: 1rem;
}

.timeline-list::before {
  content: '';
  position: absolute;
  top: 15px;
  bottom: 15px;
  left: 20px;
  width: 2px;
  background: #E2E8F0;
  z-index: 1;
}

.timeline-card {
  position: relative;
  z-index: 2;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.timeline-badge {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 2px solid #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.timeline-badge.email { border-color: #3B82F6; background: #EFF6FF; }
.timeline-badge.whatsapp { border-color: #10B981; background: #ECFDF5; }
.timeline-badge.phone { border-color: #F59E0B; background: #FFFBEB; }
.timeline-badge.citizen { border-color: var(--admin-primary); background: #EBF4F0; }

.timeline-box {
  background: #FFFFFF;
  border: 1px solid #E2E8F0;
  border-radius: 8px;
  padding: 1.25rem;
  flex-grow: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}

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

/* Pestañas de Canales de Respuesta */
.reply-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid #E2E8F0;
  padding-bottom: 0.5rem;
}

.reply-tab-btn {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #64748B;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.reply-tab-btn:hover {
  background: #F1F5F9;
  color: #1E293B;
}

.reply-tab-btn.active {
  background: var(--admin-primary);
  color: #FFFFFF;
}

/* Píldoras de Plantillas Rápidas */
.template-pills-container {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.template-pill {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s;
}

.template-pill:hover {
  background: #E2E8F0;
  border-color: #94A3B8;
  color: #0F172A;
  transform: translateY(-1px);
}

/* Estilos de Impresión Ficha PQRS */
@media print {
  .admin-sidebar,
  .admin-header,
  .page-header .btn,
  .btn,
  .reply-tabs,
  .template-pills-container,
  #replyBoxContainer,
  .actions-sidebar {
    display: none !important;
  }

  body.admin-body {
    background: #FFFFFF !important;
    color: #000000 !important;
  }

  .admin-main {
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .admin-content {
    padding: 0 !important;
  }

  .admin-card {
    border: 1px solid #000000 !important;
    box-shadow: none !important;
  }

  .print-only-header {
    display: block !important;
    margin-bottom: 2rem;
    border-bottom: 2px solid #000;
    padding-bottom: 1rem;
  }
}

.print-only-header {
  display: none;
}

/* Responsive */
@media (max-width: 992px) {
  .admin-sidebar {
    transform: translateX(-100%);
  }
  .admin-sidebar.open {
    transform: translateX(0);
  }
  .admin-main {
    margin-left: 0;
  }
  .header-toggle {
    display: block;
  }
}
