/**
 * Base Tailwind Styles
 * Common styles used across all pages
 */

/* Global Font Family */
body,
html {
}

* {
  font-family: inherit;
}

/* DM Sans Font Class */
.dm-sans {
  font-family: "DM Sans", sans-serif;
  font-optical-sizing: auto;
  font-style: normal;
}

/* Geist Font Class */
.geist {
  font-family: "Geist", sans-serif;
  font-optical-sizing: auto;
  font-style: normal;
}

/* Dropdown Menu Component */
.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 1000;
  display: none;
  min-width: 10rem;
  padding: 0.5rem 0;
  margin: 0.125rem 0 0;
  font-size: 0.875rem;
  color: #1f2937;
  text-align: left;
  list-style: none;
  background-color: #ffffff;
  background-clip: padding-box;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
    0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dropdown.open .dropdown-menu,
.dropdown-menu.show {
  display: block;
}

.dropdown-menu > li > a,
.dropdown-menu > li > button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  clear: both;
  font-weight: 400;
  color: #1f2937;
  text-align: inherit;
  white-space: nowrap;
  background-color: transparent;
  border: 0;
  cursor: pointer;
  text-decoration: none;
}

.dropdown-menu > li > a:hover,
.dropdown-menu > li > a:focus,
.dropdown-menu > li > button:hover,
.dropdown-menu > li > button:focus {
  color: #111827;
  background-color: #f3f4f6;
}

.dropdown-menu > li > a:active,
.dropdown-menu > li > button:active {
  color: #ffffff;
  background-color: #3b82f6;
}

.dropdown-menu .divider {
  height: 1px;
  margin: 0.5rem 0;
  overflow: hidden;
  background-color: #e5e7eb;
}

/* Loading Bar - Angular Loading Bar Styles */
#loading-bar,
#loading-bar-spinner {
  pointer-events: none;
  transition: 350ms linear all;
}

#loading-bar.ng-enter,
#loading-bar.ng-leave.ng-leave-active,
#loading-bar-spinner.ng-enter,
#loading-bar-spinner.ng-leave.ng-leave-active {
  opacity: 0;
}

#loading-bar.ng-enter.ng-enter-active,
#loading-bar.ng-leave,
#loading-bar-spinner.ng-enter.ng-enter-active,
#loading-bar-spinner.ng-leave {
  opacity: 1;
}

#loading-bar .bar {
  transition: width 350ms;
  background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 50%, #3b82f6 100%);
  background-size: 200% 100%;
  animation: loading-bar-shimmer 1.5s ease-in-out infinite;
  position: fixed;
  z-index: 10002;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  border-radius: 0 2px 2px 0;
}

#loading-bar .peg {
  position: absolute;
  width: 100px;
  right: 0;
  top: 0;
  height: 3px;
  opacity: 0.6;
  box-shadow: #3b82f6 1px 0 10px 2px;
  border-radius: 100%;
}

@keyframes loading-bar-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Hide the default spinner - we use our own */
#loading-bar-spinner {
  display: none;
}

/* Angular Cloak */
[ng-cloak] {
  display: none !important;
}

/* Input Styles - Modern shadcn inspired */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
textarea {
  display: flex;
  height: 2.5rem; /* h-10 */
  width: 100%;
  min-width: 0;
  border-radius: 0.75rem; /* rounded-xl */
  border: 1px solid #d1d5db; /* border-border */
  background-color: #ffffff;
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem; /* 13px */
  line-height: 1.25rem;
  color: #555555;
  outline: none;
  transition: all 0.2s;
}

/* Select - Custom modern design */
select {
  height: 2.5rem; /* h-10 - same as input */
  width: 100%;
  min-width: 0;
  border-radius: 0.75rem; /* rounded-xl */
  border: 1px solid #d1d5db;
  background-color: #ffffff;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
  padding-left: 0.75rem; /* Same as input */
  padding-right: 2.5rem; /* Space for arrow */
  font-size: 0.8125rem; /* 13px */
  line-height: 1.25rem;
  color: #555555;
  outline: none;
  transition: all 0.2s;
  cursor: pointer;
  /* Custom dropdown arrow */
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23555555' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1.25rem;
}

/* Larger screens */
@media (min-width: 640px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  textarea {
    height: 3rem; /* sm:h-12 */
    font-size: 0.875rem; /* 14px */
  }

  select {
    height: 3rem; /* sm:h-12 - same as input */
    font-size: 0.875rem; /* 14px */
    padding-left: 0.75rem; /* Same as input */
    padding-right: 2.5rem;
  }
}

/* Label Styles */
label {
  font-size: 0.9375rem; /* 15px */
  font-weight: 500;
  font-weight: normal;
  color: #2e323a; /* text-gray-800 */
  margin-bottom: 0.5rem; /* 8px gap between label and input */
  line-height: 1.5;
}

