:root {
  --ui-bg: #f3f5f9;
  --ui-surface: #ffffff;
  --ui-surface-2: #f9fbff;
  --ui-text: #1f2937;
  --ui-muted: #5f6b7a;
  --ui-border: #dbe3ef;
  --ui-primary: #0f3d68;
  --ui-primary-2: #164f86;
  --ui-accent: #b6862c;
  --ui-success: #1f8b4d;
  --ui-warning: #b56a0a;
  --ui-danger: #b42318;
  --ui-shadow: 0 10px 26px rgba(16, 24, 40, 0.08);
  --ui-space-xs: 0.35rem;
  --ui-space-sm: 0.55rem;
  --ui-space-md: 0.8rem;
  --ui-space-lg: 1rem;
  --sidebar-brand-height: 60px;
}

html {
  font-size: 16px;
  overflow-x: hidden;
}

body {
  background: var(--ui-bg);
  color: var(--ui-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

.wrapper,
.content-wrapper,
.content-wrapper > .content {
  overflow-x: hidden;
}

.wrapper .content-wrapper > .content,
.wrapper .content-wrapper > .content-header {
  animation: fadeInUp 220ms ease-out;
}

.main-header.navbar {
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface) !important;
}

.main-header .nav-link {
  min-height: 40px;
  display: flex;
  align-items: center;
  color: var(--ui-text) !important;
}

.main-sidebar {
  background: linear-gradient(180deg, var(--ui-primary) 0%, #0b2f4f 100%) !important;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-link {
  background: transparent !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18) !important;
  padding-top: 0.35rem !important;
  padding-bottom: 0.35rem !important;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  margin: 0 !important;
}

.global-brand-link {
  background: transparent !important;
  min-height: 60px;
}

.brand-logo-shell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 0.75rem);
  min-height: 38px;
  padding: 0.22rem 0.55rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.brand-text {
  color: #f8fafc !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em;
  display: none !important;
}

.brand-link .brand-image,
.brand-image-square {
  float: none !important;
  width: auto !important;
  height: 30px !important;
  max-width: 140px !important;
  max-height: 30px !important;
  margin: 0 auto !important;
  border-radius: 0 !important;
  object-fit: contain;
  opacity: 1 !important;
  box-shadow: none !important;
  background: transparent !important;
  display: block;
}

.maykol-brand-global {
  height: 30px !important;
  max-width: 142px !important;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.08));
}

.user-panel {
  border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
  padding: 0.5rem 0.85rem 0.56rem !important;
  display: flex !important;
  align-items: center;
  gap: 0.65rem;
}

.global-user-panel {
  align-items: center;
  gap: 0.58rem;
  padding: 0.5rem 0.85rem 0.56rem !important;
  margin-top: 0 !important;
}

.user-panel .image {
  margin-right: 0 !important;
  min-width: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-panel .info {
  padding-left: 0 !important;
  min-width: 0;
  flex: 1 1 auto;
}

.user-panel .info a {
  color: #e5edf8 !important;
  font-size: 0.96rem;
  line-height: 1.45;
  display: flex !important;
  flex-direction: column;
  gap: 0.14rem;
  text-decoration: none;
  overflow: hidden;
}

.global-user-panel .image {
  margin-right: 0 !important;
}

.global-user-panel .info {
  padding-left: 0 !important;
  min-width: 0;
}

.global-user-panel .info a {
  display: flex !important;
  flex-direction: column;
  gap: 0.12rem;
  text-decoration: none;
}

.user-avatar-sidebar {
  width: 2.65rem;
  height: 2.65rem;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
}

.user-avatar-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.65rem;
  height: 2.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.user-name {
  color: #f8fbff;
  font-weight: 700;
  font-size: 0.97rem;
  line-height: 1.2;
  white-space: normal;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.user-role {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  max-width: 100%;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  background: rgba(182, 134, 44, 0.18);
  color: #f9e2ad;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel .info a br {
  display: none;
}

.profile-photo-lg {
  width: 118px;
  height: 118px;
  border-radius: 999px;
  object-fit: cover;
  border: 4px solid rgba(182, 134, 44, 0.18);
  box-shadow: 0 10px 24px rgba(15, 61, 104, 0.14);
}

.profile-photo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 118px;
  height: 118px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(15, 61, 104, 0.12), rgba(182, 134, 44, 0.2));
  color: var(--ui-primary);
  font-size: 2.35rem;
}

