@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
  --primary-color: #4a90e2;
  --secondary-color: #f5a623;
  --text-color: #333;
  --bg-color: #f4f7f6;
  --card-bg: #ffffff;
  --border-color: #e6e6e6;
}

body {
  background-color: var(--bg-color);
  font-family: 'Poppins', sans-serif;
  color: var(--text-color);
  background-image: var(--background-image);
  background-size: cover;
  background-repeat: no-repeat;
}

.container {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.card {
  border: none;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  margin-bottom: 0.5rem;
}

.card-header {
  background-color: var(--primary-color);
  color: white;
  font-weight: 600;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
  padding: 1rem 1.5rem;
}

.card-body {
  padding: 1rem;
}

#prescriptionForm .card:first-child .form-control,
#prescriptionForm .card:first-child .form-select {
  text-align: left;
}

.table tbody td {
  padding: 0.25rem;
  text-align: center;
  vertical-align: middle;
}

.table th {
  padding: 0.5rem;
  vertical-align: middle;
}

#prescriptionTable tbody {
  margin-bottom: 0;
}

#prescriptionTable {
  margin-bottom: 0;
}

.form-label {
  font-weight: 500;
}

.form-control, .form-select {
  border-radius: 8px;
  border-color: var(--border-color);
  padding: 0.5rem 0.75rem;
}

.card-body .form-control, .card-body .form-select {
  text-align: center;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.25rem rgba(74, 144, 226, 0.25);
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  padding-right: 1.5rem;
}

.iti {
  width: 100%;
}

.iti__flag-container {
  z-index: 5;
}

.btn-primary {
  background-color: var(--primary-color);
  border-color: var(--primary-color);
  border-radius: 50px;
  padding: 0.75rem 1.75rem;
  font-weight: 600;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
  box-shadow: 0 5px 15px rgba(74, 144, 226, 0.3);
}

.btn-primary:hover {
  background-color: #357abd;
  border-color: #357abd;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(74, 144, 226, 0.4);
}

.btn-outline-danger {
  border-color: #dc3545;
  color: #dc3545;
  border-radius: 50px;
  padding: 0.75rem 1.75rem;
  font-weight: 600;
  transition: all 0.3s ease;
  letter-spacing: 0.5px;
}

.btn-outline-danger:hover {
  background-color: #dc3545;
  color: white;
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(220, 53, 69, 0.4);
}

.btn-success {
    border-radius: 50px;
    padding: 0.75rem 1.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    box-shadow: 0 5px 15px rgba(25, 135, 84, 0.3);
}

.btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(25, 135, 84, 0.4);
}

.watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  opacity: 0.03;
  font-size: 6em;
  color: var(--primary-color);
  pointer-events: none;
  z-index: -1;
}

.signature-display {
  display: flex;
  justify-content: flex-end;
  width: 100%;
  margin-top: 2em;
}

.print-signature {
  display: none;
  font-weight: bold;
  font-size: 1.1em;
  margin-top: 2em;
  text-align: right;
}

.signature-view {
  font-weight: 600;
  font-size: 1.1em;
  color: #333;
  min-width: 250px;
  border-top: 1px solid #bbb;
  padding-top: 0.5em;
  margin-right: 1.5em;
  letter-spacing: 0.02em;
  text-align: right;
}

#options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.2rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
  /* Ensure options don't overflow card */
  max-width: 100%;
}

#options .form-check {
  min-width: 140px;
  margin-bottom: 0.3rem;
  margin-right: 0.5rem;
  flex: 0 0 auto;
}

@media (max-width: 600px) {
  #options .form-check {
    min-width: 110px;
    font-size: 0.97em;
  }
}

.axis-input {
  text-align: center;
}

.axis-print-view {
  display: none;
}

@media print {
  .axis-input {
    display: none !important;
  }

  .axis-print-view {
    display: block !important;
    text-align: center;
    width: 100%;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    background-color: #fff !important; /* Ensure solid background */
  }

  body {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .container {
    padding-top: 0;
    padding-bottom: 0;
  }

  .btn, .form-switch {
    display: none !important;
  }

  .card, .table, .table th, .table td {
    background-color: transparent !important;
  }

  .card {
    border: 1px solid var(--border-color) !important;
    box-shadow: none !important;
    margin-bottom: 1rem; /* Reduce margin for print */
  }

  .card-header {
    background-color: var(--primary-color) !important;
    color: white !important;
  }

  .watermark {
    display: none !important;
  }

  body.print-watermark::before {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 80vw;
    height: 80vh;
    transform: translate(-50%, -50%) rotate(-45deg);
    background-image: url('background.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.05;
    z-index: -1;
  }


  /* Ensure footer is visible when printing */
  footer {
    display: block !important;
    visibility: visible !important;
    position: static !important;
  }

  .print-signature {
    display: block !important;
  }

  /* Ensure grid layout is maintained for print */
  .row.mt-4 {
    display: flex;
    flex-wrap: wrap;
  }

  .col-md-6 {
    flex: 0 0 50%;
    max-width: 50%;
  }

  body:not(.print-lens-options) #lensOptionsCard,
  body:not(.print-other-details) #otherDetailsCard {
    display: none !important;
  }

  #prescriptionTable tbody tr:last-child td {
    border-bottom: none;
  }
}

#clinicAddress {
  margin-bottom: 0;
  color: var(--text-muted);
  text-align: right;
}

#clinicPhone {
  text-align: right;
}
