@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@300;400;500;600;700;800;900&display=swap');

:root {
  --blue: #1B4A8F; --blue-dark: #0f2d5c;
  --teal: #1E8A78; --teal-dark: #155f54; --teal-light: #e0f5f0;
  --white: #fff; --offwhite: #f8f9fb; --text: #1a1a2e; --muted: #6b7280;
  --border: #e5e7eb; --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Heebo', sans-serif; color: var(--text); direction: rtl; background: var(--offwhite); }

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 60%, var(--teal) 100%);
  padding: 0; position: relative; overflow: hidden;
}
.header-bg {
  position: absolute; inset: 0;
  background: url('hero1.jpg') center/cover no-repeat;
  opacity: 0.18;
}
.header-inner {
  position: relative; display: flex; align-items: center;
  justify-content: space-between; padding: 14px 32px;
}
.header-logo { display: flex; align-items: center; gap: 14px; }
.header-logo img { height: 52px; filter: brightness(0) invert(1); }
.header-title { color: #fff; }
.header-title h1 { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.header-title span { font-size: 0.82rem; color: rgba(255,255,255,0.7); font-weight: 400; }
.header-status {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(8px); border-radius: 24px; padding: 6px 16px;
  color: #fff; font-size: 0.82rem; font-weight: 500;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot.connected    { background: #4ade80; box-shadow: 0 0 8px #4ade80; }
.dot.disconnected { background: #f87171; }
.dot.connecting, .dot.qr { background: #fbbf24; animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Layout ── */
.main { max-width: 1200px; margin: 0 auto; padding: 28px 20px; display: flex; flex-direction: column; gap: 20px; }

/* ── Stats ── */
.stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }
.stat-card {
  background: var(--white); border-radius: 16px;
  padding: 20px 20px 16px; box-shadow: 0 1px 6px rgba(0,0,0,0.07);
  border-top: 4px solid var(--teal); position: relative; overflow: hidden;
}
.stat-card::after {
  content: ''; position: absolute; bottom: -20px; left: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--teal-light); opacity: 0.5;
}
.stat-card.danger { border-top-color: var(--danger); }
.stat-card.danger::after { background: #fee2e2; }
.stat-num { font-size: 2.4rem; font-weight: 800; color: var(--blue); line-height: 1; }
.stat-card.danger .stat-num { color: var(--danger); }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Cards ── */
.card {
  background: var(--white); border-radius: 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07); overflow: hidden;
}
.card-header {
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: linear-gradient(to left, var(--offwhite), var(--white));
}
.card-header h2 { font-size: 0.95rem; font-weight: 700; color: var(--blue); letter-spacing: 0.01em; }
.card-body { padding: 20px 24px; }

/* ── QR Section ── */
#qr-section { display: none; }
#qr-section.visible { display: block; }
.qr-wrap {
  display: flex; align-items: center; gap: 32px;
  background: linear-gradient(135deg, var(--blue-dark), var(--blue));
  border-radius: 12px; padding: 24px; margin-bottom: 20px;
}
.qr-wrap img { width: 160px; height: 160px; border-radius: 8px; background: white; padding: 6px; flex-shrink: 0; }
.qr-text { color: white; }
.qr-text h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 8px; }
.qr-text p  { font-size: 0.85rem; opacity: 0.8; line-height: 1.6; }

/* ── Toggle ── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; width: 52px; height: 28px; cursor: pointer; }
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 28px; transition: 0.3s;
}
.slider:before {
  content: ''; position: absolute; width: 22px; height: 22px;
  right: 3px; top: 3px; background: white; border-radius: 50%;
  transition: 0.3s; box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.toggle input:checked + .slider { background: var(--teal); }
.toggle input:checked + .slider:before { right: auto; left: 3px; }
.campaign-badge {
  padding: 3px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 700;
}
.campaign-badge.on  { background: #dcfce7; color: var(--ok); }
.campaign-badge.off { background: #f3f4f6; color: var(--muted); }

/* ── Buttons ── */
.btn {
  padding: 9px 18px; border-radius: 9px; border: none; cursor: pointer;
  font-family: 'Heebo', sans-serif; font-size: 0.85rem; font-weight: 700;
  transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-blue { background: var(--blue); color: white; }
.btn-blue:hover { background: var(--blue-dark); }
.btn-outline { background: white; color: var(--blue); border: 2px solid var(--blue); }
.btn-outline:hover { background: var(--offwhite); }
.btn-danger { background: white; color: var(--danger); border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fef2f2; }
.btn-warn { background: white; color: var(--warn); border: 1px solid #fcd34d; }
.btn-warn:hover { background: #fffbeb; }
.btn-ok { background: var(--ok); color: white; }
.btn-ok:hover { background: #15803d; }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--offwhite); }
.btn-sm { padding: 5px 12px; font-size: 0.78rem; }

/* ── Form ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 0.78rem; font-weight: 700; color: var(--blue); text-transform: uppercase; letter-spacing: 0.04em; }
input[type=text], input[type=number], textarea, select {
  border: 1.5px solid var(--border); border-radius: 9px; padding: 9px 13px;
  font-size: 0.88rem; font-family: 'Heebo', sans-serif; direction: rtl;
  color: var(--text); transition: border 0.2s; background: white;
}
input:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(30,138,120,0.1); }
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.save-msg { font-size: 0.82rem; color: var(--ok); font-weight: 600; display: none; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
thead { background: linear-gradient(to left, var(--offwhite), #f1f5f9); }
th { padding: 11px 16px; text-align: right; font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border); }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.name-cell .name { font-weight: 700; color: var(--text); }
.name-cell .phone { font-size: 0.78rem; color: var(--muted); margin-top: 2px; direction: ltr; text-align: right; }
.ticket-count { font-size: 1.6rem; font-weight: 800; color: var(--blue); }
.pending-count { font-size: 1rem; font-weight: 600; color: var(--muted); }
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 20px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.02em;
}
.badge-ok      { background: #dcfce7; color: var(--ok); }
.badge-pending { background: #fef9c3; color: var(--warn); }
.badge-flag    { background: #fee2e2; color: var(--danger); }
.badge-new     { background: #ede9fe; color: #7c3aed; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty-state .empty-icon {
  width: 80px; height: 80px; border-radius: 50%; background: var(--offwhite);
  margin: 0 auto 16px; display: flex; align-items: center; justify-content: center;
}
.empty-state .empty-icon img { width: 40px; opacity: 0.3; }
.empty-state p { font-size: 0.9rem; }

/* ── Google ── */
.google-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.google-info { font-size: 0.88rem; }
.google-connected { color: var(--ok); font-weight: 700; font-size: 0.88rem; }
.file-drop {
  margin-top: 12px; border: 2px dashed var(--border); border-radius: 10px;
  padding: 20px; text-align: center; cursor: pointer; color: var(--muted);
  font-size: 0.85rem; transition: all 0.2s;
}
.file-drop:hover { border-color: var(--teal); color: var(--teal); background: var(--teal-light); }

/* ── Gallery strip ── */
.img-strip {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
  border-radius: 12px; overflow: hidden; margin-top: 16px;
}
.img-strip img { width: 100%; height: 100px; object-fit: cover; display: block; }

/* ── WA section ── */
.wa-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.wa-info .label { font-size: 0.72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.wa-info .value { font-size: 0.92rem; font-weight: 600; color: var(--text); margin-top: 3px; }

/* ── Search ── */
.search-wrap { position: relative; }
.search-wrap input { padding-right: 36px; width: 200px; }
.search-icon { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 0.85rem; pointer-events: none; }

/* ── Raffle result ── */
.raffle-result-box {
  background: linear-gradient(135deg, var(--blue-dark), var(--teal));
  border-radius: 14px; padding: 28px; text-align: center; color: white;
}
.raffle-winner-label { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.75; margin-bottom: 8px; }
.raffle-winner-name  { font-size: 2rem; font-weight: 900; margin-bottom: 4px; }
.raffle-winner-phone { font-size: 0.9rem; opacity: 0.8; direction: ltr; margin-bottom: 8px; }
.raffle-winner-meta  { font-size: 0.8rem; opacity: 0.65; }

/* ── Log table ── */
#log-tbody td { padding: 9px 16px; border-bottom: 1px solid var(--border); }
#log-tbody tr:last-child td { border: none; }
.log-type { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.72rem; font-weight: 700; }
.log-register { background: #ede9fe; color: #7c3aed; }
.log-ticket   { background: #dcfce7; color: var(--ok); }
.log-raffle   { background: #fef9c3; color: var(--warn); }
.log-manual   { background: #dbeafe; color: #1d4ed8; }

@media (max-width: 700px) {
  .stats { grid-template-columns: repeat(2,1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }
  .header-inner { padding: 12px 16px; }
  .header-logo img { height: 38px; }
  .card-body { padding: 16px; }
}
