/* -----------------------------------------------------------
   BUTTONS
----------------------------------------------------------- */
.primary-button,
.secondary-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 18px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: none;
  transition: background-color 0.2s;
}

.primary-button,
button {
  background-color: #5ba543;
  color: #fff;
}

.primary-button:hover,
button:hover:not(:disabled) {
  background-color: #e1f0db;
}

.secondary-button {
  background-color: #fff;
  color: #333;
  border: 1px solid #ccc;
}

.secondary-button:hover {
  border-color: #999;
}

button:disabled,
.primary-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  background-color: #ccc !important;
  color: #666 !important;
}

.text-button {
  background: none;
  border: none;
  color: #5ba543;
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
}

.text-button:hover {
  text-decoration: underline;
}

/* spinner */
.spinner {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top: 2px solid #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* -----------------------------------------------------------
   FORMS & INPUTS
----------------------------------------------------------- */
label {
  font-weight: 600;
  margin-top: 10px;
  display: block;
  color: #444;
}

.section-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  display: block;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px;
  margin-top: 6px;
  margin-bottom: 18px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  transition: border-color 0.2s;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
}

input:focus,
textarea:focus,
select:focus {
  border-color: #5ba543;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input[type="date"] {
  appearance: none;
  -webkit-appearance: none;
  padding-left: 12px;
  height: 44px;
  font-size: 16px;
  color: #5ba543;
  border: 1px solid #ddd;
  border-radius: 6px;
}

input[type="date"]:focus {
  border-color: #5ba543;
  outline: none;
}

input[name="total"] {
  background-color: #f2f2f2;
  color: #777;
  font-weight: bold;
  cursor: not-allowed;
  border: 1px solid #ccc;
}

/* Hide number input arrows/spinners */
#deposit::-webkit-outer-spin-button,
#deposit::-webkit-inner-spin-button,
#tax-rate-custom::-webkit-outer-spin-button,
#tax-rate-custom::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#deposit[type="number"],
#tax-rate-custom[type="number"] {
  -moz-appearance: textfield;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  padding: 0.6rem 2.5rem 0.6rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: #333;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg fill='none' stroke='black' stroke-width='2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 1rem;
}

select:focus {
  outline: none;
  border-color: #5ba543;
  box-shadow: 0 0 0 2px rgba(91, 165, 67, 0.2);
}

#currency-tag:has(option[value=""]:checked) {
  color: #888;
}

/* -----------------------------------------------------------
   INPUT ICONS
----------------------------------------------------------- */
.icon {
  width: 16px;
  height: 16px;
  stroke-width: 2;
  vertical-align: middle;
  margin-right: 6px;
}

.input-icon-wrapper {
  position: relative;
}

.input-icon-wrapper .lucide {
  position: absolute;
  left: 14px;
  top: 15px;
  color: #5ba543;
  stroke-width: 2;
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.input-icon-wrapper input {
  width: 100%;
  padding-left: 40px;
  height: 38px;
  font-size: 15px;
  line-height: 1.2;
}

.readonly-input-icon-wrapper {
  display: flex;
  align-items: center;
  border: 1px #bbb;
  border-radius: 6px;
  background-color: #f5f5f5;
  padding: 0 10px;
  height: 40px;
  box-sizing: border-box;
}

.readonly-input-icon-wrapper .lucide {
  color: #5ba543;
  stroke-width: 2;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  flex-shrink: 0;
}

.readonly-input-icon-wrapper input {
  flex: 1;
  border: none;
  background: transparent;
  color: #555;
  outline: none;
  cursor: default;
  width: 100%;
  height: 38px;
  font-size: 15px;
  line-height: 1.2;
  padding-left: 0px;
  padding-top: 16px;
}

/* -----------------------------------------------------------
   DOCUMENT TYPE
----------------------------------------------------------- */
.doc-type-toggle {
  display: flex;
  gap: 0.5rem;
  margin-top: 8px;
  margin-bottom: 18px;
}

.doc-type-button {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid #ccc;
  background-color: #fff;
  color: #333;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.doc-type-button:hover {
  border-color: #999;
}

.doc-type-button.selected {
  background-color: #5ba543;
  color: #fff;
  border-color: #5ba543;
}

.choose-design-btn.active {
  background-color: #5ba543;
  color: #fff;
  border-color: #5ba543;
}

/* -----------------------------------------------------------
   TEMPLATES
----------------------------------------------------------- */
.template-drawer {
  display: block;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
  opacity: 0;
  max-height: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease, max-height 0.4s ease;
  margin-top: 1rem;
}

.template-drawer.open {
  opacity: 1;
  transform: translateY(0);
  max-height: none;
}

.template-drawer-content {
  padding: 1.5rem;
  overflow: visible;
  max-height: none;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
  justify-items: center;
  align-items: start;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
}

.template-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid transparent;
  border-radius: 12px;
  padding: 1rem;
  cursor: pointer;
  transition: border 0.2s ease, box-shadow 0.2s ease;
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 300px;
}

