/* Static Map Styles for Visit Location */
.visit-location-map img {
  max-width: 100%;
  height: auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.visit-location-info {
  background: #f8f9fa;
  padding: 15px;
  border-radius: 6px;
  border: 1px solid #e9ecef;
}

.visit-location-links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.visit-location-links .button {
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  display: inline-block;
  color: white;
}

/* Custom styles for Active Admin forms */

/* Make select2 dropdowns wider in master forms */
.edit_master .select2-container,
.new_master .select2-container {
  min-width: 400px !important;
  width: 100% !important;
  max-width: 600px !important;
}

/* Style for select2 selection box */
.edit_master .select2-selection,
.new_master .select2-selection {
  min-height: 38px !important;
  padding: 4px !important;
}

/* Make the dropdown results wider only in master forms */
.edit_master .select2-dropdown,
.new_master .select2-dropdown {
  min-width: 400px !important;
}

/* General form input improvements for masters */
.edit_master input[type="text"],
.edit_master input[type="number"],
.edit_master select,
.new_master input[type="text"],
.new_master input[type="number"],
.new_master select {
  min-width: 400px;
  width: 100%;
  max-width: 600px;
}

/* Specific styles for category selects */
#master_seccion_input .select2-container,
#master_categoria_input .select2-container,
#master_subcategoria_input .select2-container,
#master_clase_input .select2-container,
#master_sector_input .select2-container,
#master_nivel1_input .select2-container,
#master_nivel2_input .select2-container,
#master_nivel3_input .select2-container {
  width: 100% !important;
  max-width: 600px !important;
}

/* Make form labels more visible */
.edit_master label,
.new_master label {
  font-weight: 600;
  color: #333;
  min-width: 150px;
  display: inline-block;
}

/* Improve form fieldset spacing */
.edit_master fieldset,
.new_master fieldset {
  margin-bottom: 2rem;
}

/* Make the form inputs container wider */
.edit_master .inputs,
.new_master .inputs {
  max-width: 900px;
}

/* Style for form list items */
.edit_master fieldset > ol > li,
.new_master fieldset > ol > li {
  margin-bottom: 1.5rem;
}

/* Improve select2 search box */
.select2-search__field {
  width: 100% !important;
  padding: 6px !important;
}

/* Better hover state for select2 options */
.select2-results__option--highlighted {
  background-color: #3b82f6 !important;
}

/* Style for disabled select2 */
.select2-container--disabled .select2-selection {
  background-color: #f3f4f6;
  cursor: not-allowed;
}

/* Ensure category hierarchy is visible */
.select2-results__option {
  padding: 8px 12px !important;
  font-size: 14px !important;
}

/* Add some spacing between form sections */
#master_seccion_input,
#master_categoria_input,
#master_subcategoria_input,
#master_clase_input,
#master_sector_input,
#master_nivel1_input,
#master_nivel2_input,
#master_nivel3_input {
  margin-bottom: 1.2rem;
}

/* Styles for Master Show Page */
.master-info-panel .panel_contents {
  padding: 20px;
}

.category-hierarchy {
  display: flex;
  align-items: center;
  padding: 8px 0;
  font-size: 14px;
}

.category-icon {
  margin-right: 10px;
  font-size: 18px;
}

.categorization-panel {
  background: #f0f8ff;
}

.categorization-panel h3 {
  background: #4a90e2;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.custom-categorization-panel {
  background: #f5f5ff;
}

.custom-categorization-panel h3 {
  background: #7c3aed;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.butcher-info-panel {
  background: #fff5f5;
}

.butcher-info-panel h3 {
  background: #dc2626;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.additional-info-panel {
  background: #f9fafb;
}

.additional-info-panel h3 {
  background: #6b7280;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.image-panel h3 {
  background: #10b981;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.quick-actions-panel h3 {
  background: #f59e0b;
  color: white;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

.special-status-panel h3 {
  background: #ffc107;
  color: #856404;
  padding: 10px 15px;
  margin: 0;
  font-size: 14px;
}

/* Improve attribute tables in show view */
.attributes_table th {
  width: 150px;
  font-weight: 600;
  color: #4b5563;
  background: #f9fafb;
  padding: 10px 15px;
}

.attributes_table td {
  padding: 10px 15px;
}

/* Style for product image container */
.product-image-container {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  padding: 2px;
  border-radius: 10px;
}

.product-image-container > a {
  display: inline-block;
  background: white;
  padding: 20px;
  border-radius: 8px;
}

/* Hover effects for panels */
.panel:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.3s ease;
}

