/* No-backdrop CSS for prescription plugin - removes modal backdrop to prevent flickering */

.prescription-section {
  border: 1px solid #05b9d2;
  border-radius: 0.375rem;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.prescription-form-section h5 {
  color: #495057;
  font-weight: 600;
  border-bottom: 2px solid #007bff;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.prescription-form-section h6 {
  color: #495057;
  font-weight: 500;
  margin-bottom: 0.75rem;
  margin-top: 1rem;
}

.form-label {
  font-weight: 500;
  color: #495057;
}

.form-label i.fas.fa-info-circle {
  color: #6c757d;
  margin-left: 0.25rem;
  cursor: help;
}

.form-label i.fas.fa-info-circle:hover {
  color: #007bff;
}

.form-check-label {
  font-weight: 400;
  color: #495057;
}

.btn-primary {
  background-color: #007bff;
  border-color: #007bff;
}

.btn-primary:hover {
  background-color: #0056b3;
  border-color: #004085;
}

/* Modal without backdrop - prevents flickering - SPECIFIC RULES */
#prescriptionProductModal {
  background-color: rgba(0, 0, 0, 0.5) !important;
  z-index: 1060 !important;
}

#prescriptionProductModal .modal-dialog {
  margin: 1.75rem auto;
  z-index: 1065 !important;
}

#prescriptionProductModal .modal-content {
  z-index: 1070 !important;
}

/* Prevent conflicts with page accordion */
#productDescriptionAccordion {
  z-index: 1 !important;
}

#productDescriptionAccordion .accordion-item {
  z-index: 1 !important;
}

/* Ensure prescription modal is always on top */
#prescriptionProductModal.show {
  display: block !important;
  z-index: 1060 !important;
}

/* Order prescription display */
.order-prescription-data {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  padding: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.order-prescription-data strong {
  color: #495057;
  font-weight: 600;
}

.product-name dt.variation- {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .product-header .col-md-4.text-end {
    text-align: left !important;
    margin-top: 1rem;
  }

  .prescription-section {
    padding: 1rem;
  }

  .modal-dialog.modal-lg {
    margin: 0.5rem;
  }
}

/* Loading states */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

.spinner-border-sm {
  width: 1rem;
  height: 1rem;
}

/* Form validation feedback */
.is-invalid {
  border-color: #dc3545;
}

.invalid-feedback {
  display: block;
  color: #dc3545;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Success states */
.alert-success {
  background-color: #d1edff;
  border-color: #b8daff;
  color: #004085;
}

.alert-danger {
  background-color: #f8d7da;
  border-color: #f5c6cb;
  color: #721c24;
}

/* Prescription Table Styles */
.prescricao-container {
  background-color: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1.5rem;
}

.prescricao-container h5 {
  color: #495057;
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: center;
}

.prescricao-tabela {
  display: table;
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1rem;
  table-layout: fixed;
}

.prescricao-header {
  display: table-row;
  background-color: #f8f9fa;
  border-bottom: 2px solid #dee2e6;
}

.prescricao-linha {
  display: table-row;
  border-bottom: 1px solid #dee2e6;
}

.prescricao-linha:last-child {
  border-bottom: none;
}

.campo-vazio {
  display: table-cell;
  width: 120px;
  padding: 0.75rem;
  font-weight: 600;
  color: #495057;
  vertical-align: middle;
  text-align: center;
  background-color: #f8f9fa;
}

.campo-titulo {
  display: table-cell;
  padding: 0.75rem;
  font-weight: 600;
  color: #495057;
  text-align: center;
  vertical-align: middle;
  background-color: #f8f9fa;
  border-right: 1px solid #dee2e6;
  min-width: 120px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  line-height: 1.4;
  font-size: 10px !important;
  text-align: center;
}

.campo-titulo:last-child {
  border-right: none;
}

.campo-titulo small {
  display: block;
  font-size: 0.75rem;
  color: #6c757d;
  margin-top: 0.25rem;
}

.help-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-color: #6c757d;
  color: #fff;
  border-radius: 50%;
  text-align: center;
  line-height: 16px;
  font-size: 10px;
  margin-left: 0.25rem;
  cursor: help;
}

.campo-select:last-child {
  border-right: none;
}

.prescricao-campo {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #333;
  border-radius: 0.25rem;
  background-color: #fff;
  font-size: 0.9rem;
  color: #495057;
}

.acoes-prescricao {
  text-align: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #dee2e6;
}

.btn-copiar-prescricao {
  background-color: #28a745;
  color: #fff;
  border: 1px solid #28a745;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-copiar-prescricao:hover {
  background-color: #218838;
  border-color: #1e7e34;
  color: #fff;
}

/* Origin Data Styles */
.origem-dados {
  background-color: #fff;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.origem-dados h6 {
  color: #495057;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.opcoes-origem {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.origem-opcao {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 0.9rem;
  color: #495057;
}

.origem-opcao input[type="checkbox"] {
  margin-right: 0.5rem;
}

.checkmark {
  margin-left: 0.25rem;
}

/* Responsive adjustments for prescription table */
@media (max-width: 768px) {
  .prescricao-tabela {
    display: block !important;
  }

  .prescricao-header {
    display: none !important; /* Hide header on mobile */
  }

  .prescricao-linha {
    display: block !important;
    margin-bottom: 0;
    border: none;
    padding: 0;
    background: transparent;
  }

  .olho-label {
    display: none !important; /* Hide eye label in mobile - will show inline */
  }

  .campo-select {
    display: flex !important;
    align-items: center;
    width: 100%;
    padding: 10px 0 !important;
    border: none !important;
    border-bottom: 1px solid #e9ecef;
    min-width: auto !important;
    gap: 15px;
  }

  .campo-select:last-child {
    border-bottom: none;
  }

  .campo-select::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    color: #000;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex: 0 0 auto;
    width: 110px;
    text-align: left;
    line-height: 1.2;
  }

  .prescricao-campo {
    flex: 1;
    width: auto !important;
    padding: 10px 12px !important;
    font-size: 0.9rem !important;
    border: 1px solid #333 !important;
    border-radius: 4px !important;
    background-color: white !important;
    transition: all 0.2s ease;
    min-height: 38px;
  }

  .prescricao-campo:focus {
    border-color: #05b9d2 !important;
    box-shadow: 0 0 0 2px rgba(5, 185, 210, 0.1) !important;
    background-color: white !important;
    outline: none;
  }

  .campo-vazio,
  .campo-titulo {
    display: none !important;
  }

  /* Add eye section headers */
  .prescricao-linha::before {
    content: "👁️ OLHO DIREITO (OD)";
    display: block;
    font-weight: 700;
    color: #000;
    font-size: 0.85rem;
    padding: 12px 0 8px 0;
    margin-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
  }

  .prescricao-linha[id="oe_section_product"]::before {
    content: "👁️ OLHO ESQUERDO (OE)";
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #dee2e6;
  }

  .olho-label {
    display: none !important;
  }
}

