/* The Tool Bakery — Raffle Ticket Generator (front-end) */
#ttb-rtg { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; color: #111; }
.ttb-rtg-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 18px; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.ttb-rtg-title { margin: 0 0 12px; font-size: 20px; font-weight: 700; }

.ttb-rtg-grid-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px 16px;
}
.ttb-rtg-field--full { grid-column: 1 / -1; }
.ttb-rtg-field label { display:block; font-size: 12px; color:#374151; margin-bottom:6px; }
.ttb-rtg-field input[type="text"],
.ttb-rtg-field input[type="number"],
.ttb-rtg-field input[type="file"],
.ttb-rtg-field select,
.ttb-rtg-field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 10px; font-size: 14px; background:#fafafa;
}
.ttb-rtg-field input[type="file"] { padding: 8px; background:#fff; }
.ttb-rtg-field--checkbox { grid-column: 1 / -1; }

.ttb-rtg-actions { display:flex; align-items:center; gap: 12px; margin-top: 14px; }
.ttb-rtg-btn { background:#111827; color:#fff; border:none; border-radius: 999px; padding:10px 16px; font-weight:600; cursor:pointer; }
.ttb-rtg-btn:hover { opacity:.92; }
.ttb-rtg-note { color:#6b7280; }

/* ---------- PRINTED TICKETS (within iframe) ---------- */
.ttb-rtg-print-body { margin: 0; }
.ttb-rtg-grid {
  display: flex;
  flex-direction: column;
  gap: 0.25in; /* add more vertical space */
}
.ttb-rtg-ticket {
  border: 1px solid #111;
  border-radius: 10px;
  overflow: hidden;
  display:flex;
  flex-direction: row;
  break-inside: avoid;
  margin-bottom: 0.25in;
  position: relative; /* Added for absolute positioning of the logo column */
}
.ttb-rtg-main {
  flex: 1 1 70%;
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  /* Added to center content based on logo column's width */
  padding-left: 1.25in;
}

.ttb-rtg-main-top {
  text-align: center;
}

.ttb-rtg-logo-column {
  /* Changed to absolute positioning to not affect the main ticket layout */
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 1.25in; /* A fixed width for the logo column */
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  padding: 0 5px;
}

.ttb-rtg-logo {
  max-height: 100px;
  max-width: 100%;
  object-fit: contain;
}

.ttb-rtg-org {
  font-weight: 700;
  font-size: 11px;
}

.ttb-rtg-titletext {
  font-size: 24px;
  font-weight: 800;
  text-transform: uppercase;
  margin: 2px 0 4px 0;
}

.ttb-rtg-event {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 2px;
}

.ttb-rtg-meta {
  font-size: 11px;
  color: #374151;
}

.ttb-rtg-main-middle {
  margin: 6px 0;
  text-align: center;
}

.ttb-rtg-prizes {
  display: inline-block;
  text-align: left;
  margin: 0 auto;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.3;
}

.ttb-rtg-main-bottom {
  display: flex;
  justify-content: flex-start; /* Changed to start everything at the left */
  align-items: flex-end;
  font-size: 11px;
}

.ttb-rtg-info-left {
  flex: none; /* Removed flex: 1 so it only takes up needed space */
  font-size: 10px;
  color: #374151;
}

.ttb-rtg-price-right {
  font-weight: 700;
  font-size: 13px;
  margin-left: auto; /* Pushed the price to the far right */
}

.ttb-rtg-number-overlay {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 14px;
  font-weight: 800;
}


/* stub side */
.ttb-rtg-stub-head { display:flex; align-items:center; justify-content: space-between; }
.ttb-rtg-stub-title { font-weight: 700; font-size: 12px; }
.ttb-rtg-stub-num { font-weight: 800; font-size: 12px; }
.ttb-rtg-line { display:flex; align-items:center; gap: 6px; margin-top: 6px; }
.ttb-rtg-line label { font-size: 11px; flex: 0 0 42px; color:#111; }
.ttb-rtg-blank { border-bottom: 1px solid #111; height: 14px; flex: 1 1 auto; }

/* Page margins via @page only (keep your chosen size) */
@page { size: Letter; margin: 0.5in; }

/* No extra body margins in the print doc */
.ttb-rtg-print-body { margin: 0; }

@media print {
  /* Don’t rely on CSS grid for spacing in FF; we’ll stack tickets with margins */
  .ttb-rtg-grid { display: block !important; }

  /* Ensure stable sizing math */
  .ttb-rtg-ticket,
  .ttb-rtg-main,
  .ttb-rtg-stub { box-sizing: border-box; }

  /* ✅ Keep tickets horizontal: main (left) + stub (right) */
  .ttb-rtg-ticket {
    display: flex !important;
    flex-direction: row !important;
    height: 1.80in;          /* exact ticket height incl. padding/border */
    margin: 0 0 0.20in 0;    /* vertical spacing between tickets */
    page-break-inside: avoid;
    border: 1px solid #111;  /* keep border in case any earlier CSS was overridden */
    border-radius: 10px;
    overflow: hidden;
  }
  .ttb-rtg-ticket:last-child { margin-bottom: 0; }

  /* Left panel (main) */
  .ttb-rtg-main {
    flex: 1 1 70%;
    padding: 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
  }

  /* Right panel (stub) */
  .ttb-rtg-stub {
    flex: 0 0 30%;
    padding: 10px 12px;
    border-left: 2px dotted #9ca3af; /* perforation */
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #fbfbfb;
  }
  
  /* NEW: Horizontal layout for logo/company and prizes */
  .ttb-rtg-logo-company-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 4px;
  }
  
  .ttb-rtg-prizes-line {
    font-size: 12px;
    line-height: 1.3;
    margin: 6px 0;
    text-align: center;
  }
  
  /* Clean up old rules that are no longer needed for printing */
  .ttb-rtg-prizes {
    display: none;
  }
}

body, .ttb-rtg-ticket { font-family: 'Oswald', sans-serif; }

/* ===== THEMES ===== */
.ttb-rtg-theme-bw .ttb-rtg-ticket { border-color:#000; background:#fff; color:#000; }
.ttb-rtg-theme-bw .ttb-rtg-titleline { background:#000; color:#fff; padding:4px 6px; }

.ttb-rtg-theme-green .ttb-rtg-ticket { border-color:#1b5e20; background:#e8f5e9; color:#1b5e20; }
.ttb-rtg-theme-green .ttb-rtg-titleline { background:#1b5e20; color:#fff; padding:4px 6px; }

.ttb-rtg-theme-blue .ttb-rtg-ticket { border-color:#0d47a1; background:#e3f2fd; color:#0d47a1; }
.ttb-rtg-theme-blue .ttb-rtg-titleline { background:#0d47a1; color:#fff; padding:4px 6px; }

.ttb-rtg-theme-red .ttb-rtg-ticket { border-color:#b71c1c; background:#ffebee; color:#b71c1c; }
.ttb-rtg-theme-red .ttb-rtg-titleline { background:#b71c1c; color:#fff; padding:4px 6px; }

.ttb-rtg-theme-purple .ttb-rtg-ticket { border-color:#5e35b1; background:#f3effa; color:#5e35b1; }
.ttb-rtg-theme-purple .ttb-rtg-titleline { background:#5e35b1; color:#fff; padding:4px 6px; }

.ttb-rtg-theme-orange .ttb-rtg-ticket { border-color:#e65100; background:#fff5ea; color:#e65100; }
.ttb-rtg-theme-orange .ttb-rtg-titleline { background:#e65100; color:#fff; padding:4px 6px; }

/* --- Print button loading spinner --- */
.ttb-rtg-btn.is-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.8;
  padding-right: 32px; /* add space for spinner */
}

.ttb-rtg-btn.is-loading::after {
  content: "";
  position: absolute;
  right: 12px;              /* sit inside padding, not overlapping text */
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: ttb-spin 0.8s linear infinite;
}

@keyframes ttb-spin {
  to { transform: translateY(-50%) rotate(360deg); }
}

#ttb-closebar { display: block; }
@media print { #ttb-closebar { display: none !important; } }