:root {
  --brand: #652d90;
  --brand-dark: #4f2270;
  --brand-light: #f3eaf9;
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(101, 45, 144, 0.08);
  --shadow-sm: 0 2px 12px rgba(17, 24, 39, 0.06);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

body.admin-login {
  background: linear-gradient(145deg, var(--brand-light) 0%, var(--bg) 45%, #eef2ff 100%);
}

a { color: var(--brand); text-decoration: none; font-weight: 600; }
a:hover { color: var(--brand-dark); }

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

@media (min-width: 640px) {
  .container { padding: 24px 24px 48px; }
}

/* —— Top bar —— */
.topbar {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 4px 20px rgba(79, 34, 112, 0.25);
}

.topbar .container {
  padding-top: 12px;
  padding-bottom: 12px;
}

.topbar strong {
  color: #fff;
  font-size: 1.05rem;
  display: block;
}

.topbar .muted {
  color: rgba(255, 255, 255, 0.82) !important;
}

.topbar a.btn {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.1);
}

.topbar a.btn:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.5);
}

.topbar a.btn-primary {
  background: #fff;
  color: var(--brand);
  border-color: #fff;
}

.topbar a.btn-primary:hover {
  background: var(--brand-light);
  color: var(--brand-dark);
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.admin-logo {
  border-radius: 999px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* —— Cards & layout —— */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 640px) {
  .card { padding: 24px 28px; }
}

.card-elevated {
  box-shadow: var(--shadow);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-header h1,
.page-header h2 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
}

.page-header p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
  margin-top: 4px;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.btn:active { transform: scale(0.98); }

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
  color: #fff;
  box-shadow: 0 4px 14px rgba(101, 45, 144, 0.35);
}

.btn-primary:hover {
  filter: brightness(1.05);
  color: #fff;
}

.btn-danger { background: #dc2626; color: #fff; }
.btn-outline {
  border-color: var(--border);
  color: var(--text);
  background: #fff;
}
.btn-outline:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-light);
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--brand);
}
.btn-ghost:hover { background: var(--brand-light); }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; }

/* —— Forms —— */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1.3fr 1fr; }
}

label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #374151;
  display: block;
  margin-bottom: 6px;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(101, 45, 144, 0.15);
}

textarea { min-height: 120px; resize: vertical; }

.fieldset {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 16px 8px;
  margin: 0;
  background: #fafbfc;
}

.fieldset legend {
  padding: 0 8px;
  font-weight: 700;
  font-size: 0.88rem;
  color: #374151;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.45;
}

/* —— Editor (Summernote + Word) —— */
.editor-section {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #fafbfc;
}

.editor-tools {
  margin-bottom: 12px;
}

.editor-tools-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.editor-tools-hint {
  margin-bottom: 0;
}

.import-status {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
}

.import-status--info {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

.import-status--ok {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.import-status--err {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.note-editor.note-frame,
.note-editor.note-frame.note-editor--wesonga {
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.note-toolbar {
  background: #fff !important;
  border-bottom: 1px solid var(--border) !important;
  padding: 6px 4px !important;
}

@media (max-width: 768px) {
  .note-toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    white-space: nowrap;
  }

  .note-toolbar .note-btn-group {
    flex-shrink: 0;
  }

  .note-editable {
    min-height: 240px !important;
    font-size: 16px !important;
    padding: 14px !important;
  }

  .editor-tools-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-tools-actions .btn {
    width: 100%;
  }

  .note-modal .modal-dialog {
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
  }
}

.note-editable {
  min-height: 300px !important;
  font-size: 15px !important;
  line-height: 1.65 !important;
  padding: 16px !important;
}

.note-editable table {
  width: 100%;
  border-collapse: collapse;
}

.note-editable td,
.note-editable th {
  border: 1px solid var(--border);
  padding: 6px 8px;
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -4px;
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 640px;
}

th, td {
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 12px 10px;
  vertical-align: top;
}

th {
  background: var(--brand-light);
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

tbody tr:hover { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-published {
  background: #d1fae5;
  color: #065f46;
}

.badge-draft {
  background: #fef3c7;
  color: #92400e;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.85rem;
}

@media (max-width: 640px) {
  .table-wrap table { min-width: 520px; }
}

/* —— Status messages —— */
.status {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  font-size: 0.9rem;
  font-weight: 500;
}

.status-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.status-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.muted { color: var(--muted); }

.inline-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}

.inline-stack input {
  flex: 1 1 160px;
  min-width: 0;
  max-width: 220px;
}

/* —— Login —— */
.login-wrap {
  max-width: 420px;
  margin: 0 auto;
  padding: 32px 16px 48px;
}

.login-brand {
  text-align: center;
  margin-bottom: 20px;
}

.login-logo {
  width: 80px;
  height: 80px;
}

.login-card {
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
  text-align: center;
}

.login-card .login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 20px;
}

/* —— Gallery admin —— */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.gallery-admin-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  background: #fff;
}

.gallery-admin-item img {
  display: block;
  width: 100%;
  max-height: 120px;
  object-fit: cover;
  border-radius: 8px;
}

.check-label {
  display: block;
  margin-top: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}

.legacy-cover {
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  padding: 14px;
  background: #fffbeb;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
}

.form-actions .btn-primary {
  flex: 1 1 auto;
  min-width: 140px;
}

@media (max-width: 480px) {
  .form-actions .btn { width: 100%; }
}
