/*
 * Consulta Revista - Premium Design System (Restored & Cleaned)
 * Built for Bootstrap 5.3 + DataTables BS5
 */

:root {
  /* Paleta Océano - Extraída de imagen */
  --ocean-sky: #B8D4F0;      /* Fondo sidebar, base */
  --ocean-light: #E0F2FE;   /* Hover, filas alternas */
  --ocean-accent: #38BDF8;  /* Botones, badges, acentos */
  --ocean-deep: #1E5F8E;    /* Headers, títulos */
  --ocean-night: #0F172A;   /* Texto principal */
  --ocean-white: #FFFFFF;   /* Cards, modals */

  /* Mapeo a variables Bootstrap consistentes */
  --cr-primary: #1E5F8E;
  --cr-primary-hover: #1E5F8E;
  --cr-secondary: #38BDF8;
  --cr-bg-body: #B8D4F0;
  --cr-bg-sidebar: #B8D4F0;
  --cr-bg-card: #FFFFFF;
  --cr-text-heading: #0F172A;
  --cr-text-body: #0F172A;
  --cr-text-muted: #1E5F8E;
  --cr-border: #B8D4F0;
  --cr-radius: 0.5rem;
  --cr-shadow: 0 4px 6px -1px rgba(30, 95, 142, 0.1);

  /* TODAS las listas usan el mismo azul océano - consistencia */
  --cr-lista-all: #38BDF8;
  --cr-lista-all-bg: #E0F2FE;
  --cr-lista-all-text: #1E5F8E;
}

/* =========================================
   Base & Typography
   ========================================= */
body {
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    sans-serif;
  background-color: var(--cr-bg-body);
  color: var(--cr-text-body);
  line-height: 1.5;
  height: 100%; /* Ensure full height for sticky footer */
}

html {
  height: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--cr-text-heading);
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* =========================================
   Layout Structure
   ========================================= */
#layout-wrapper {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

/* Page Content */
.main-content {
  margin-left: 260px; /* Standard sidebar width */
  margin-top: 70px; /* Standard header height */
  transition: all 0.3s ease;
  min-height: calc(100vh - 70px); /* Minimum height to fill viewport */
  display: flex;
  flex-direction: column;
}

.page-content {
  padding: 1.5rem;
  flex: 1; /* Grow to push footer down */
}

/* Sidebar - Blanco para contrastar con body azul */
.sidebar {
  width: 260px;
  height: 100vh;
  position: fixed;
  top: 70px;
  left: 0;
  background: #FFFFFF;
  border-right: 2px solid #38BDF8;
  box-shadow: 2px 0 12px rgba(30, 95, 142, 0.15);
  z-index: 1000;
  padding-top: 1.5rem;
}

/* Sidebar - Colores Océano */
.sidebar .nav-link {
  color: #1E5F8E;
  padding: 0.875rem 1.5rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

.sidebar .nav-link:hover {
  background-color: #E0F2FE;
  color: #0F172A;
}

.sidebar .nav-link.active {
  background-color: #B8D4F0;
  color: #0F172A;
  border-left-color: #38BDF8;
}

/* Navbar */
.navbar {
  height: 70px;
  background-color: #fff;
  border-bottom: 1px solid var(--cr-border);
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1001;
  padding: 0 1.5rem;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--cr-primary);
  width: 260px;
  margin-right: 0;
}

/* Breadcrumb - Océano */
.breadcrumb {
  background: #E0F2FE;
  border: 2px solid #B8D4F0;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: 0 2px 4px rgba(30, 95, 142, 0.08);
}

.breadcrumb-item {
  font-size: 0.875rem;
  font-weight: 500;
}

.breadcrumb-item a {
  color: #1E5F8E;
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb-item a:hover {
  color: #38BDF8;
  text-decoration: underline;
}

.breadcrumb-item.active {
  color: #0F172A;
  font-weight: 600;
}

.breadcrumb-item + .breadcrumb-item::before {
  color: #38BDF8;
  font-weight: 600;
}

/* Footer */
.footer {
  background: #fff;
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--cr-border);
  color: var(--cr-text-muted);
  font-size: 0.875rem;
  padding-left: calc(260px + 2rem); /* Align content with main-content */
  margin-top: auto; /* Push to bottom when content is short */
}

