/* ============================================================
   ADMIN — Les Portes de Maslacq
   ============================================================ */

:root {
  --dark:    #2C2416;
  --primary: #5C4033;
  --accent:  #C9A96E;
  --light:   #F8F4EF;
  --border:  #E8DDD3;
  --muted:   #7A6858;
  --white:   #FFFFFF;
  --success: #3A7D44;
  --error:   #C0392B;
  --sidebar-w: 220px;
}

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

body {
  font-family: 'Raleway', sans-serif;
  font-size: 0.93rem;
  color: var(--dark);
  background: var(--light);
  line-height: 1.6;
}

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

/* ── AUTH PAGES ────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--dark) 0%, #4a3328 100%);
  padding: 1rem;
}

.auth-card {
  background: var(--white);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--dark);
  text-align: center;
  margin-bottom: 0.25rem;
}

.auth-brand span { color: var(--accent); }

.auth-title {
  font-family: 'Raleway', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 1.75rem;
}

.auth-footer {
  text-align: center;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 1.25rem;
}

/* ── DASHBOARD LAYOUT ──────────────────────────────── */

.dashboard {
  display: grid;
  grid-template-rows: 56px 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Header */
.admin-header {
  grid-column: 1 / -1;
  background: var(--dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  z-index: 100;
}

.admin-header .brand {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--white);
}

.admin-header .brand span { color: var(--accent); }

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.header-user {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.6);
}

.header-user strong { color: var(--accent); }

/* Sidebar */
.admin-sidebar {
  background: var(--dark);
  padding: 1.5rem 0;
  border-right: 1px solid rgba(255,255,255,0.05);
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: 1.5rem;
}

.sidebar-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 0 1.25rem;
  margin-bottom: 0.4rem;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.25rem;
  color: rgba(255,255,255,0.65);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.sidebar-nav li a:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.sidebar-nav li a.active {
  color: var(--accent);
  background: rgba(201,169,110,0.12);
  border-right: 3px solid var(--accent);
}

.sidebar-nav li a .page-icon { font-size: 1rem; width: 1.2rem; text-align: center; }

/* Main content */
.admin-main {
  overflow-y: auto;
  background: var(--light);
}

.main-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}

/* ── CONTENT EDITOR ────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.5rem;
  color: var(--dark);
}

.page-title small {
  display: block;
  font-family: 'Raleway', sans-serif;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.save-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

#saveStatus {
  font-size: 0.8rem;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}

#saveStatus.visible { opacity: 1; }

/* Section / Fieldset */
.editor-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.editor-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  background: var(--light);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.editor-section-header h3 {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--primary);
}

.editor-section-header .toggle-icon {
  color: var(--muted);
  transition: transform 0.2s;
}

.editor-section-header.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.editor-section-body {
  padding: 1.25rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.editor-section-body.single-col {
  grid-template-columns: 1fr;
}

/* Fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field.full-width {
  grid-column: 1 / -1;
}

.field label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field textarea,
.field select {
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.85rem;
  font-family: 'Raleway', sans-serif;
  font-size: 0.88rem;
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.2s;
  width: 100%;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,64,51,0.1);
}

.field textarea {
  min-height: 90px;
  resize: vertical;
}

.field small {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Array field */
.array-field {
  grid-column: 1 / -1;
}

.array-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.array-item {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.array-item input,
.array-item textarea {
  flex: 1;
}

/* JSON editor */
.json-field {
  grid-column: 1 / -1;
}

.json-editor {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  min-height: 160px;
  line-height: 1.5;
  background: #1e1e1e;
  color: #d4d4d4;
  border-color: #333;
  border-radius: 6px;
  padding: 0.85rem;
}

.json-editor:focus { border-color: var(--accent); }

/* ── BUTTONS ───────────────────────────────────────── */

.btn-primary {
  background: var(--primary);
  color: var(--white);
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-family: 'Raleway', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
}

.btn-primary:hover { background: var(--dark); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-accent {
  background: var(--accent);
  color: var(--dark);
  border: none;
  border-radius: 6px;
  padding: 0.65rem 1.5rem;
  font-family: 'Raleway', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-accent:hover { background: #b8935d; }

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 1.1rem;
  font-family: 'Raleway', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-outline:hover { border-color: var(--primary); }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 1rem;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  transition: color 0.2s;
}

.btn-icon:hover { color: var(--error); }

.btn-sm {
  padding: 0.4rem 0.9rem;
  font-size: 0.72rem;
}

.btn-full { width: 100%; }

.btn-danger {
  background: var(--error);
  color: white;
  border: none;
  border-radius: 6px;
  padding: 0.6rem 1.2rem;
  font-family: 'Raleway', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── ALERTS ────────────────────────────────────────── */

.alert {
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.alert.hidden { display: none; }

.alert-error {
  background: #fde8e6;
  color: var(--error);
  border: 1px solid #f5c6c2;
}

.alert-success {
  background: #e6f4ea;
  color: var(--success);
  border: 1px solid #b7dfc0;
}

.alert-info {
  background: #e8f0fe;
  color: #1a56a4;
  border: 1px solid #b3cdf5;
}

/* ── PASSWORD CHANGE ───────────────────────────────── */

.settings-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.settings-section h3 {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 1rem;
}

/* ── LOADING ───────────────────────────────────────── */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── QUILL WYSIWYG ─────────────────────────────────── */

.quill-wrapper .ql-toolbar {
  border-radius: 6px 6px 0 0;
  border-color: var(--border);
  background: var(--light);
  font-family: 'Raleway', sans-serif;
}

.quill-wrapper .ql-container {
  border-radius: 0 0 6px 6px;
  border-color: var(--border);
  font-family: 'Raleway', sans-serif;
  font-size: 0.9rem;
  min-height: 110px;
}

.quill-wrapper .ql-editor {
  min-height: 110px;
  color: var(--dark);
  line-height: 1.65;
}

.quill-wrapper .ql-editor p { margin-bottom: 0.4em; }

.quill-wrapper .ql-toolbar button:hover,
.quill-wrapper .ql-toolbar button:focus {
  color: var(--primary);
}

.quill-wrapper .ql-toolbar button.ql-active { color: var(--accent); }

/* ── MAINTENANCE TOGGLE ─────────────────────────────── */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #ccc;
  border-radius: 26px;
  transition: .25s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background: white;
  border-radius: 50%;
  transition: .25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

.maintenance-toggle-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.maintenance-status {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
}

.maintenance-status.on { color: var(--error); }
.maintenance-status.off { color: var(--success); }

/* ── RESPONSIVE ────────────────────────────────────── */

@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }

  .sidebar-nav li a span:not(.page-icon) { display: none; }
  .sidebar-label { display: none; }
  .editor-section-body { grid-template-columns: 1fr; }
  .field.full-width { grid-column: 1; }
  .image-field { grid-column: 1; }
  .array-field { grid-column: 1; }
  .json-field { grid-column: 1; }
  .main-inner { padding: 1.25rem 1rem 3rem; }
  .submission-header { flex-direction: column; align-items: flex-start; gap: .5rem; }
  .submission-actions { flex-wrap: wrap; }
}

/* ── SUBMISSIONS ────────────────────────────────── */

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--error);
  color: #fff;
  font-size: .62rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

.submissions-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.submission-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  transition: box-shadow .15s;
}

.submission-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,.07);
}