/* Button styles in show view */
.quick-actions-panel .button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  color: white;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 6px;
  transition: transform 0.2s ease;
}

.quick-actions-panel .button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Status tags improvements - class-based (used by status_tag class: option) */
.status_tag.yes, .status-tag.yes {
  background: #10b981 !important;
  color: white !important;
}

.status_tag.no, .status-tag.no {
  background: #ef4444 !important;
  color: white !important;
}

.status_tag.warning, .status-tag.warning {
  background: #f59e0b !important;
  color: white !important;
}

.status_tag.primary, .status-tag.primary,
.status_tag.blue, .status-tag.blue {
  background: #3b82f6 !important;
  color: white !important;
}

.status_tag.orange, .status-tag.orange {
  background: #f97316 !important;
  color: white !important;
}

/* Status tags - data-status based (ActiveAdmin v4 uses data-status attribute) */
.status-tag[data-status="published"],
.status-tag[data-status="closed"] {
  background: #10b981 !important;
  color: white !important;
}

.status-tag[data-status="performed"] {
  background: #f97316 !important;
  color: white !important;
}

.status-tag[data-status="progress"] {
  background: #f59e0b !important;
  color: white !important;
}

.status-tag[data-status="planned"] {
  background: #3b82f6 !important;
  color: white !important;
}

.status-tag[data-status="not_published"] {
  background: #f59e0b !important;
  color: white !important;
}

.status-tag[data-status="rejected"] {
  background: #ef4444 !important;
  color: white !important;
}

.status-tag[data-status="activo"] {
  background: #10b981 !important;
  color: white !important;
}

.status-tag[data-status="inactivo"] {
  background: #ef4444 !important;
  color: white !important;
}

.status-tag[data-status="nuevo"] {
  background: #f59e0b !important;
  color: white !important;
}

/* Responsive columns for show view */
@media (max-width: 768px) {
  .columns {
    display: block !important;
  }

  .column {
    width: 100% !important;
    margin-bottom: 20px;
  }
}

/* MagnificPopup custom styles */
.mfp-bg {
  background: rgba(0, 0, 0, 0.9) !important;
}

.mfp-figure {
  background: transparent !important;
}

.mfp-container {
  padding: 40px;
}

.mfp-image-holder .mfp-close {
  color: white !important;
  font-size: 36px !important;
  opacity: 0.8;
  right: 20px;
  top: 20px;
}

.mfp-image-holder .mfp-close:hover {
  opacity: 1;
}

.mfp-title {
  color: white !important;
  font-size: 16px !important;
  padding: 8px 24px !important;
  background: rgba(0, 0, 0, 0.7);
  margin-top: 10px;
  border-radius: 4px;
}

.mfp-img {
  max-height: 90vh !important;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border-radius: 8px;
}

/* Ensure image popup links work in show view */
.product-image-container a.image-popup {
  cursor: zoom-in;
  position: relative;
  display: block;
}

.product-image-container a.image-popup:hover img {
  opacity: 0.95;
  transform: scale(1.02);
  transition: all 0.3s ease;
}

/* Add zoom icon on hover */
.product-image-container a.image-popup::after {
  content: "🔍";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.product-image-container a.image-popup:hover::after {
  opacity: 0.8;
}

/* Styles for General Categories Form */
.general_categories.new form fieldset.inputs,
.general_categories.edit form fieldset.inputs {
  padding: 0;
}

/* Styles for Custom Categories Form */
.custom_categories.new form fieldset.inputs,
.custom_categories.edit form fieldset.inputs {
  padding: 0;
}

.general_categories.new form fieldset.inputs ol,
.general_categories.edit form fieldset.inputs ol,
.custom_categories.new form fieldset.inputs ol,
.custom_categories.edit form fieldset.inputs ol {
  padding: 20px 30px;
  margin: 0;
}

.general_categories.new form fieldset.inputs ol > li,
.general_categories.edit form fieldset.inputs ol > li,
.custom_categories.new form fieldset.inputs ol > li,
.custom_categories.edit form fieldset.inputs ol > li {
  padding: 12px 0;
  margin: 0 0 15px 0;
  list-style: none;
}

.general_categories.new form fieldset.inputs ol > li label,
.general_categories.edit form fieldset.inputs ol > li label,
.custom_categories.new form fieldset.inputs ol > li label,
.custom_categories.edit form fieldset.inputs ol > li label {
  width: 25%;
  float: left;
  text-align: left;
  padding-right: 15px;
  padding-left: 0;
}

.general_categories.new form fieldset.inputs ol > li input,
.general_categories.edit form fieldset.inputs ol > li input,
.general_categories.new form fieldset.inputs ol > li select,
.general_categories.edit form fieldset.inputs ol > li select {
  width: 70%;
  float: left;
}

.level-input {
  margin-bottom: 15px;
  padding: 12px 0;
  background: transparent;
  border-radius: 5px;
  clear: both;
}

.level-input label {
  width: 25% !important;
  float: left !important;
  text-align: left !important;
  padding-right: 15px !important;
  padding-left: 0 !important;
}

.level-input input,
.level-input select {
  width: 70% !important;
  float: left !important;
}

#general_category_level_type {
  width: 100%;
  max-width: 600px;
}

