/* ============================================================
   E-Business Card Generator — Styles
   ============================================================ */

/* ----- Reset & Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #eef2f7;
  --panel:     #ffffff;
  --border:    #e2e8f0;
  --text:      #1a2332;
  --muted:     #64748b;
  --radius:    14px;
  --shadow:    0 2px 20px rgba(0,0,0,0.07);
  --font:      'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-width: 360px;
  overflow-x: auto;
}

/* ============================================================
   PRIVACY FOOTER
   ============================================================ */
.privacy-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  color: #64748b;
  font-size: 0.72rem;
  line-height: 1.5;
  text-align: center;
}
.privacy-footer svg { flex-shrink: 0; fill: #94a3b8; }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-family: var(--font);
  font-weight: 500;
  color: #fff;
  background: #1e293b;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  pointer-events: auto;
  max-width: 420px;
  animation: toast-in 0.22s ease forwards;
}
.toast.toast-error  { background: #be123c; }
.toast.toast-warn   { background: #b45309; }
.toast.toast-ok     { background: #15803d; }
.toast.toast-out    { animation: toast-out 0.22s ease forwards; }

@keyframes toast-in  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }
@keyframes toast-out { from { opacity:1; transform:translateY(0); } to { opacity:0; transform:translateY(10px); } }

/* ============================================================
   APP HEADER
   ============================================================ */
.app-header {
  background: linear-gradient(135deg, #1a6eb5 0%, #0c7a70 100%);
  color: #fff;
  padding: 28px 48px;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-icon {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  opacity: 0.9;
}

.app-header h1 {
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.app-header p {
  font-size: 0.88rem;
  opacity: 0.8;
  max-width: 560px;
  line-height: 1.5;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.app-main {
  display: grid;
  grid-template-columns: 480px 1fr;
  gap: 24px;
  max-width: 1280px;
  margin: 28px auto;
  padding: 0 24px 48px;
}

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px 28px 32px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1.5px solid var(--border);
}

.step-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1a6eb5, #0d9488);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

/* ============================================================
   FORM
   ============================================================ */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.fg { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fg.full { grid-column: 1 / -1; }

.section-divider {
  border-top: 1.5px solid var(--border);
  padding-top: 14px;
  margin-top: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.req  { color: #e53e3e; }
.opt  { font-weight: 400; text-transform: none; letter-spacing: 0; }

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"] {
  width: 100%;
  min-width: 0;
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text);
  background: #fafbfc;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  outline: none;
}

input:focus {
  border-color: #1a6eb5;
  box-shadow: 0 0 0 3px rgba(26,110,181,0.13);
  background: #fff;
}

input.error {
  border-color: #e53e3e;
  box-shadow: 0 0 0 3px rgba(229,62,62,0.12);
}

/* ----- Uploads ----- */
.uploads-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.upload-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.upload-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--muted);
  background: #fafbfc;
  transition: border-color 0.18s, color 0.18s, background 0.18s;
  user-select: none;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.upload-btn:hover {
  border-color: #1a6eb5;
  color: #1a6eb5;
  background: #f0f7ff;
}

.upload-btn.has-file {
  border-color: #0d9488;
  color: #0d9488;
  background: #f0fdfb;
  border-style: solid;
}

.upload-btn svg { width: 15px; height: 15px; flex-shrink: 0; }
/* ----- Logo position picker ----- */
.logo-pos-row {
  margin-bottom: 24px;
}

.logo-pos-row > label {
  display: block;
  margin-bottom: 10px;
}

.logo-pos-btns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.pos-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 6px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  background: #fafbfc;
  color: var(--muted);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}

.pos-btn svg {
  width: 38px;
  height: 24px;
}

.pos-btn:hover {
  border-color: #1a6eb5;
  color: #1a6eb5;
  background: #f0f7ff;
}

.pos-btn.active {
  border-color: #1a6eb5;
  background: #e8f3ff;
  color: #1a6eb5;
}
/* ----- Theme dots ----- */
.theme-row {
  margin-bottom: 20px;
}

.theme-row > label {
  display: block;
  margin-bottom: 10px;
}

.themes { display: flex; gap: 10px; flex-wrap: wrap; }

.theme-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  padding: 0;
}

.theme-dot:hover { transform: scale(1.18); }

.theme-dot.active {
  border-color: var(--text);
  transform: scale(1.12);
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
}

/* ----- Buttons ----- */
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 22px;
  border-radius: 9px;
  border: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: linear-gradient(135deg, #1a6eb5, #1558a0);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26,110,181,0.35);
}
.btn-primary:hover  { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(26,110,181,0.45); }
.btn-primary:active { transform: translateY(0);    box-shadow: 0 2px 8px rgba(26,110,181,0.35); }

.btn-secondary {
  background: #fff;
  color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}
.btn-secondary:hover  { background: #f8fafc; border-color: #cbd5e1; }
.btn-secondary:active { background: #f1f5f9; }

/* ============================================================
   CARD STAGE
   ============================================================ */
.card-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #dde3ec;
  border-radius: 10px;
  padding: 28px 20px;
  margin-bottom: 16px;
  min-height: 200px;
  overflow-x: auto;
}

/* ============================================================
   BUSINESS CARD
   ============================================================ */

/* --- Theme CSS variables --- */
.theme-blue    { --c: #1a6eb5; --cd: #1558a0; --cl: #e8f3ff; }
.theme-teal    { --c: #0d9488; --cd: #0a7a6e; --cl: #e0f7f5; }
.theme-navy    { --c: #1e3a5f; --cd: #152c4a; --cl: #e8eef6; }
.theme-purple  { --c: #7c3aed; --cd: #6d28d9; --cl: #f0eaff; }
.theme-crimson { --c: #c0392b; --cd: #a93226; --cl: #fdf0ee; }
.theme-dark    { --c: #2d3748; --cd: #1a202c; --cl: #f1f5f9; }

.business-card {
  display: flex;
  width: 620px;
  height: 350px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0,0,0,0.22);
  font-family: var(--font);
  background: #fff;
  flex-shrink: 0;
}

/* --- Left section (info): CSS Grid with named areas --- */
.bc-left {
  flex: 1;
  min-width: 0;
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-areas:
    "photo .        logo"
    "identity identity identity"
    "rule  rule     rule"
    "conts conts    conts"
    "socials socials socials";
  padding: 22px 18px 20px 22px;
  column-gap: 14px;
  align-items: start;
  background: #fff;
}

/* Named grid area assignments */
.bc-photo-ring { grid-area: photo; }
.bc-identity   { grid-area: identity; min-width: 0; }
.bc-logo       { grid-area: logo; align-self: start; }
.bc-rule       { grid-area: rule; }
.bc-contacts   { grid-area: conts; }
.bc-socials    { grid-area: socials; }

/* Photo sizing */
.bc-photo-ring {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 3px solid var(--c);
  background: var(--cl);
  overflow: hidden;
  flex-shrink: 0;
}

/* ---- Logo position variants ---- */

/* Top-Left: logo and photo share first row, identity gets its own full-width row below */
.logo-tl .bc-left {
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-areas:
    "logo  .         photo"
    "identity identity identity"
    "rule  rule      rule"
    "conts conts     conts"
    "socials socials socials";
}

/* Top logo positions: give the name row a small top margin so it breathes
   after the photo/logo row */
.logo-tr .bc-identity,
.logo-tl .bc-identity,
.logo-br .bc-identity { padding-top: 6px; }

/* Bottom-Left: logo pinned to bottom-left; 1fr spacer between socials and logo */
.logo-bl .bc-left {
  grid-template-rows: auto auto auto auto 1fr auto;
  grid-template-areas:
    "photo identity ."
    "rule  rule     rule"
    "conts conts    conts"
    "socials socials socials"
    ". . ."
    "logo  .        .";
}

/* Bottom-Right: identity gets its own full-width row; logo absolutely pinned to bottom-right */
.logo-br .bc-left {
  grid-template-rows: auto auto auto 1fr auto;
  grid-template-areas:
    "photo .         ."
    "identity identity identity"
    "rule  rule      rule"
    "conts conts     conts"
    "socials socials socials";
}

.logo-br .bc-logo {
  grid-area: auto;
  position: absolute;
  bottom: 20px;
  right: 18px;
}

.bc-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bc-photo-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c);
}
.bc-photo-ph svg { width: 44px; height: 44px; opacity: 0.45; }

/* Name block */
.bc-identity { padding-top: 2px; overflow: hidden; }

.bc-identity h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--c);
  line-height: 1.2;
  margin-bottom: 4px;
  word-break: break-word;
}

.bc-role {
  font-size: 0.73rem;
  color: #475569;
  font-weight: 500;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bc-org {
  font-size: 0.69rem;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logo — prominent */
.bc-logo {
  max-width: 120px;
  max-height: 85px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

/* Divider */
.bc-rule {
  height: 1.5px;
  background: linear-gradient(90deg, var(--c), transparent);
  margin: 10px 0 8px;
  opacity: 0.35;
}

/* Contact rows */
.bc-contacts { display: flex; flex-direction: column; gap: 5px; }

.bc-row {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.71rem;
  color: #475569;
  line-height: 1.3;
  min-width: 0;
}

.bc-row span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bc-ico {
  width: 11px;
  height: 11px;
  flex-shrink: 0;
  fill: var(--c);
}

/* Social media icons strip on card */
.bc-socials {
  display: flex;
  gap: 7px;
  align-items: center;
  padding-top: 6px;
}

.bc-social-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c);
  opacity: 0.75;
  flex-shrink: 0;
}

.bc-social-icon svg {
  width: 12px;
  height: 12px;
  display: block;
}

/* --- Right section (QR) --- */
.bc-right {
  width: 195px;
  flex-shrink: 0;
  background: var(--c);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 18px 14px;
}

.bc-qr {
  background: #fff;
  border-radius: 8px;
  width: 146px;
  height: 146px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

/* qrcode.js injects a canvas (then hides it) + an img — only size the img */
.bc-qr canvas {
  width: 130px !important;
  height: 130px !important;
  /* do NOT set display here — qrcode.js sets display:none on canvas after rendering */
}
.bc-qr img {
  display: block !important;
  width: 130px !important;
  height: 130px !important;
}

/* Placeholder icon inside QR box */
.qr-ph {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #94a3b8;
}
.qr-ph svg { width: 60px; height: 60px; }
.qr-ph p   { font-size: 0.65rem; font-family: var(--font); }

.qr-label {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.82);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  text-align: center;
}

/* ============================================================
   PREVIEW HINT
   ============================================================ */
.preview-hint {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.preview-hint.success { color: #0d9488; }

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .app-main { grid-template-columns: 1fr; }

  .business-card { width: 540px; height: 305px; }
  .bc-right      { width: 170px; }
  .bc-qr         { width: 124px; height: 124px; }
  .bc-qr canvas  { width: 88px !important; height: 88px !important; }
  .bc-qr img     { display: block !important; width: 88px !important; height: 88px !important; }
}

@media (max-width: 640px) {
  .app-header { padding: 20px; }
  .app-main   { padding: 0 12px 32px; gap: 16px; margin-top: 20px; }
  .panel      { padding: 20px; }

  .form-grid      { grid-template-columns: 1fr; }
  .fg.full        { grid-column: 1; }
  .uploads-row    { grid-template-columns: 1fr; }

  .business-card  { width: 360px; flex-shrink: 0; height: 205px; }
  .bc-right       { width: 120px; }
  .bc-qr          { width: 86px; height: 86px; }
  .bc-qr canvas  { width: 62px !important; height: 62px !important; }
  .bc-qr img     { display: block !important; width: 62px !important; height: 62px !important; }

  .bc-photo-ring  { width: 48px; height: 48px; }
  .bc-identity h3 { font-size: 0.85rem; }
  .bc-left        { padding: 14px 12px 14px 14px; }
  .bc-top-row     { gap: 8px; }
  .bc-logo        { max-width: 38px; max-height: 28px; }

  .bc-socials         { padding-top: 4px !important; gap: 5px !important; }
  .bc-social-icon svg { width: 9px !important; height: 9px !important; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  @page { size: 5in 3in; margin: 0.25in; }

  html, body {
    height: auto !important;
    min-height: 0 !important;
    background: #fff !important;
  }

  /* Hide everything except the card */
  .app-header,
  .form-panel,
  .panel-header,
  .preview-hint,
  .privacy-footer {
    display: none !important;
  }

  .app-main {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: none !important;
    min-height: 0 !important;
  }

  .preview-panel {
    box-shadow: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    min-height: 0 !important;
  }

  .card-stage {
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    display: block !important;
  }

  .business-card {
    width:      3.5in !important;
    height:     2in  !important;
    box-shadow: none !important;
    border:     0.5pt solid #ccc !important;
    border-radius: 6pt !important;
  }

  /* Tighter card padding gives ~6pt more vertical breathing room */
  .bc-left        { padding: 12pt 10pt 10pt 12pt !important; }

  /* Smaller photo so the extra identity row (top-logo positions) still fits */
  .bc-photo-ring  { width: 36pt !important; height: 36pt !important; }

  /* Logo much smaller in print — column still sizes correctly */
  .bc-logo        { max-width: 30pt !important; max-height: 22pt !important; }

  /* Identity text — tighter line spacing and margins */
  .bc-identity h3 { font-size: 11pt !important; margin-bottom: 2pt !important; }
  .bc-role        { font-size: 7.5pt !important; margin-bottom: 1pt !important; }
  .bc-org         { font-size: 6.5pt !important; }

  /* Reset the screen padding-top we added for top-logo layouts */
  .logo-tr .bc-identity,
  .logo-tl .bc-identity,
  .logo-br .bc-identity { padding-top: 0 !important; }

  /* Tighter rule */
  .bc-rule        { margin: 5pt 0 4pt !important; }

  /* Contacts */
  .bc-row         { font-size: 6.5pt !important; }
  .bc-contacts    { gap: 2.5pt !important; }
  .bc-ico         { width: 7pt !important; height: 7pt !important; }

  /* Social icons — scale down to match contacts row */
  .bc-socials         { padding-top: 3pt !important; gap: 5pt !important; }
  .bc-social-icon svg { width: 7pt !important; height: 7pt !important; }

  /* ── logo-br: switch to 2-column grid in print so the logo column
        doesn't squeeze the name; logo is absolutely pinned to bottom-right ── */
  .logo-br .bc-left {
    grid-template-columns: auto 1fr !important;
    grid-template-rows: auto auto 1fr auto !important;
    grid-template-areas:
      "photo identity"
      "rule  rule"
      "conts conts"
      "socials socials" !important;
    position: relative !important;
  }
  .logo-br .bc-logo {
    position: absolute !important;
    bottom: 10pt !important;
    right: 10pt !important;
    max-width: 28pt !important;
    max-height: 18pt !important;
  }

  .bc-right       { width: 1.1in !important; padding: 10pt !important; }
  .bc-qr          { width: 76pt !important; height: 76pt !important; }
  .bc-qr canvas,
  .bc-qr img      { width: 56pt !important; height: 56pt !important; }
  .qr-label       { font-size: 5pt !important; }
}