.nav-sidebar .nav-link {
  border-radius: 10px;
  margin: 3px 8px;
  min-height: 40px;
  display: flex;
  align-items: center;
  color: #e5edf8 !important;
  font-weight: 600;
  transition: background-color 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.nav-sidebar .nav-link p {
  margin-bottom: 0;
  font-size: 1rem;
}

.nav-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  color: #ffffff !important;
  transform: translateX(2px);
}

.nav-sidebar .nav-link.active {
  background: rgba(182, 134, 44, 0.95) !important;
  color: #fff !important;
  box-shadow: 0 6px 18px rgba(182, 134, 44, 0.3);
}

.nav-treeview .nav-link {
  padding-left: 2.2rem !important;
  font-size: 0.9rem;
  min-height: 38px;
}

.nav-sidebar .nav-icon {
  width: 1.35rem;
  text-align: center;
  margin-right: 0.35rem;
  font-size: 1rem;
}

.nav-header {
  color: #c9daef !important;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 800;
  margin-top: 0.75rem;
  margin-bottom: 0.25rem;
}

.sidebar {
  padding-bottom: 1rem;
}

.layout-fixed .main-sidebar .brand-link,
.layout-fixed .main-sidebar .global-brand-link {
  min-height: var(--sidebar-brand-height) !important;
  height: var(--sidebar-brand-height) !important;
}

.layout-fixed .main-sidebar .sidebar {
  margin-top: 0 !important;
  height: calc(100vh - var(--sidebar-brand-height) - 1px) !important;
  padding-top: 0 !important;
}

.layout-fixed .main-sidebar .global-user-panel {
  margin-top: 0 !important;
}

.main-sidebar .sidebar .user-panel.mt-3 {
  margin-top: 0 !important;
}

.main-sidebar .sidebar .user-panel {
  margin-bottom: 0.28rem;
}

.sidebar::-webkit-scrollbar {
  width: 8px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.24);
  border-radius: 20px;
}

.content-wrapper {
  background: var(--ui-bg) !important;
}

.content-header h1,
.content-header h2,
.content-header h3 {
  color: #16273a;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.card {
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  box-shadow: var(--ui-shadow);
  margin-bottom: var(--ui-space-md);
}

.card:hover {
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.1);
}

.card-header {
  background: var(--ui-surface) !important;
  border-bottom: 1px solid var(--ui-border);
  padding: var(--ui-space-sm) var(--ui-space-md);
}

.card-title {
  color: #16273a;
  font-weight: 700;
  font-size: 1rem;
  margin-bottom: 0;
}

.card-body {
  padding: var(--ui-space-md);
}

.card-footer {
  padding: var(--ui-space-sm) var(--ui-space-md);
}

.admin-hero {
  border: 1px solid var(--ui-border);
  background: linear-gradient(120deg, #ffffff 0%, #f7faff 100%);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: var(--ui-space-md);
  box-shadow: var(--ui-shadow);
}

.admin-hero h1,
.admin-hero h2 {
  font-size: 1.55rem;
  margin: 0 0 0.35rem;
}

.admin-hero p {
  margin: 0;
  color: var(--ui-muted);
}

.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.admin-stat {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 12px;
  padding: 12px 14px;
}

.admin-stat strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
  color: #13283d;
}

