/* =========================================================
   FONDATION DAVID VIAUD — STYLE PANÈL ADMIN
   ========================================================= */
:root {
  --navy: #0a2463;
  --navy-dark: #061644;
  --navy-light: #16337f;
  --red: #d7263d;
  --red-dark: #b01e30;
  --gold: #f2b134;
  --bg: #f4f6fb;
  --white: #ffffff;
  --border: #e3e7f0;
  --text: #333a4a;
  --text-muted: #7a8092;
  --radius: 12px;
  --shadow: 0 8px 24px rgba(10,36,99,.08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--text); }
a { text-decoration: none; color: inherit; }
ul { margin: 0; padding: 0; list-style: none; }

/* ---------- LOGIN PAGE ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--navy), var(--navy-dark));
  padding: 20px;
}
.login-card {
  background: var(--white); border-radius: 16px; padding: 44px; width: 100%; max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.login-card .logo { text-align: center; font-weight: 800; font-size: 20px; color: var(--navy); margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 30px; }
.login-error { display: none; background: #fdeaec; color: var(--red-dark); padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; font-weight: 600; }

/* ---------- APP LAYOUT ---------- */
.admin-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; background: var(--navy-dark); color: rgba(255,255,255,.85);
  padding: 26px 18px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; color: var(--white); font-weight: 800; font-size: 17px; padding: 0 8px 26px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 500; margin-bottom: 4px; transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: var(--white); }
.sidebar nav a.active { background: var(--red); color: var(--white); }
.sidebar .icon { width: 20px; text-align: center; }
.sidebar-footer { margin-top: 30px; padding-top: 18px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer .user-email { font-size: 12px; color: rgba(255,255,255,.55); padding: 0 14px 10px; word-break: break-all; }
.logout-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; background: none; border: none;
  color: rgba(255,255,255,.75); font-size: 14px; padding: 12px 14px; cursor: pointer; border-radius: 10px;
}
.logout-btn:hover { background: rgba(255,255,255,.06); color: var(--white); }

.main-area { flex: 1; min-width: 0; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border); padding: 18px 32px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 20px; margin: 0; color: var(--navy); }
.content { padding: 32px; }