.template-option img {
  width: auto;
  height: 200px;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  margin-bottom: 0.5rem;
  background: #fff;
  border: 1px solid #ddd;
  padding: 4px;
}

.template-option span {
  font-size: 0.95rem;
  font-weight: 500;
  color: #333;
  text-align: center;
}

.template-option input[type="radio"] {
  display: none;
}

.template-option input[type="radio"]:checked + img {
  border: 2px solid #5ba543;
  box-shadow: 0 0 0 2px #5ba54333;
}

.template-preview-row {
  display: flex;
  gap: 1.5rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

/* -----------------------------------------------------------
   OTHER COMPONENTS
----------------------------------------------------------- */
#logo-preview {
  width: 100%;
  max-width: 180px;
  height: auto;
  object-fit: contain;
  margin-top: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 4px;
  display: none;
}

#logo-preview:not([src]) {
  display: none;
  border: none;
}

.loading-placeholder {
  pointer-events: none;
  opacity: 0.4;
  background-color: #ccc;
  color: #666;
  border-color: #bbb;
}

.trial-banner {
  background-color: #e6f4ea;
  color: #1b5e20;
  padding: 1.25rem 1.5rem;
  border: 1px solid #c8e6c9;
  border-radius: 12px;
  margin: 1.5rem auto 2rem auto;
  max-width: 100%;
  width: 100%;
  text-align: center;
  font-size: 1rem;
  line-height: 1.5;
}

.total-display {
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  background-color: #f4f4f4;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
  display: block;
  line-height: 1.4;
  width: 100%;
  box-sizing: border-box;
}

.total-main {
  font-size: 1rem;
  color: #333;
}

.total-sub {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
  line-height: 1.3;
}

.currency-inputs {
  display: flex;
  gap: 0.5rem;
  flex-direction: row;
}

.currency-inputs input {
  padding: 0.4rem 0.6rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  min-width: 4ch;
  text-align: center;
}

.custom-dropdown-wrapper {
  margin-top: 4px;
  position: relative;
  user-select: none;
}

.custom-dropdown-wrapper:focus-within .custom-dropdown-options {
  display: block;
}

.custom-dropdown-display {
  border: 1px solid #ccc;
  border-radius: 6px;
  padding: 0 0.75rem;
  height: 40px;
  line-height: 40px;
  font-size: 1rem;
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.custom-dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-top: 2px;
  z-index: 9999;
  display: none;
  max-height: 280px;
  overflow-y: auto;
  min-width: 100%;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.custom-dropdown-options div {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
}

.custom-dropdown-options div:hover {
  background: #b2daa4;
}

#generate-btn.loading {
  cursor: progress;
}

#generate-btn.loading span {
  display: inline-flex;
  align-items: center;
}

#clerk-auth-buttons-mobile {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

#clerk-auth-buttons-mobile .primary-button,
#clerk-auth-buttons-mobile .secondary-button {
  width: 100%;
  max-width: 320px;
  font-size: 16px;
  white-space: nowrap;
}

#photo-preview-list img {
  border: 1px solid #ccc;
  padding: 4px;
  background: #fff;
}