.submission-card.unread {
  border-left: 3px solid var(--primary);
  background: #fdfaf6;
}

.submission-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .5rem;
}

.submission-name {
  font-size: .95rem;
  color: var(--dark);
}

.submission-sujet {
  display: inline-block;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: .72rem;
  padding: 1px 10px;
  margin-left: .5rem;
  color: var(--muted);
}

.submission-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
}

.submission-date {
  font-size: .75rem;
  color: var(--muted);
}

.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  margin-right: .4rem;
  vertical-align: middle;
}

.submission-coords {
  font-size: .82rem;
  color: var(--muted);
  margin-bottom: .5rem;
}

.submission-message {
  font-size: .88rem;
  line-height: 1.6;
  color: var(--dark);
  background: var(--light);
  border-radius: 6px;
  padding: .75rem 1rem;
  margin-top: .75rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.btn-xs {
  font-size: .72rem;
  padding: 2px 8px;
  line-height: 1.4;
  border-radius: 4px;
}

/* ── ANALYTICS ──────────────────────────────── */

.analytics-realtime {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.75rem;
  margin-bottom: 1.25rem;
}

.realtime-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34,197,94,.2);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

@keyframes pulse-dot {
  0%, 100% { box-shadow: 0 0 0 3px rgba(34,197,94,.2); }
  50%       { box-shadow: 0 0 0 6px rgba(34,197,94,.08); }
}

.realtime-count {
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Playfair Display', serif;
  line-height: 1;
}

.realtime-label {
  font-size: .88rem;
  color: var(--muted);
}

.analytics-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
  text-align: center;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary);
  font-family: 'Playfair Display', serif;
  line-height: 1.1;
}

.stat-label {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .4rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.analytics-chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: .75rem;
}

.chart-header h3 {
  font-size: .95rem;
  color: var(--dark);
}

.chart-period-btns {
  display: flex;
  gap: .35rem;
}

.period-btn {
  font-family: 'Raleway', sans-serif;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--light);
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

.period-btn:hover { border-color: var(--primary); color: var(--primary); }
.period-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.chart-wrap {
  height: 260px;
  position: relative;
}

.analytics-error {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3rem;
  text-align: center;
  color: var(--error);
}

.analytics-error small { display: block; margin-top: .5rem; color: var(--muted); font-size: .82rem; }

/* Analytics setup guide */
.analytics-setup {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2.5rem;
  text-align: center;
  max-width: 680px;
}

.analytics-setup h3 { font-size: 1.2rem; margin-bottom: .75rem; color: var(--dark); }
.analytics-setup p  { color: var(--muted); font-size: .88rem; margin-bottom: 1.75rem; }

.setup-steps { text-align: left; }

.setup-step {
  display: flex;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}
.setup-step:last-child { border-bottom: none; }

.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: .78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.setup-step strong { display: block; margin-bottom: .3rem; font-size: .9rem; }
.setup-step small  { color: var(--muted); line-height: 1.55; }

.env-vars { margin-top: .75rem; display: flex; flex-direction: column; gap: .5rem; }

.env-var {
  display: flex;
  align-items: baseline;
  gap: .75rem;
  background: var(--light);
  border-radius: 6px;
  padding: .5rem .75rem;
  font-size: .82rem;
}

.env-var code {
  font-family: monospace;
  font-size: .8rem;
  color: var(--primary);
  background: rgba(92,64,51,.08);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

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

@media (max-width: 768px) {
  .analytics-stats { grid-template-columns: 1fr 1fr; }
  .stat-card:last-child { grid-column: 1 / -1; }
}

/* ── ADMINS TABLE ────────────────────────────── */

.admins-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.admins-table th {
  text-align: left;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding: .5rem .75rem;
  border-bottom: 2px solid var(--border);
}

.admins-table td {
  padding: .7rem .75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admins-table tr:last-child td { border-bottom: none; }
.admins-table tr:hover td { background: var(--light); }

.badge-me {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 1px 7px;
  border-radius: 10px;
  margin-left: .4rem;
  vertical-align: middle;
}