/* Tablet adjustments */
@media (max-width: 992px) and (min-width: 769px) {
  .prescricao-tabela {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .campo-titulo {
    font-size: 0.85rem;
    line-height: 1.3;
    min-width: 100px;
  }

  .olho-label {
    font-size: 0.85rem;
    line-height: 1.3;
    padding: 0.6rem;
  }
}

/* Additional mobile improvements */
@media (max-width: 768px) {
  .prescricao-container {
    padding: 0 !important;
  }

  .form-check {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 15px !important;
  }

  .form-check-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #495057;
  }

  /* Style for "Mesmo grau" checkbox */
  #same_grade_product {
    width: 20px;
    height: 20px;
    margin-right: 10px;
  }

  /* Origin data section mobile */
  .origem-dados {
    padding: 15px;
    margin-bottom: 20px;
  }

  .origem-dados h6 {
    font-size: 1rem;
    margin-bottom: 12px;
  }

  .opcoes-origem {
    flex-direction: column;
    gap: 12px;
  }

  .origem-opcao {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    transition: all 0.3s ease;
  }

  .origem-opcao:has(input:checked) {
    background: #e7f5ff;
    border-color: #667eea;
  }

  .origem-opcao input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
  }

  .origem-opcao label {
    font-size: 0.95rem;
    font-weight: 500;
  }

  /* Observations section */
  .observations-section textarea {
    font-size: 1rem !important;
    padding: 12px !important;
    min-height: 100px;
  }

  /* Prescription section padding */
  .prescription-section {
    padding: 15px !important;
    margin-bottom: 20px;
  }

  .prescription-section h5 {
    font-size: 1.1rem;
    margin-bottom: 15px;
  }

  /* File upload section */
  #prescription_file {
    font-size: 0.95rem;
    padding: 10px;
  }

  .form-text {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  /* File preview */
  #file_preview_container {
    gap: 10px !important;
  }

  .file-preview-item {
    width: 100% !important;
    max-width: none !important;
  }
}

/* Quantity fields integrated in prescription table */
.quantidade-linha {
  background-color: #f8f9fa;
  border-top: 2px solid #007bff;
}

.quantidade-linha .olho-label {
  background-color: #e3f2fd;
  color: #1976d2;
  font-weight: 700;
  font-size: 0.9rem;
}

.quantidade-linha .prescricao-campo {
  border: 2px solid #007bff;
  font-weight: 600;
  text-align: center;
}

.quantidade-linha .prescricao-campo:focus {
  border-color: #0056b3;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Quantity info in cart */
.quantity-info {
  background-color: #e9ecef;
  border: 1px solid #dee2e6;
  border-radius: 0.25rem;
  padding: 0.75rem;
  margin: 0.75rem 0;
}

.quantity-info h5 {
  color: #495057;
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.quantity-info p {
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
}

/* Fix for layout breaking after prescription fill */
.prescricao-linha {
  display: table-row !important;
  border-bottom: 1px solid #dee2e6;
}

.prescricao-linha:last-child {
  border-bottom: none;
}

.olho-label {
  display: table-cell !important;
  /* width: 120px; */
  padding: 0.75rem;
  font-weight: 600;
  color: #495057;
  text-align: center;
  vertical-align: middle;
  background-color: #e9ecef;
  border-right: 1px solid #dee2e6;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  font-size: 0.75rem;
}

.campo-select {
  display: table-cell !important;
  padding: 0.75rem;
  vertical-align: middle;
  border-right: 1px solid #dee2e6;
  min-width: 120px;
}

.prescricao-campo {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
  background-color: #fff;
  font-size: 0.9rem;
  color: #495057;
}

.prescricao-campo:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
  outline: none;
}
