/* =============================================
   Smart Digital ID Card & Certificate Maker
   style.css
   ============================================= */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #263148;
  --border: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 14px;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --accent: #6366f1;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface2: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* HEADER */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100; gap: 12px;
}
.header-logo { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.logo-img { width: 38px; height: 38px; border-radius: 8px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-main { font-weight: 800; font-size: 16px; color: var(--primary); }
.brand-sub { font-size: 12px; color: var(--muted); }
.header-right { display: flex; align-items: center; gap: 10px; }
.theme-btn { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 15px; transition: all 0.2s; }
.theme-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.wa-btn { display: flex; align-items: center; gap: 6px; background: #25d366; color: #fff; padding: 8px 16px; border-radius: 8px; text-decoration: none; font-weight: 600; font-size: 14px; transition: opacity 0.2s; }
.wa-btn:hover { opacity: 0.85; }

/* HERO */
.hero { background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%); padding: 44px 24px 36px; text-align: center; }
.hero-inner { max-width: 640px; margin: 0 auto; }
.hero-badge { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.15); color: #fff; padding: 6px 16px; border-radius: 100px; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.hero h1 { font-size: clamp(26px, 4.5vw, 40px); font-weight: 800; color: #fff; margin-bottom: 10px; }
.hero p { color: rgba(255,255,255,0.8); font-size: 15px; }

/* APP WRAP */
.app-wrap { max-width: 1200px; margin: 0 auto; padding: 28px 20px 60px; }

/* MODE TABS */
.mode-tabs { display: flex; gap: 10px; margin-bottom: 24px; }
.mode-tab { display: flex; align-items: center; gap: 8px; padding: 11px 24px; border-radius: 100px; border: 2px solid var(--border); background: var(--surface); color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; transition: all 0.2s; font-family: inherit; }
.mode-tab:hover { border-color: var(--primary); color: var(--primary); }
.mode-tab.active { border-color: var(--primary); background: var(--primary); color: #fff; }

/* BUILDER GRID */
.builder-grid { display: grid; grid-template-columns: 420px 1fr; gap: 28px; align-items: start; }
@media (max-width: 900px) { .builder-grid { grid-template-columns: 1fr; } }

/* FORM PANEL */
.form-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 0; }
.builder-form { display: none; }
.builder-form.active { display: block; }

.section-label { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }

.template-row { margin-bottom: 20px; }
.template-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tmpl-btn { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 14px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface2); color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 600; transition: all 0.2s; font-family: inherit; min-width: 72px; }
.tmpl-btn:hover { border-color: var(--primary); color: var(--primary); }
.tmpl-btn.active { border-color: var(--primary); background: rgba(99,102,241,0.12); color: var(--primary); }
.tmpl-icon { font-size: 20px; }

/* PHOTO UPLOAD */
.photo-upload-area { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 2px dashed var(--border); border-radius: 12px; padding: 20px; cursor: pointer; transition: border-color 0.2s; min-height: 100px; }
.photo-upload-area:hover { border-color: var(--primary); }
#photoPlaceholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
#photoPlaceholder i { font-size: 36px; opacity: 0.4; }
.remove-photo-btn { margin-top: 6px; background: none; border: 1px solid #ef4444; color: #ef4444; padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; font-family: inherit; }

/* FORM FIELDS */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.hint { font-weight: 400; color: var(--muted); font-size: 11px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%; background: var(--surface2); border: 1.5px solid var(--border);
  color: var(--text); padding: 9px 12px; border-radius: 8px; font-size: 13px;
  font-family: inherit; transition: border-color 0.2s; outline: none; resize: vertical;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--primary); }
.half-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* COLOR SWATCHES */
.color-swatches { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.swatch { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform 0.15s, border-color 0.15s; padding: 0; }
.swatch:hover { transform: scale(1.15); }
.swatch.active { border-color: #fff; box-shadow: 0 0 0 2px var(--primary); transform: scale(1.15); }

/* DOWNLOAD */
.download-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 13px; background: linear-gradient(135deg, var(--primary), #7c3aed); color: #fff; border: none; border-radius: var(--radius); font-size: 15px; font-weight: 700; cursor: pointer; transition: opacity 0.2s, transform 0.1s; font-family: inherit; margin-top: 20px; }
.download-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.download-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* PREVIEW PANEL */
.preview-panel { position: sticky; top: 90px; }
.preview-label-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.preview-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.preview-hint { font-size: 11px; color: var(--muted); }

.preview-wrap { display: flex; justify-content: center; }

/* ==========================
   ID CARD STYLES
   ========================== */
.id-card {
  width: 340px;
  min-height: 210px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  background: #fff;
  font-family: 'Inter', sans-serif;
  position: relative;
  color: #1e293b;
}

.id-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 12px;
  background: var(--accent);
  color: #fff;
}

.id-org-logo {
  width: 42px; height: 42px;
  border-radius: 8px;
  background: rgba(255,255,255,0.2);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  flex-shrink: 0;
}

.id-org-name { font-weight: 800; font-size: 13px; line-height: 1.2; }
.id-card-label { font-size: 10px; letter-spacing: 1.5px; opacity: 0.8; margin-top: 2px; }

.id-body {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
}

.id-photo-wrap { flex-shrink: 0; }
.id-photo-wrap img, .id-photo-placeholder {
  width: 76px; height: 76px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  object-fit: cover;
}
.id-photo-placeholder {
  background: #f1f5f9;
  display: flex; align-items: center; justify-content: center;
  color: #94a3b8; font-size: 30px;
}

.id-info { flex: 1; min-width: 0; }
.id-name { font-size: 16px; font-weight: 800; color: #1e293b; margin-bottom: 5px; word-break: break-word; }
.id-field { font-size: 11.5px; color: #475569; margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.id-field i { color: var(--accent); flex-shrink: 0; font-size: 11px; }

.id-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px 10px;
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  font-size: 10.5px;
}
.id-address { color: #64748b; flex: 1; }
.id-valid { font-weight: 700; color: var(--accent); white-space: nowrap; }

.id-watermark {
  position: absolute; bottom: 30px; right: -20px;
  font-size: 10px; font-weight: 800; letter-spacing: 3px;
  color: var(--accent); opacity: 0.06;
  transform: rotate(-30deg);
  pointer-events: none;
  white-space: nowrap;
}

/* Office template tweaks */
.id-card.office-tmpl .id-header { flex-direction: row; }
.id-card.office-tmpl .id-body { flex-direction: row-reverse; }

/* Club template tweaks */
.id-card.club-tmpl .id-header { justify-content: center; text-align: center; flex-direction: column; gap: 4px; padding: 16px; }
.id-card.club-tmpl .id-org-logo { width: 48px; height: 48px; font-size: 20px; }

/* ==========================
   CERTIFICATE STYLES
   ========================== */
.cert-card {
  width: 560px;
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  font-family: 'Inter', sans-serif;
  color: #1e293b;
}

.cert-border-outer {
  border: 6px solid var(--accent);
  margin: 10px;
  border-radius: 8px;
}

.cert-border-inner {
  border: 2px solid rgba(99,102,241,0.2);
  margin: 6px;
  border-radius: 5px;
  padding: 30px 28px 22px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.cert-border-inner::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top center, rgba(99,102,241,0.04) 0%, transparent 70%);
  pointer-events: none;
}

.cert-top-badge { font-size: 36px; margin-bottom: 6px; }

.cert-issuer {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 10px;
}

.cert-presents {
  font-size: 12px;
  color: #64748b;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.cert-recipient {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.2;
  margin-bottom: 10px;
  word-break: break-word;
}

.cert-for-text {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.cert-desc {
  font-size: 12px;
  color: #475569;
  line-height: 1.6;
  max-width: 420px;
  margin: 0 auto 16px;
}

.cert-divider {
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 0 auto 16px;
  width: 80%;
  opacity: 0.4;
}

.cert-sign-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.cert-sign-block { text-align: left; }
.cert-sign-line { border-top: 1.5px solid #334155; width: 130px; margin-bottom: 4px; }
.cert-sign-name { font-size: 12px; font-weight: 700; color: #1e293b; }
.cert-sign-title { font-size: 11px; color: #64748b; }

.cert-meta-block { text-align: right; }
.cert-date { font-size: 12px; color: #1e293b; font-weight: 600; }
.cert-no { font-size: 10px; color: #94a3b8; margin-top: 3px; }

.cert-footer-brand {
  font-size: 10px;
  color: #94a3b8;
  letter-spacing: 1px;
  margin-top: 4px;
}

@media (max-width: 620px) {
  .cert-card { width: 100%; min-width: 0; }
  .cert-recipient { font-size: 22px; }
  .id-card { width: 100%; max-width: 340px; }
  .half-grid { grid-template-columns: 1fr; }
}

/* FOOTER */
.app-footer { text-align: center; padding: 24px; border-top: 1px solid var(--border); color: var(--muted); font-size: 14px; }
.app-footer a { color: var(--primary); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* TOAST */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--surface); border: 1px solid var(--border); color: var(--text); padding: 12px 24px; border-radius: 100px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); transition: transform 0.3s ease; z-index: 9999; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { border-color: #10b981; color: #10b981; }
.toast.error { border-color: #ef4444; color: #ef4444; }


/* ---- HOME BUTTON ---- */
.home-btn {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 7px;
  color: rgba(255,255,255,0.65);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.2s, color 0.2s;
  white-space: nowrap;
}
.home-btn:hover { border-color: rgba(255,255,255,0.55); color: #fff; }