/* ---------- WIDGETS ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; margin-bottom: 30px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 13px; color: var(--text-muted); font-weight: 600; margin-bottom: 10px; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--navy); }
.stat-card .value.red { color: var(--red); }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 26px; margin-bottom: 24px; }
.divider { border: none; border-top: 1px solid #eceff6; margin: 18px 0; }
.card-head { display: flex; align-items: center; justify-content: between; justify-content: space-between; margin-bottom: 20px; }
.card-head h2 { font-size: 17px; margin: 0; color: var(--navy); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; border: none; border-radius: 9px; padding: 11px 20px; font-weight: 600; font-size: 14px; cursor: pointer; transition: background .15s, transform .15s; }
.btn-primary { background: var(--red); color: var(--white); }
.btn-primary:hover { background: var(--red-dark); }
.btn-navy { background: var(--navy); color: var(--white); }
.btn-navy:hover { background: var(--navy-light); }
.btn-outline { background: var(--white); color: var(--navy); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--navy); }
.btn-danger { background: #fdeaec; color: var(--red-dark); }
.btn-danger:hover { background: #f9d3d8; }
.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 12px 14px; background: #f8f9fd; color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
td { padding: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 8px; }
.thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }

/* Badges */
.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-green { background: #e7f8ee; color: #1f7a4c; }
.badge-gray { background: #eef0f6; color: #5c6478; }
.badge-red { background: #fdeaec; color: var(--red-dark); }
.badge-gold { background: #fdf3e0; color: #a3720f; }
.badge-blue { background: #e6edfb; color: var(--navy); }

/* Forms */
.form-row { margin-bottom: 18px; }
.form-row label { display: block; font-weight: 600; color: var(--navy); margin-bottom: 7px; font-size: 13px; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; padding: 11px 14px; border-radius: 9px; border: 1.5px solid var(--border);
  font-family: var(--font); font-size: 14px; background: #fafbfd;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: none; border-color: var(--red); background: var(--white); }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 700px) { .form-grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* Rich editor toolbar */
.editor-toolbar { display: flex; gap: 6px; flex-wrap: wrap; background: #f8f9fd; border: 1.5px solid var(--border); border-bottom: none; border-radius: 9px 9px 0 0; padding: 8px; }
.editor-toolbar button {
  background: var(--white); border: 1px solid var(--border); border-radius: 6px; width: 34px; height: 34px;
  cursor: pointer; font-weight: 700; color: var(--navy); font-size: 14px;
}
.editor-toolbar button:hover { background: #eef1fa; }
.editor-content {
  min-height: 280px; border: 1.5px solid var(--border); border-radius: 0 0 9px 9px; padding: 16px;
  font-size: 14px; line-height: 1.7; background: var(--white);
}
.editor-content:focus { outline: none; border-color: var(--red); }
.editor-content img { max-width: 100%; border-radius: 8px; }

/* Toggle */
.toggle-group { display: flex; gap: 10px; }
.toggle-btn { flex: 1; padding: 12px; border-radius: 9px; border: 1.5px solid var(--border); background: var(--white); font-weight: 600; cursor: pointer; text-align: center; }
.toggle-btn.active { background: var(--navy); color: var(--white); border-color: var(--navy); }

/* Image uploader */
.upload-box {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 30px; text-align: center;
  cursor: pointer; background: #fafbfd; margin-bottom: 14px; transition: border-color .15s;
}
.upload-box:hover { border-color: var(--red); }
.upload-preview { max-height: 160px; border-radius: 8px; margin: 0 auto 10px; }

/* Gallery manager grid */
.gallery-manager-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.gallery-item { background: var(--white); border-radius: 10px; overflow: hidden; box-shadow: var(--shadow); position: relative; }
.gallery-item img { width: 100%; height: 130px; object-fit: cover; }
.gallery-item .gi-body { padding: 10px 12px; }
.gallery-item .gi-order { font-size: 12px; color: var(--text-muted); }
.gallery-item .gi-actions { display: flex; gap: 6px; margin-top: 8px; }
@media (max-width: 900px) { .gallery-manager-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(6,22,68,.55); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--white); border-radius: 14px; padding: 28px; max-width: 440px; width: 100%; }
.modal-box h3 { margin-top: 0; color: var(--navy); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.spinner { width: 30px; height: 30px; border: 4px solid #e0e4f0; border-top-color: var(--red); border-radius: 50%; margin: 30px auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; bottom: 24px; right: 24px; background: var(--navy); color: var(--white); padding: 14px 22px; border-radius: 10px; box-shadow: var(--shadow); font-size: 14px; font-weight: 600; z-index: 300; display: none; }
.toast.show { display: block; }
.toast.error { background: var(--red-dark); }

.mobile-menu-btn { display: none; background: none; border: none; font-size: 22px; color: var(--navy); cursor: pointer; }
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 150; transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu-btn { display: block; }
  .content { padding: 20px; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- LOGIN: mesaj enfòmasyon + bouton lyen ---------- */
.login-info { display: none; background: #e7f0ff; color: var(--navy); padding: 12px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; font-weight: 600; }
.link-btn { display: block; width: 100%; margin-top: 16px; background: none; border: none; color: var(--navy); font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: underline; }

/* ---------- FILTÈ, KÒD, RAPÒ, ENPRIME ---------- */
.filters-row { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.filters-row .form-row { margin-bottom: 0; min-width: 140px; }
.filters-row .form-row.grow { flex: 1; min-width: 200px; }
.code-box { margin-top: 18px; background: #fdf3e0; border: 1.5px dashed var(--gold); border-radius: 10px; padding: 16px 18px; font-size: 14px; overflow-wrap: anywhere; }
.code-box strong.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; letter-spacing: 1px; color: var(--navy); }
.code-text { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 700; color: var(--navy); }
.report-section { margin-bottom: 24px; }
.report-section h3 { margin: 0 0 14px; color: var(--navy); font-size: 16px; }
.mini-note { font-size: 12px; color: var(--text-muted); }
.print-only { display: none; }
.stat-card .value.small { font-size: 20px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .stat-grid { grid-template-columns: minmax(0, 1fr) !important; } }
@media print {
  .sidebar, .topbar, .no-print, .toast, .mobile-menu-btn { display: none !important; }
  .print-only { display: block !important; }
  .admin-layout { display: block; }
  .main-area { margin: 0; width: 100%; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .stat-card { box-shadow: none; border: 1px solid #ddd; break-inside: avoid; }
  .report-head h2 { color: #0a2463; margin-bottom: 4px; }
}
