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

:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --surface2: #f8f9fa;
  --border: #e0e3e8;
  --text: #1a1d23;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --sidebar-bg: #1e2330;
  --sidebar-text: #a8b3c7;
  --sidebar-active: #2563eb;
  --radius: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.12);
}

body.dark-mode {
  --bg: #111827;
  --surface: #1f2937;
  --surface2: #374151;
  --border: #374151;
  --text: #f9fafb;
  --text-muted: #9ca3af;
}

body { font-family: 'Inter', system-ui, sans-serif; color: var(--text); background: var(--bg); font-size: 14px; line-height: 1.5; }

a { color: var(--primary); text-decoration: none; }

/* Disable ALL hover animations */
* { transition: none !important; animation: none !important; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-size: 13px; font-weight: 500;
  background: var(--surface); color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-danger  { background: var(--danger);  color: #fff; border-color: var(--danger); }
.btn-block   { width: 100%; justify-content: center; }
.btn-sm, .btn.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { background: none; border: none; cursor: pointer; font-size: 16px; padding: 4px 8px; color: var(--text-muted); }

/* ── Forms ────────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.field label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--text);
  width: 100%;
}
textarea { resize: vertical; }
.input-sm { padding: 5px 8px; font-size: 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0; padding: 8px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; }
.hint { font-size: 11px; color: var(--text-muted); }

/* ── Site Header ──────────────────────────────────────────────────────────── */
.site-header {
  background: #1e2330; display: flex; align-items: center;
  padding: 0 24px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-inner { display: flex; align-items: center; gap: 14px; width: 100%; }
.site-title { font-weight: 700; white-space: nowrap; }
.header-logo { max-width: 40vw; object-fit: contain; }
.header-nav { display: flex; gap: 20px; margin-left: auto; }
.header-nav a { color: rgba(255,255,255,.8); font-size: 13px; }

/* ── Site Footer ──────────────────────────────────────────────────────────── */
.site-footer { background: #1e2330; padding: 18px 24px; margin-top: auto; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; color: rgba(255,255,255,.7); font-size: 13px; }
.footer-inner a { color: rgba(255,255,255,.7); }

/* ── Login Page ───────────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 16px; }
.login-card { background: var(--surface); border-radius: 12px; padding: 36px 32px; width: 100%; max-width: 380px; box-shadow: var(--shadow-md); }
.login-card h2 { margin-bottom: 24px; font-size: 20px; }

/* ── Dashboard Layout ─────────────────────────────────────────────────────── */
.dashboard-body { background: var(--bg); min-height: 100vh; }
.dash-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.dash-sidebar {
  width: 220px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: 8px; padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { font-size: 20px; color: var(--primary); }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--sidebar-text); font-size: 13px; font-weight: 500; cursor: pointer; border-left: 3px solid transparent; }
.nav-item.active { color: #fff; border-left-color: var(--primary); background: rgba(37,99,235,.15); }
.nav-icon { width: 18px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: block; color: var(--sidebar-text); font-size: 12px; margin-bottom: 8px; }
.btn-logout { display: block; text-align: center; padding: 7px 12px; background: rgba(255,255,255,.08); color: rgba(255,255,255,.7); border-radius: 6px; font-size: 12px; }

/* Topbar */
.dash-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.dash-topbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 16px; font-weight: 600; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.sidebar-toggle { display: none; background: none; border: none; font-size: 18px; cursor: pointer; padding: 4px 8px; }
.notif-badge { background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 5px; position: absolute; top: -4px; right: -4px; }
.notif-btn { position: relative; }

/* Notifications Panel */
.notif-panel { position: absolute; top: 56px; right: 16px; width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); z-index: 200; }
.notif-header { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.notif-header strong { flex: 1; font-size: 14px; }
.notif-list { max-height: 400px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer; }
.notif-item.unread { background: #eff6ff; font-weight: 600; }
.notif-item .notif-title { font-size: 13px; }
.notif-item .notif-meta  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

/* Content Sections */
.dash-content { flex: 1; padding: 24px; }
.dash-section { display: none; }
.dash-section.active { display: block; }
.section-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.section-header h2 { font-size: 18px; font-weight: 700; flex: 1; }
.section-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Event Grid */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.event-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.event-card-title { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.event-card-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 12px; line-height: 1.6; }
.event-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.event-url { font-size: 11px; color: var(--primary); word-break: break-all; margin-bottom: 8px; }

/* Tables */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.data-table th { background: var(--surface2); padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); border-bottom: 1px solid var(--border); }
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.data-table tr:last-child td { border-bottom: none; }
.tag-created { color: var(--success); font-weight: 600; }
.tag-deleted { color: var(--danger); font-weight: 600; }

/* Settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 20px; }
.settings-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.settings-card h3 { font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.settings-card.full-width { grid-column: 1 / -1; }
.settings-save-bar { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.save-msg { font-size: 13px; color: var(--success); }

/* Nav / Footer link builder */
.link-row { display: flex; gap: 6px; margin-bottom: 6px; }
.link-row input { flex: 1; }

/* Background settings */
.bg-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.bg-tab { padding: 6px 16px; border: 1px solid var(--border); border-radius: 20px; cursor: pointer; background: var(--surface); font-size: 13px; }
.bg-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.bg-preview-wrap { margin-top: 16px; }
.bg-preview { width: 100%; height: 120px; border-radius: var(--radius); border: 1px solid var(--border); background-repeat: repeat; }

/* Toggle switch */
.toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.toggle input { display: none; }
.slider { width: 40px; height: 22px; background: var(--border); border-radius: 11px; position: relative; flex-shrink: 0; }
.slider::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::after { left: 21px; }

/* Upload row */
.upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.file-preview { display: flex; align-items: center; gap: 6px; }
.file-preview img { height: 40px; width: auto; border-radius: 4px; border: 1px solid var(--border); }
.file-preview .file-icon { font-size: 24px; }
.file-preview .file-name { font-size: 12px; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-btn { font-size: 11px; color: var(--danger); cursor: pointer; background: none; border: none; padding: 0; }

/* Custom CSS Editor */
.code-editor { font-family: 'Courier New', monospace; font-size: 13px; background: #1e2330; color: #e2e8f0; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; width: 100%; margin-bottom: 12px; }

/* ── Editor Modal ─────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 400; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 480px; box-shadow: var(--shadow-md); z-index: 501; position: relative; }
.modal-box h3 { font-size: 16px; margin-bottom: 20px; }
.modal-box .field:last-child { margin-bottom: 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; }

.modal-lg .modal-box, .editor-box { max-width: 820px; max-height: 90vh; display: flex; flex-direction: column; }
.editor-header { display: flex; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.editor-header h3 { flex: 1; font-size: 16px; }
.editor-body { flex: 1; overflow-y: auto; padding: 24px; }
.editor-footer { display: flex; justify-content: space-between; padding: 16px 24px; border-top: 1px solid var(--border); }
.editor-footer-right { display: flex; gap: 8px; }
.editor-section { margin-bottom: 28px; }
.editor-section h4 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 14px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.toggles { display: flex; flex-direction: column; gap: 8px; }
.toggles label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

/* Certificate Preview */
.cert-preview-wrap { position: relative; background: #ddd; border-radius: var(--radius); overflow: hidden; margin-top: 14px; user-select: none; }
.cert-preview-placeholder { padding: 40px; text-align: center; color: var(--text-muted); }
.cert-preview-img { display: block; width: 100%; height: auto; }
.cert-name-label { position: absolute; cursor: grab; white-space: nowrap; line-height: 1; pointer-events: auto; }
.cert-name-label:active { cursor: grabbing; }

/* Font controls */
.font-controls { display: grid; gap: 12px; }
.font-search-wrap { position: relative; }
.font-dropdown { position: absolute; top: 100%; left: 0; right: 0; max-height: 200px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; z-index: 100; box-shadow: var(--shadow-md); }
.font-option { padding: 8px 10px; cursor: pointer; font-size: 13px; }
.font-option:hover { background: var(--surface2); }
.style-buttons { display: flex; gap: 6px; }
.style-btn { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; background: var(--surface); font-size: 14px; color: var(--text); }
.style-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* URL display */
.url-display { display: flex; align-items: center; gap: 8px; background: var(--surface2); padding: 10px 12px; border-radius: 6px; font-size: 13px; word-break: break-all; }

/* Loading */
.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ── Visitor Page ──────────────────────────────────────────────────────────── */
.visitor-page { min-height: 100vh; display: flex; flex-direction: column; }
.event-header-img { width: 100%; }
.event-header-img img { width: 100%; max-height: 400px; object-fit: cover; display: block; }
.visitor-main { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; }
.visitor-card { background: var(--surface); border-radius: 12px; padding: 36px 32px; width: 100%; max-width: 480px; box-shadow: var(--shadow-md); }
.instruction-text { font-size: 15px; margin-bottom: 24px; color: var(--text); line-height: 1.6; }
.download-form { display: flex; flex-direction: column; gap: 10px; }
.pwd-input { padding: 12px 14px; font-size: 15px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); width: 100%; }
.dark-toggle { position: fixed; bottom: 20px; right: 20px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: var(--shadow-md); z-index: 300; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .dash-sidebar { position: fixed; left: -220px; z-index: 300; }
  .dash-sidebar.open { left: 0; }
  .sidebar-toggle { display: block; }
  .settings-grid { grid-template-columns: 1fr; }
  .modal { padding: 8px; }
  .editor-box { max-height: 98vh; }
  .visitor-card { padding: 24px 16px; }
  .header-logo { max-width: 40vw !important; }
}