#parent_selection {
  margin-top: 20px;
  margin-bottom: 20px;
  clear: both;
}

#parent_selection {
  padding: 12px 0;
  background: transparent;
  border-radius: 5px;
  margin: 15px 0;
}

#parent_selection label {
  width: 25% !important;
  float: left !important;
  text-align: left !important;
  padding-right: 15px !important;
  padding-left: 0 !important;
}

#parent_selection .select2-container {
  width: 70% !important;
  float: left !important;
}

#value_inputs {
  margin-top: 15px;
  clear: both;
}

#inherited_fields_notice {
  margin-bottom: 15px;
  margin-left: 20%;
  width: 75%;
}

/* Ensure proper field widths */
#general_category_seccion,
#general_category_categoria,
#general_category_subcategoria,
#general_category_clase {
  width: 100%;
  max-width: 600px;
}

/* Fix for form hints */
.general_categories p.inline-hints {
  margin-left: 25%;
  clear: both;
  padding-top: 5px;
  color: #666;
  font-size: 0.9em;
}

/* Fix alignment for dynamic fields */
.level-input li.input {
  clear: both;
  overflow: hidden;
}

.level-input li.input:after {
  content: "";
  display: table;
  clear: both;
}

/* Fix for boolean checkbox */
.general_categories .boolean label {
  width: auto !important;
  float: none !important;
  margin-left: 25%;
}

.general_categories .boolean input[type="checkbox"] {
  width: auto !important;
  float: none !important;
  margin-right: 10px;
}

/* Clear floats */
.general_categories form fieldset.inputs ol > li:after {
  content: "";
  display: table;
  clear: both;
}

/* Panel styles */
.general_categories .panel {
  margin-bottom: 20px;
}

.general_categories .panel h3 {
  font-size: 1.1em;
  padding: 10px 15px;
  margin: 0;
}

/* Specific styles for the form panel content */
.general_categories form .panel_contents {
  padding: 20px 30px !important;
}

/* Ensure proper spacing for fields inside panels */
.general_categories #value_inputs > div {
  padding: 12px 0;
  margin: 10px 0;
}

/* Special handling for parent_id field with Select2 - only in forms, not index */
.general_categories.new #general_category_parent_id_input .select2-container,
.general_categories.edit #general_category_parent_id_input .select2-container,
.custom_categories.new #custom_category_parent_id_input .select2-container,
.custom_categories.edit #custom_category_parent_id_input .select2-container {
  width: 70% !important;
  max-width: 600px !important;
}

/* Width for the Select2 wrapper span */
.general_categories.new #general_category_parent_id_input > span,
.general_categories.edit #general_category_parent_id_input > span,
.custom_categories.new #custom_category_parent_id_input > span,
.custom_categories.edit #custom_category_parent_id_input > span {
  width: 80% !important;
}

.general_categories li[data-field-type="parent-selection"] {
  padding: 12px 0;
  margin: 0 0 15px 0;
}

/* Style the level type selector with proper spacing */
.general_categories li.select.input.optional {
  padding: 12px 0 !important;
  margin: 0 0 15px 0 !important;
  background: transparent;
}

/* Active checkbox styling */
.general_categories li.boolean.input.optional {
  padding: 12px 0 !important;
  margin: 0 0 15px 0 !important;
  background: transparent;
}

/* Account Cards Grid Styles */
/* ActiveAdmin uses table structure for grid, so we need to style the table cells */
.custom-grid table {
  width: 100%;
  table-layout: auto;
  border-collapse: separate;
  border-spacing: 20px;
}

.custom-grid tbody {
  display: block;
  width: 100%;
}

.custom-grid tr {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin: 0;
  justify-content: flex-start;
}

.custom-grid td.account {
  display: block;
  width: 280px !important; /* Fixed width for all cards */
  flex: 0 0 280px; /* Prevent flex from changing the width */
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
}

