/* Wydaho Pic — Shared Styles */

:root {
  --bg: #111110;
  --surface: #1a1a19;
  --surface2: #242423;
  --border: #333332;
  --text: #f0efe9;
  --muted: #888883;
  --accent: #d1432a;
  --green: #3ecf8e;
  --accent2: #c8a86b;
  --yellow: #f7c948;
  --orange: #f6993f;
  --radius: 12px;
}

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

html, body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

img { max-width: 100%; display: block; }
a { color: var(--accent); text-decoration: none; }

.muted { color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn:hover { background: var(--surface2); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #b8371f; }
.btn-danger { background: transparent; border-color: var(--accent); color: var(--accent); }
.btn-danger:hover { background: rgba(209,67,42,.1); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; padding: 4px; }
.btn-icon:hover { color: var(--accent); }

/* ── Cards ────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Forms ─────────────────────────────────────────────────── */

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], input[type="datetime-local"],
textarea, select {
  display: block; width: 100%;
  margin-top: 4px; padding: 10px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font: inherit; font-size: 15px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; }
select { cursor: pointer; }

.form-card { max-width: 500px; }
.form-row { display: flex; gap: 16px; }
.form-row > label { flex: 1; }

/* ── Toast ─────────────────────────────────────────────────── */

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 9999;
}
.toast.show { opacity: 1; pointer-events: auto; }
.toast.success { background: var(--green); color: #111; }
.toast.error { background: var(--accent); color: #fff; }

/* ── Login ─────────────────────────────────────────────────── */

.login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
}
.login-card {
  width: 100%; max-width: 360px;
  text-align: center;
}
.brand { margin-bottom: 32px; }
.brand-logo { width: 80px; height: 80px; border-radius: 16px; margin: 0 auto 12px; }
.brand h1 { font-size: 24px; font-weight: 700; }
.brand p { margin-top: 4px; }
.error-msg { color: var(--accent); font-size: 13px; margin-top: 12px; min-height: 18px; }

#login-form { text-align: left; }
#login-form input { margin-bottom: 12px; }
#login-form .btn { margin-top: 8px; }

/* ── App Header (Admin) ───────────────────────────────────── */

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.header-logo { width: 32px; height: 32px; border-radius: 6px; }
.header-title { font-weight: 700; font-size: 16px; }
.header-right { display: flex; gap: 8px; }

.page-content { padding: 20px; max-width: 1000px; margin: 0 auto; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; }
.header-actions { display: flex; gap: 8px; }

/* ── Events Grid (Admin) ──────────────────────────────────── */

.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.event-card { cursor: pointer; transition: border-color .15s; }
.event-card:hover { border-color: var(--accent); }
.event-card.inactive { opacity: .5; }
.event-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.event-card-header h3 { font-size: 16px; }
.event-card-stats { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.event-card-date { font-size: 13px; color: var(--muted); }

.badge { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; }
.badge-muted { background: var(--surface2); color: var(--muted); }

/* ── Event Detail (Admin) ─────────────────────────────────── */

.detail-grid { display: grid; grid-template-columns: 300px 1fr; gap: 20px; }
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

.stat-row { display: flex; gap: 24px; margin-bottom: 16px; }
.stat { text-align: center; }
.stat span { display: block; font-size: 28px; font-weight: 700; color: var(--accent); }
.stat small { font-size: 12px; color: var(--muted); }

.share-section { margin-bottom: 16px; }
.copy-row { display: flex; gap: 8px; }
.copy-row input { flex: 1; font-size: 13px; }

.qr-section { text-align: center; margin-bottom: 16px; }
.qr-section img { max-width: 200px; margin: 0 auto 8px; background: #fff; border-radius: 8px; padding: 8px; }

.action-row { display: flex; gap: 8px; }
.action-row .btn { flex: 1; justify-content: center; }

.detail-photos h3 { margin-bottom: 12px; }

/* ── Gallery Grid (Shared) ────────────────────────────────── */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
  background: var(--surface2);
}
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .2s;
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-item-info {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}
.gallery-name {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 4px 6px;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
  font-size: 11px; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.guest-name { font-size: 11px; color: #fff; }
.delete-btn { color: rgba(255,255,255,.7); font-size: 16px; }
.delete-btn:hover { color: var(--accent); }

/* ── Photo Viewer ─────────────────────────────────────────── */

.photo-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.95);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column;
  z-index: 2000;
}
.photo-viewer img {
  max-width: 95vw; max-height: 85vh;
  object-fit: contain;
  border-radius: 4px;
}
.viewer-info {
  margin-top: 12px;
  font-size: 14px;
  text-align: center;
}
.viewer-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: none;
  color: #fff; font-size: 32px;
  cursor: pointer; opacity: .7;
}
.viewer-close:hover { opacity: 1; }

/* ── Guest Views ──────────────────────────────────────────── */

.guest-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  text-align: center;
}
.guest-hero { width: 100%; max-width: 400px; }
.guest-logo { width: 80px; height: 80px; border-radius: 16px; margin: 0 auto 12px; }
.guest-hero h1 { font-size: 28px; font-weight: 700; margin-bottom: 4px; }
.code-form { display: flex; gap: 8px; margin-top: 24px; }
.code-form input { flex: 1; text-align: center; font-size: 18px; letter-spacing: 2px; text-transform: lowercase; }
.code-form .btn { padding: 10px 24px; }