/* Labels with flex/inline-flex classes should respect them */
label.flex,
label.inline-flex {
  display: flex !important;
}

label.inline-flex {
  display: inline-flex !important;
}

/* Form group spacing */
.form-group,
.control-group {
  margin-bottom: 1.25rem; /* 20px spacing between form groups */
}

/* Placeholder styling */
input::placeholder,
textarea::placeholder {
  color: #999999;
}

/* Selection styling */
input::selection,
textarea::selection {
  background-color: #0099e6;
  color: white;
}

/* Focus state */
input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Select hover state */
select:hover:not(:disabled) {
  border-color: #9ca3af;
}

/* Disabled state */
input:disabled,
textarea:disabled,
select:disabled {
  pointer-events: none;
  cursor: not-allowed;
  opacity: 0.5;
  background-color: #f6f7f8;
}

/* Select disabled - adjust arrow color */
select:disabled {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23999999' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Error/Invalid state */
input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: #d9534f;
  box-shadow: 0 0 0 3px rgba(217, 83, 79, 0.12);
}

/* Select error state - red arrow */
select[aria-invalid="true"] {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20' fill='none'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23d9534f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* File input styling */
input[type="file"]::file-selector-button {
  display: inline-flex;
  height: 1.75rem;
  border: 0;
  background-color: transparent;
  font-size: 0.875rem;
  font-weight: 500;
  color: #686868;
}

/* Button Base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 0.5rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Checkbox & Radio - shadcn style */
input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  border: 1px solid #000000;
  background-color: transparent;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  position: relative;
  outline: none;
}

/* Screen reader only - for payment method cards */
input[type="radio"].sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

input[type="checkbox"]:hover,
input[type="radio"]:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background-color: #000000;
  border-color: transparent;
}

input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.375rem;
  height: 0.5625rem;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid #000000;
  outline-offset: 2px;
}

input[type="radio"] {
  border-radius: 50%;
}

input[type="radio"]:checked::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background-color: white;
  transform: translate(-50%, -50%);
}

/* Error States */
.has-error input,
.has-error textarea,
.has-error select {
  border-color: #ef4444;
}

.error-block {
  color: #ef4444;
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Card Styles */
.card {
  background-color: #ffffff;
  border-radius: 0.75rem;
  border: 1px solid #f3f4f6;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Credit Card Images */
div[credit-cards] {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

div[credit-cards] img {
  height: 20px;
  width: auto;
  object-fit: contain;
  filter: grayscale(20%);
  opacity: 0.98;
  transition: all 0.2s;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 2px;
  background-color: #f9fafb;
}

@media (min-width: 640px) {
  div[credit-cards] img {
    height: 30px;
  }
}

div[credit-cards] img:hover {
  filter: grayscale(0%);
  opacity: 1;
}

.credit-cards img {
  height: 20px;
  width: auto;
  object-fit: contain;
  filter: grayscale(20%);
  opacity: 0.98;
  transition: all 0.2s;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  padding: 2px;
  background-color: #f9fafb;
}

@media (min-width: 640px) {
  .credit-cards img {
    height: 30px;
  }
}

.credit-cards img:hover {
  filter: grayscale(0%);
  opacity: 1;
}

/* Input with Icon Component */
.input-with-icon {
  position: relative;
  display: block;
}

.input-with-icon i {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  pointer-events: none;
  z-index: 1;
}

.input-with-icon svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.125rem;
  height: 1.125rem;
  color: #9ca3af;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
  z-index: 1;
}

.input-with-icon input {
  padding-left: 2.5rem;
}

/* Card Type Detection - Shows card brand icon in input */
.input-with-icon.card-detected::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  pointer-events: none;
}

.input-with-icon.card-visa::after {
  background-image: url('../images/visa.png');
}

.input-with-icon.card-mastercard::after {
  background-image: url('../images/mastercard.png');
}

.input-with-icon.card-amex::after,
.input-with-icon.card-americanexpress::after {
  background-image: url('../images/americanexpress.png');
}

.input-with-icon.card-discover::after {
  background-image: url('../images/discover.png');
}

.input-with-icon.card-jcb::after {
  background-image: url('../images/jcb.png');
}

.input-with-icon.card-diners::after,
.input-with-icon.card-dinersclub::after {
  background-image: url('../images/dinersclub.png');
}

.input-with-icon.card-maestro::after {
  background-image: url('../images/maestro.png');
}

.input-with-icon.card-unionpay::after {
  background-image: url('../images/unionpay.png');
}

/* Card detected - add padding for the icon */
.input-with-icon.card-detected input {
  padding-right: 3rem;
}

/* Line Clamp Utilities */
.line-clamp-1 {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