/* Ensure all account cards have the same size */
.custom-grid .account-card {
  width: 280px !important; /* Fixed width */
  height: 100%;
  margin: 0 !important;
  display: flex !important;
  flex-direction: column !important;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .custom-grid td.account {
    width: 100% !important;
    flex: 0 0 100%;
    max-width: 100%;
  }

  .custom-grid .account-card {
    width: 100% !important;
  }

  .custom-grid tr {
    flex-direction: column;
    align-items: center;
  }
}

@media (min-width: 641px) and (max-width: 1024px) {
  .custom-grid td.account {
    width: 260px !important;
    flex: 0 0 260px;
  }

  .custom-grid .account-card {
    width: 260px !important;
  }
}

@media (min-width: 1025px) {
  /* Default 280px width is maintained */
}

/* Spacing for pagination in Locals Summary panel */
.locals-summary-panel .panel_contents nav.pagination,
.locals-summary-panel .panel_contents .pagination {
  margin: 12px 15px 18px;
}

/* Footer pagination layout and spacing like ActiveAdmin */
.locals-summary-panel .paginated_collection_footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px; /* inner spacing so it doesn't touch panel border */
  border-top: 1px solid #e5e7eb; /* subtle separator above footer */
  background: transparent;
}

/* Reset margins for pagination inside footer to avoid collapsing with panel border */
.locals-summary-panel .paginated_collection_footer nav.pagination,
.locals-summary-panel .paginated_collection_footer .pagination {
  margin: 0; /* override top helper spacing */
}

/* Tweak info text color to match AA tone */
.locals-summary-panel .paginated_collection_footer .pagination_information {
  color: #6b7280; /* gray-600 */
}

/* Account Card Logo Link Hover Effect */
.account-card .logo-container {
  position: relative;
}

.account-card .logo-link {
  position: relative;
  display: block;
  cursor: pointer;
}

/* Ensure icon is above image */
.account-card .logo-link .link-icon {
  z-index: 100 !important;
}

/* ========================================
   Planogram Items - Bandeja Grouping
   ======================================== */

/* Group header row */
.bandeja-group-header {
  cursor: pointer;
  user-select: none;
  background: #f8fafc !important;
  border-left: 3px solid #6366f1;
}

.bandeja-group-header + .bandeja-row {
  border-top: none;
}

/* Visual separation between groups */
.bandeja-row + .bandeja-group-header td {
  border-top: 2px solid #e2e8f0;
}

.bandeja-group-header:hover {
  background: #eef2ff !important;
}

.bandeja-group-header td {
  padding: 10px 14px !important;
  border-bottom: 1px solid #e2e8f0;
}

.bandeja-header-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bandeja-chevron {
  width: 18px;
  text-align: center;
  color: #6366f1;
  font-size: 12px;
}

.bandeja-label {
  font-weight: 700;
  font-size: 13px;
  color: #1e293b;
  letter-spacing: 0.02em;
}

.bandeja-count {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
  background: #e2e8f0;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

/* Tags for promo/laminado/pesable */
.pi-tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.pi-tag-green {
  background: #dcfce7;
  color: #166534;
}

.pi-tag-blue {
  background: #dbeafe;
  color: #1e40af;
}

/* Footer summary */
.bandeja-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-size: 12px;
  color: #64748b;
}

.bandeja-footer-total {
  font-weight: 600;
  color: #475569;
}

.bandeja-footer-sep {
  color: #cbd5e1;
  font-size: 14px;
}

.bandeja-footer-info {
  color: #94a3b8;
}

/* Dark mode */
.dark .bandeja-group-header {
  background: #1e293b !important;
  border-left-color: #818cf8;
}

.dark .bandeja-group-header:hover {
  background: #334155 !important;
}

.dark .bandeja-group-header td {
  border-bottom-color: #334155;
}

.dark .bandeja-chevron {
  color: #818cf8;
}

.dark .bandeja-label {
  color: #e2e8f0;
}

.dark .bandeja-count {
  color: #94a3b8;
  background: #334155;
}

.dark .pi-tag-green {
  background: #064e3b;
  color: #6ee7b7;
}

.dark .pi-tag-blue {
  background: #1e3a5f;
  color: #93c5fd;
}

.dark .bandeja-footer {
  background: #1e293b;
  border-color: #334155;
}

.dark .bandeja-footer-total {
  color: #cbd5e1;
}

.dark .bandeja-footer-sep {
  color: #475569;
}

.dark .bandeja-footer-info {
  color: #64748b;
}

.dark .bandeja-row + .bandeja-group-header td {
  border-top-color: #475569;
}