.event-header { text-align: center; padding: 24px 20px 8px; }
.event-header h1 { font-size: 24px; }
.event-header p { margin-top: 4px; max-width: 400px; margin-left: auto; margin-right: auto; }

.event-actions { text-align: center; padding: 16px 20px; }
.btn-capture {
  padding: 14px 32px;
  font-size: 16px;
  border-radius: 50px;
  gap: 10px;
}
.btn-capture svg { width: 22px; height: 22px; }
.limit-msg { font-size: 13px; color: var(--muted); margin-top: 8px; }

.gallery-section { padding: 0 16px 80px; max-width: 800px; margin: 0 auto; }
.gallery-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.gallery-header h2 { font-size: 18px; }

.reveal-msg {
  text-align: center; padding: 40px 20px;
  color: var(--muted); font-size: 16px;
}

/* ── Registration ─────────────────────────────────────────── */

.register-card {
  max-width: 400px; margin: 24px auto; padding: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
}
.register-card h2 { font-size: 18px; margin-bottom: 4px; }
.register-card p { margin-bottom: 16px; }
.register-card form label { margin-bottom: 14px; }
.register-card .btn { margin-top: 8px; }

/* ── Camera View ──────────────────────────────────────────── */

.camera-view {
  position: fixed; inset: 0;
  background: #000;
  z-index: 1000;
}
.camera-view video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.camera-controls {
  position: absolute; bottom: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-around;
  padding: 24px 32px 40px;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
}
.cam-btn {
  background: none; border: none;
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.cam-close, .cam-flip { width: 48px; height: 48px; opacity: .8; }
.cam-close:hover, .cam-flip:hover { opacity: 1; }
.cam-shutter {
  width: 72px; height: 72px;
  border-radius: 50%;
  border: 4px solid #fff;
  background: transparent;
  position: relative;
}
.cam-shutter::after {
  content: '';
  position: absolute; inset: 6px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform .1s;
}
.cam-shutter:active::after { transform: scale(.85); }

/* ── Preview View ─────────────────────────────────────────── */

.preview-view {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 1000;
  display: flex; flex-direction: column;
}
.preview-view > img {
  flex: 1;
  object-fit: contain;
  background: #000;
  min-height: 0;
}
.preview-form {
  padding: 16px 20px 32px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.preview-form input { margin-bottom: 10px; }
.preview-actions { display: flex; gap: 10px; margin-top: 4px; }
.preview-actions .btn { flex: 1; justify-content: center; }

/* ── Empty State ──────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
  grid-column: 1 / -1;
}

/* ── Print Styles ─────────────────────────────────────────── */

.print-only { display: none; }

@media print {
  body > *:not(.print-only) { display: none !important; }
  .print-only { display: block !important; }
  .print-qr-content {
    text-align: center;
    padding: 40px;
  }
  .print-qr-content img {
    max-width: 300px;
    margin: 0 auto 24px;
  }
  .print-qr-content h2 {
    font-size: 28px;
    color: #000;
    margin-bottom: 8px;
  }
  .print-qr-url {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
  }
  .print-qr-instructions {
    font-size: 18px;
    color: #333;
  }
}

/* ── Responsive ───────────────────────────────────────────── */

@media (min-width: 600px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 6px; }
}
@media (min-width: 900px) {
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
}