.admin-stat span {
  color: var(--ui-muted);
  font-weight: 600;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.small-box {
  border-radius: 14px;
  box-shadow: var(--ui-shadow);
}

.small-box,
.small-box.bg-info,
.small-box.bg-success,
.small-box.bg-warning,
.small-box.bg-danger,
.small-box.bg-secondary,
.small-box.bg-primary {
  background: var(--ui-surface) !important;
  color: var(--ui-text) !important;
  border: 1px solid var(--ui-border);
}

.small-box .icon {
  color: #90a4bf !important;
  opacity: 0.7;
}

.small-box .inner h3 {
  font-size: 2rem;
  font-weight: 800;
}

.badge,
.badge-success,
.badge-warning,
.badge-danger,
.badge-primary,
.badge-secondary {
  border-radius: 999px;
  padding: 0.45em 0.75em;
  font-weight: 700;
}

.badge-success { background: var(--ui-success) !important; color: #fff !important; }
.badge-warning { background: var(--ui-warning) !important; color: #fff !important; }
.badge-danger { background: var(--ui-danger) !important; color: #fff !important; }
.badge-primary { background: var(--ui-primary-2) !important; color: #fff !important; }

/* Paleta unica para todo el admin: evita colores inconsistentes entre vistas */
.bg-primary,
.bg-success,
.bg-warning,
.bg-danger,
.bg-info,
.bg-secondary,
.card-header.bg-primary,
.card-header.bg-success,
.card-header.bg-warning,
.card-header.bg-danger,
.card-header.bg-info,
.card-header.bg-secondary {
  background-color: var(--ui-primary-2) !important;
  color: #ffffff !important;
}

.btn-success,
.btn-danger,
.btn-warning,
.btn-info,
.btn-secondary {
  background-color: var(--ui-primary-2) !important;
  border-color: var(--ui-primary-2) !important;
  color: #ffffff !important;
}

.btn-success:hover,
.btn-danger:hover,
.btn-warning:hover,
.btn-info:hover,
.btn-secondary:hover {
  background-color: #123f69 !important;
  border-color: #123f69 !important;
}

.badge-success,
.badge-warning,
.badge-danger,
.badge-info,
.badge-secondary {
  background-color: var(--ui-primary-2) !important;
  color: #ffffff !important;
}

/* Compatibilidad con estilos legacy en vistas antiguas */
.bg-custom-gold,
.text-custom-gold,
.btn-gold {
  background-color: var(--ui-primary-2) !important;
  color: #ffffff !important;
}

.text-custom-gold {
  color: var(--ui-primary-2) !important;
  background-color: transparent !important;
}

.hover\:bg-custom-gold-dark:hover {
  background-color: #123f69 !important;
}

.shadow-custom {
  box-shadow: var(--ui-shadow) !important;
}

.btn {
  border-radius: 10px;
  min-height: 38px;
  padding: 0.38rem 0.75rem;
  font-weight: 700;
  font-size: 0.92rem;
  line-height: 1.2;
}

.btn-sm {
  min-height: 32px;
  padding: 0.3rem 0.55rem;
  font-size: 0.82rem;
}

.btn-primary {
  background-color: var(--ui-primary-2);
  border-color: var(--ui-primary-2);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #123f69;
  border-color: #123f69;
}

.btn-success {
  background-color: var(--ui-success);
  border-color: var(--ui-success);
}

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

.form-control,
.custom-select,
.input-group-text,
.select2-container--default .select2-selection--single {
  min-height: 38px;
  border-radius: 10px;
  border-color: #c9d5e5;
  font-size: 0.92rem;
  padding: 0.38rem 0.65rem;
}

.form-group label,
label.form-label {
  font-weight: 700;
  color: #1c2f45;
  margin-bottom: 0.35rem;
}

textarea.form-control {
  min-height: 100px;
}

.form-section-title {
  font-weight: 800;
  color: #15273a;
  margin-bottom: 0.9rem;
  font-size: 1.05rem;
}

.form-control:focus,
.custom-select:focus,
.btn:focus,
.nav-link:focus,
a:focus {
  outline: 3px solid rgba(15, 61, 104, 0.35) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

.table {
  color: var(--ui-text);
}

.table thead th {
  background: #eef3fb;
  color: #243244;
  border-bottom: 1px solid var(--ui-border);
  font-weight: 700;
  font-size: 0.86rem;
  white-space: nowrap;
}

.table tbody tr:hover {
  background: #f6f9ff;
}

.table td,
.table th {
  padding: 0.5rem 0.58rem;
  vertical-align: middle;
}

.table td {
  font-size: 0.89rem;
  line-height: 1.35;
}

.actions-col {
  min-width: 190px;
}

.action-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  align-items: center;
}

.action-form {
  display: inline-flex;
  margin: 0;
}

.action-btn.btn {
  min-height: 36px;
  width: 36px;
  padding: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main-footer {
  background: var(--ui-surface);
  border-top: 1px solid var(--ui-border);
  color: var(--ui-muted);
  font-size: 0.88rem;
  padding: 0.65rem 0.85rem;
}

a {
  color: var(--ui-primary-2);
}

a:hover {
  color: #0c3558;
}

.pub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.pub-card {
  background: #fff;
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--ui-shadow);
  display: flex;
  flex-direction: column;
}

.pub-thumb {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: #edf2fa;
}

.pub-body {
  padding: 14px 14px 10px;
}

.pub-title {
  font-size: 1.1rem;
  margin: 0 0 0.5rem;
  color: #15273a;
  font-weight: 800;
}

.pub-meta {
  color: var(--ui-muted);
  font-size: 0.85rem;
}

.pub-excerpt {
  margin: 0.5rem 0 0.75rem;
  color: #364a5f;
}

.pub-footer {
  margin-top: auto;
  border-top: 1px solid var(--ui-border);
  padding: 10px 14px;
  background: #fbfcff;
}

.access-hub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.access-card {
  background: var(--ui-surface);
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  box-shadow: var(--ui-shadow);
  overflow: hidden;
}

.access-card-head {
  background: linear-gradient(140deg, #173e66 0%, #1d568f 100%);
  color: #fff;
  padding: 12px 14px;
}

.access-card-head h3 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 800;
}

.access-list {
  padding: 12px;
  display: grid;
  gap: 8px;
}

.access-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--ui-border);
  background: #f8fbff;
  border-radius: 10px;
  padding: 9px 10px;
  color: #1c3550;
  font-weight: 700;
  text-decoration: none !important;
}

.access-link:hover {
  background: #eaf2fc;
  color: #0f3d68;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  margin-right: 6px;
}

.status-publicado {
  background: var(--ui-success);
}

.status-borrador,
.status-archivado {
  background: #7a8798;
}

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

@media (max-width: 992px) {
  .nav-sidebar .nav-link {
    min-height: 42px;
  }

  .small-box .inner h3 {
    font-size: 1.7rem;
  }

  .services-table {
    min-width: 1100px;
  }

  .actions-col {
    min-width: 170px;
  }
}

@media (max-width: 768px) {
  html {
    font-size: 15px;
  }

  .global-brand-link {
    min-height: 58px;
  }

  .brand-logo-shell {
    min-height: 36px;
  }

  .maykol-brand-global {
    height: 29px !important;
  }

  .global-user-panel {
    padding: 0.45rem 0.72rem 0.5rem;
  }

  .user-avatar-sidebar,
  .user-avatar-fallback {
    width: 2.35rem;
    height: 2.35rem;
  }

  .content-wrapper > .content {
    padding: 0.55rem !important;
  }

  .container-fluid {
    padding-left: 0.45rem !important;
    padding-right: 0.45rem !important;
  }

  .card-header,
  .card-body,
  .card-footer {
    padding: 0.58rem !important;
  }

  .table td,
  .table th {
    padding: 0.44rem 0.46rem;
  }
}

/* Keep the shared user panel in the same place across legacy and shared views. */
.main-sidebar .sidebar > .global-user-panel,
.main-sidebar .sidebar .os-content > .global-user-panel { margin-top: 0 !important; }
.nav-sidebar .nav-link:not(.active):focus { background: transparent !important; }
.nav-sidebar .nav-link:not(.active):hover { background: rgba(255,255,255,.07) !important; transform: none; }
.nav-sidebar .nav-link[aria-current="page"] { background: rgba(182,134,44,.95) !important; }

/* Legacy pages also enable layout-navbar-fixed, which otherwise fixes the brand. */
.layout-fixed .main-sidebar .brand-link { position: relative !important; top: auto !important; }
.main-sidebar .nav-sidebar > .nav-item { margin: 0; padding: 0; }
.main-sidebar .nav-sidebar > .nav-item > .nav-link {
  box-sizing: border-box; width: calc(100% - 16px) !important;
  min-height: 42px; height: 42px; padding: 8px 16px !important;
  margin: 3px 8px !important; line-height: 24px;
}
.main-sidebar .nav-sidebar > .nav-item > .nav-link p { line-height: 24px; }

body { font-family: "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif; }
.main-sidebar .nav-sidebar > .nav-item > .nav-link p { font-size: 16px !important; white-space: nowrap; }
.main-sidebar .nav-sidebar .nav-icon { flex-shrink: 0; }

#imagePreviewModalLarge, #imageManagerPreviewModal, #cotizacionPreviewModal { font-family: "Segoe UI", Arial, sans-serif !important; }
#imagePreviewModalLarge .modal-title, #imageManagerPreviewModal .modal-title, #cotizacionPreviewModal .modal-title { font-family: inherit !important; }