@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .main-content,
  .footer {
    margin-left: 0;
  }
  .sidebar.show {
    transform: translateX(0);
  }
}

/* =========================================
   Components
   ========================================= */
/* Components - Cards & Containers con bordes visibles */
.card {
  background: #FFFFFF;
  border: 2px solid #B8D4F0;
  border-radius: var(--cr-radius);
  box-shadow: 0 2px 8px rgba(30, 95, 142, 0.08), 0 1px 3px rgba(30, 95, 142, 0.05);
  margin-bottom: 1.5rem;
  overflow: visible !important;
  position: relative;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(30, 95, 142, 0.12), 0 2px 6px rgba(30, 95, 142, 0.08);
  border-color: #38BDF8;
}

.card-body {
  padding: 1.5rem;
  overflow: visible !important;
}

.card-header {
  background: linear-gradient(135deg, #ffffff 0%, #E0F2FE 100%);
  border-bottom: 2px solid #B8D4F0;
  padding: 1.25rem 1.5rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  color: #1E5F8E;
}

/* =========================================
   DataTables Professional Design
   ========================================= */
/* Wrapper Styling */
.dataTables_wrapper {
  padding: 0;
  overflow: visible !important; /* Allow buttons to show */
  position: relative;
  z-index: auto; /* Don't create stacking context */
}

/* Ensure all DataTables containers allow overflow */
.dataTables_wrapper > .row,
.dataTables_wrapper .dt-buttons,
.card-body.p-0 {
  overflow: visible !important;
}

/* Dropdown menu styling with maximum z-index */
div.dt-button-collection {
  position: fixed !important; /* Use fixed positioning to escape all containers */
  z-index: 99999 !important; /* Maximum z-index to float above everything */
  background: white;
  box-shadow:
    0 10px 15px -3px rgb(0 0 0 / 0.1),
    0 4px 6px -2px rgb(0 0 0 / 0.1);
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

/* Filter & Controls spacing */
.dataTables_wrapper .row {
  margin: 0; /* Align perfectly with card */
  padding: 1rem 1.5rem; /* Add internal padding */
}

/* Remove side padding for table row specifically to let borders touch edges if desired,
   or keep it consistent. Let's keep it consistent professional box. */
/* However, standard BS5 card-body has padding.
   If DataTable is inside .card-body, it inherits padding.
*/

/* Buttons Styling Override (Solid & Professional) */
div.dt-buttons {
  gap: 0.5rem;
  margin-bottom: 0;
}
div.dt-buttons .btn {
  font-weight: 500;
  box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  font-size: 0.85rem;
  border-radius: 0.375rem;
}

/* Search Box - Océano */
.dataTables_filter input {
  border: 1px solid #B8D4F0;
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  min-width: 250px;
  transition: all 0.2s;
}
.dataTables_filter input:focus {
  border-color: #38BDF8;
  outline: none;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* Table Design */
.table.dataTable {
  border-collapse: separate !important;
  border-spacing: 0;
  width: 100% !important;
  margin-bottom: 0 !important;
  border-top: 1px solid var(--cr-border);
  border-bottom: 1px solid var(--cr-border);
}

/* DataTables - Océano */
/* Headers */
.table.dataTable thead th {
  background-color: #E0F2FE;
  color: #1E5F8E;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #B8D4F0;
  vertical-align: middle;
  white-space: nowrap;
}

/* Body */
.table.dataTable tbody td {
  padding: 0.625rem 1rem;
  vertical-align: middle;
  color: #0F172A;
  font-size: 0.85rem;
  border-bottom: 1px solid #B8D4F0;
}

/* Row Hover */
.table-hover tbody tr:hover {
  background-color: #E0F2FE !important;
}

/* Pagination - Océano */
.dataTables_paginate .pagination {
  margin: 0;
  gap: 0.25rem;
}
.dataTables_paginate .page-item .page-link {
  border: 1px solid #B8D4F0;
  border-radius: 0.375rem;
  color: #1E5F8E;
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  background: white;
}
.dataTables_paginate .page-item.active .page-link {
  background-color: #38BDF8;
  border-color: #38BDF8;
  color: white;
}
.dataTables_paginate .page-item.disabled .page-link {
  background-color: #E0F2FE;
  color: #B8D4F0;
  border-color: #B8D4F0;
}

/* Info Text */
.dataTables_info {
  color: #1E5F8E !important;
  font-size: 0.875rem;
  padding-top: 0.5rem !important;
}

/* =========================================
   Lista Badges - TODOS azul océano
   ========================================= */
.badge-lista {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.025em;
  border-radius: 9999px;
  border: 1.5px solid transparent;
  transition: all 0.2s ease;
}

.badge-lista::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-lista-07,
.badge-lista-20,
.badge-lista-comercial {
  background-color: #E0F2FE;
  color: #1E5F8E;
  border-color: #38BDF8;
}

.badge-lista:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.3);
}

/* =========================================
   Form Improvements - Océano
   ========================================= */
.form-card {
  background: linear-gradient(135deg, #ffffff 0%, #E0F2FE 100%);
  border: 1px solid #B8D4F0;
  border-radius: var(--cr-radius);
  box-shadow: 0 1px 3px rgba(30, 95, 142, 0.05);
}

.form-card .card-header {
  background: transparent;
  border-bottom: 2px solid #B8D4F0;
  padding: 1.5rem;
}

.form-card .card-header h5 {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  color: #0F172A;
}

.form-card .card-header h5 i {
  color: #1E5F8E;
  font-size: 1.25rem;
}

.form-label {
  font-weight: 500;
  color: #0F172A;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.form-control, .form-select {
  border: 1.5px solid #B8D4F0;
  border-radius: 0.5rem;
  padding: 0.625rem 0.875rem;
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: #38BDF8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.form-control::placeholder {
  color: #1E5F8E;
}

/* Search Button - Océano (sin gradiente) */
.btn-search {
  background: #1E5F8E;
  border: 2px solid #1E5F8E;
  color: white;
  box-shadow: 0 2px 4px rgba(30, 95, 142, 0.2);
  transition: all 0.2s ease;
}

.btn-search:hover {
  background: #38BDF8;
  border-color: #38BDF8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(30, 95, 142, 0.25);
}

/* =========================================
   Sidebar Enhancements - Océano
   ========================================= */
.sidebar-brand {
  padding: 1.5rem;
  border-bottom: 1px solid #B8D4F0;
  margin-bottom: 1rem;
}

.sidebar-brand a {
  color: #1E5F8E;
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-brand i {
  font-size: 1.5rem;
  color: #38BDF8;
}

.sidebar-section-title {
  color: #1E5F8E;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 1rem 1.5rem 0.5rem;
  margin: 0;
}

.sidebar .nav-link {
  margin: 0.25rem 0.75rem;
  border-radius: 0.5rem;
  border-left: none;
  position: relative;
  overflow: hidden;
}

.sidebar .nav-link::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: #3b82f6;
  transform: scaleY(0);
  transition: transform 0.2s ease;
}

.sidebar .nav-link.active::before {
  transform: scaleY(1);
}

.sidebar .nav-link i {
  font-size: 1.1rem;
  width: 1.5rem;
  text-align: center;
}

/* =========================================
   Alert Improvements - Océano
   ========================================= */
.alert {
  border: none;
  border-radius: var(--cr-radius);
  padding: 1rem 1.25rem;
}

.alert-info {
  background: linear-gradient(135deg, #E0F2FE 0%, #B8D4F0 100%);
  color: #1E5F8E;
}

.alert-success {
  background: linear-gradient(135deg, #E0F2FE 0%, #B8D4F0 100%);
  color: #1E5F8E;
}

.alert-warning {
  background: linear-gradient(135deg, #E0F2FE 0%, #B8D4F0 100%);
  color: #1E5F8E;
}

.alert-danger {
  background: linear-gradient(135deg, #E0F2FE 0%, #B8D4F0 100%);
  color: #1E5F8E;
}

/* =========================================
   Table Action Buttons - Océano (sin gradiente)
   ========================================= */
.btn-action {
  padding: 0.5rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  color: #1E5F8E;
  transition: all 0.2s ease;
}

.btn-action:hover {
  background: #E0F2FE;
  color: #0F172A;
}

.btn-action-primary {
  background: #38BDF8;
  border: 2px solid #38BDF8;
  color: white;
  box-shadow: 0 2px 4px rgba(56, 189, 248, 0.3);
}

.btn-action-primary:hover {
  background: #1E5F8E;
  border-color: #1E5F8E;
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(56, 189, 248, 0.4);
}

/* =========================================
   Results Summary Card - Océano
   ========================================= */
.results-summary {
  background: linear-gradient(135deg, #E0F2FE 0%, #B8D4F0 100%);
  border: 1px solid #38BDF8;
  border-radius: var(--cr-radius);
  padding: 1rem 1.25rem;
}

.results-summary i {
  color: #1E5F8E;
}

/* =========================================
   Modal Edit - Header Océano (sin gradiente)
   ========================================= */
.modal-header-edit {
  background: #1E5F8E;
  color: white;
  border-bottom: 2px solid #38BDF8;
  padding: 1.25rem 1.5rem;
}

/* TODOS los headers de lista usan el mismo azul océano */
.modal-header-edit.header-lista-07,
.modal-header-edit.header-lista-20,
.modal-header-edit.header-lista-comercial {
  background: #1E5F8E;
}

.modal-header-edit .modal-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.modal-header-edit .badge-lista {
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
  background: rgba(255, 255, 255, 0.2) !important;
  border-color: rgba(255, 255, 255, 0.4) !important;
  color: white !important;
}

.modal-header-edit .badge-lista::before {
  background: white !important;
}

/* Modal Content Styling - Océano */
.modal-content {
  border: 2px solid #B8D4F0;
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px rgba(30, 95, 142, 0.15), 0 4px 12px rgba(30, 95, 142, 0.1);
  overflow: hidden;
}

.modal-body {
  background: #E0F2FE;
  padding: 1.5rem;
}

/* Modal Cards - Visibles */
.modal-body .card {
  border: 2px solid #B8D4F0;
  border-radius: 0.625rem;
  box-shadow: 0 2px 6px rgba(30, 95, 142, 0.08);
  margin-bottom: 1rem;
  overflow: hidden;
}

.modal-body .card:hover {
  box-shadow: 0 4px 10px rgba(30, 95, 142, 0.12);
  border-color: #38BDF8;
}

.modal-body .card-header {
  background: linear-gradient(135deg, #ffffff 0%, #E0F2FE 100%);
  border-bottom: 2px solid #B8D4F0;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.9rem;
  color: #1E5F8E;
}

.modal-body .card-header h6 {
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body .card-header h6 i {
  color: #38BDF8;
  font-size: 1rem;
}

.modal-body .card-body {
  background: #fff;
  padding: 1.25rem;
}

/* Modal Form Controls - Océano */
.modal-body .form-label {
  font-weight: 500;
  font-size: 0.8rem;
  color: #1E5F8E;
  margin-bottom: 0.375rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.modal-body .form-control {
  border: 2px solid #B8D4F0;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  background: #fff;
}

.modal-body .form-control:focus {
  border-color: #38BDF8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

/* Modal Footer - Océano */
.modal-footer {
  background: #E0F2FE;
  border-top: 2px solid #B8D4F0;
  padding: 1rem 1.5rem;
  gap: 0.75rem;
}

.modal-footer .btn {
  padding: 0.625rem 1.25rem;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.modal-footer .btn-secondary {
  background: #0F172A;
  border: 2px solid #0F172A;
  color: white;
}

.modal-footer .btn-secondary:hover {
  background: #1E5F8E;
  border-color: #1E5F8E;
  color: white;
  transform: translateY(-1px);
}

.modal-footer .btn-primary {
  background: #1E5F8E;
  border: 2px solid #1E5F8E;
  color: white;
  box-shadow: 0 2px 4px rgba(30, 95, 142, 0.2);
}

.modal-footer .btn-primary:hover {
  background: #38BDF8;
  border-color: #38BDF8;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(30, 95, 142, 0.3);
}

/* Required Field Indicator */
.modal-body .text-danger {
  color: #ef4444;
  font-weight: 600;
}
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in-up {
  animation: fadeInUp 0.5s ease-out;
}
