/* ===================================================================
   Agir Ensemble — Interface d'administration
   =================================================================== */

:root {
  --rose-deep:   #8B1A4A;
  --rose-mid:    #B5305A;
  --rose-warm:   #C94E78;
  --rose-light:  #E8A0B4;
  --rose-pale:   #FDE8EF;
  --rose-blush:  #FFF4F7;
  --rose-border: #F0C8D8;
  --gold:        #C9924A;
  --white:       #FFFFFF;
  --text:        #2C1320;
  --text-body:   #4A2D3B;
  --text-muted:  #9B7080;
  --bg:          #FAF5F8;
  --surface:     #FFFFFF;
  --border:      #EDD5DF;
  --green:       #15803D;
  --green-bg:    #F0FDF4;
  --green-border:#BBF7D0;
  --red:         #9B1A4A;
  --red-bg:      #FFF1F2;
  --red-border:  #FCA5A5;
  --orange:      #C2410C;
  --orange-bg:   #FFF7ED;
  --shadow-sm:   0 2px 8px rgba(139,26,74,.06);
  --shadow:      0 4px 20px rgba(139,26,74,.10);
  --shadow-md:   0 8px 40px rgba(139,26,74,.13);
  --radius-sm:   8px;
  --radius:      14px;
  --radius-lg:   20px;
  --font-display:'Cormorant Garamond', Georgia, serif;
  --font-body:   'Nunito', system-ui, sans-serif;
  --sidebar-w:   260px;
  --header-h:    64px;
  --transition:  .25s cubic-bezier(.4,0,.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--rose-mid); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--rose-deep); }
img { max-width: 100%; height: auto; display: block; }
ul { list-style: none; }

/* ── Layout ─────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--text);
  color: rgba(255,255,255,.75);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}
.sidebar-header {
  padding: 1.5rem 1.25rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: white !important;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
}
.sidebar-logo span { color: var(--rose-light); font-weight: 700; }
.sidebar-logo small {
  display: block;
  font-family: var(--font-body);
  font-size: .7rem;
  color: rgba(255,255,255,.4);
  font-weight: 400;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 1.25rem .75rem;
}
.nav-section-label {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255,255,255,.3);
  padding: 1.25rem .5rem .5rem;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65) !important;
  font-size: .88rem;
  font-weight: 600;
  transition: all var(--transition);
  margin-bottom: .15rem;
  position: relative;
}
.sidebar-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .8; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: white !important; }
.sidebar-link.active {
  background: var(--rose-mid);
  color: white !important;
}
.sidebar-link.active svg { opacity: 1; }
.sidebar-link .badge {
  margin-left: auto;
  background: var(--rose-warm);
  color: white;
  font-size: .65rem;
  font-weight: 700;
  padding: .15rem .5rem;
  border-radius: 99px;
  min-width: 20px;
  text-align: center;
}
.sidebar-link.active .badge { background: rgba(255,255,255,.3); }

.sidebar-footer {
  padding: 1rem .75rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem .85rem;
  border-radius: var(--radius-sm);
  margin-bottom: .5rem;
  background: rgba(255,255,255,.05);
}
.user-avatar {
  width: 34px; height: 34px;
  background: var(--rose-mid);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .9rem;
  color: white;
  flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 600; color: rgba(255,255,255,.8); }
.user-role { font-size: .72rem; color: rgba(255,255,255,.4); }

/* ── Main content ────────────────────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top bar ─────────────────────────────────────────────────────── */
.admin-topbar {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
}
.topbar-breadcrumb {
  font-size: .82rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.topbar-breadcrumb a { color: var(--rose-mid); }
.topbar-breadcrumb svg { width: 10px; height: 10px; }

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.topbar-site-link {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .84rem;
  font-weight: 600;
  color: var(--text-muted) !important;
  padding: .4rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  transition: all var(--transition);
}
.topbar-site-link:hover { border-color: var(--rose-light); color: var(--rose-mid) !important; }
.topbar-site-link svg { width: 14px; height: 14px; }

/* ── Content area ────────────────────────────────────────────────── */
.admin-content {
  flex: 1;
  padding: 2rem 1.75rem;
  max-width: 1100px;
}

/* ── Page header ────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}
.page-header p {
  font-size: .9rem;
  color: var(--text-muted);
  margin-top: .2rem;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: .85rem;
  padding: .6rem 1.4rem;
  border-radius: 99px;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; }
.btn-rose  { background: var(--rose-mid); color: white; }
.btn-rose:hover { background: var(--rose-deep); color: white; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { border-color: var(--rose-light); color: var(--rose-mid); }
.btn-danger { background: #fee2e2; color: #991b1b; }
.btn-danger:hover { background: #fca5a5; }
.btn-success { background: var(--green-bg); color: var(--green); border: 1.5px solid var(--green-border); }
.btn-sm { padding: .4rem 1rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.75rem; font-size: .92rem; }

/* ── Cards ─────────────────────────────────────────────────────── */
.admin-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.75rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}
.admin-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.admin-card-header h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

/* ── Stat cards ──────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; }
.stat-icon.rose  { background: var(--rose-pale);  color: var(--rose-mid); }
.stat-icon.green { background: var(--green-bg);   color: var(--green); }
.stat-icon.gold  { background: #FFF7ED;            color: var(--gold); }
.stat-icon.blue  { background: #EFF6FF;            color: #2563EB; }
.stat-number { font-family: var(--font-display); font-size: 2.2rem; font-weight: 700; color: var(--text); line-height: 1; }
.stat-label  { font-size: .8rem; color: var(--text-muted); font-weight: 600; margin-top: .25rem; }

/* ── Table ────────────────────────────────────────────────────────── */
.admin-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.admin-table th {
  text-align: left;
  padding: .85rem 1rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--rose-blush); }
.admin-table .thumb {
  width: 52px; height: 36px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}
.admin-table .no-thumb {
  width: 52px; height: 36px;
  background: var(--rose-pale);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.admin-table .no-thumb svg { width: 16px; height: 16px; color: var(--rose-border); }
.table-title {
  font-weight: 600;
  color: var(--text);
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Badge statut */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .72rem;
  font-weight: 700;
  padding: .25rem .7rem;
  border-radius: 99px;
}
.badge-published { background: var(--green-bg); color: var(--green); }
.badge-draft     { background: var(--orange-bg); color: var(--orange); }
.badge-unread    { background: var(--rose-pale); color: var(--rose-mid); }
.badge-read      { background: var(--bg); color: var(--text-muted); }
.badge svg { width: 9px; height: 9px; }

/* Table actions */
.table-actions { display: flex; align-items: center; gap: .5rem; }
.action-btn {
  width: 30px; height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  color: var(--text-muted) !important;
  border: 1px solid var(--border);
  background: white;
}
.action-btn svg { width: 14px; height: 14px; }
.action-btn:hover { transform: scale(1.1); }
.action-btn.edit:hover   { background: #EFF6FF; color: #2563EB !important; border-color: #BFDBFE; }
.action-btn.delete:hover { background: var(--red-bg); color: var(--red) !important; border-color: var(--red-border); }
.action-btn.view:hover   { background: var(--rose-pale); color: var(--rose-mid) !important; border-color: var(--rose-border); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.form-full  { grid-column: 1 / -1; }
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-weight: 700;
  font-size: .83rem;
  color: var(--text);
  margin-bottom: .45rem;
}
.form-group label .required { color: var(--rose-mid); margin-left: .2rem; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: .9rem;
  outline: none;
  transition: all var(--transition);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--rose-mid);
  background: white;
  box-shadow: 0 0 0 3px rgba(181,48,90,.1);
}
.form-group textarea { resize: vertical; min-height: 100px; }
.form-hint { font-size: .76rem; color: var(--text-muted); margin-top: .35rem; }
.form-check {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
}
.form-check input[type="checkbox"] {
  width: 18px; height: 18px;
  border-radius: 5px;
  cursor: pointer;
  accent-color: var(--rose-mid);
}

/* Upload */
.upload-area {
  border: 2px dashed var(--rose-border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  background: var(--rose-blush);
  transition: all var(--transition);
  cursor: pointer;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--rose-mid);
  background: var(--rose-pale);
}
.upload-area svg { width: 36px; height: 36px; color: var(--rose-light); margin: 0 auto .75rem; }
.upload-area p   { font-size: .88rem; color: var(--text-muted); margin: 0; }
.upload-area strong { color: var(--rose-mid); }
.upload-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .75rem;
  background: var(--bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: .75rem;
}
.upload-preview img { width: 80px; height: 56px; object-fit: cover; border-radius: 8px; }
.upload-preview-info { flex: 1; }
.upload-preview-info p { font-size: .82rem; color: var(--text-muted); margin: 0; }

/* Sidebar layout for edit */
.edit-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
  align-items: start;
}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert {
  padding: .85rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
}
.alert svg { width: 16px; height: 16px; flex-shrink: 0; }
.alert-success { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-border); }
.alert-error   { background: var(--red-bg);   color: var(--red);   border: 1px solid var(--red-border); }
.alert-info    { background: var(--rose-pale); color: var(--rose-deep); border: 1px solid var(--rose-border); }

/* ── Login page ──────────────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--rose-deep) 0%, var(--rose-warm) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 3rem 2.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,.2);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .ribbon { font-size: 2.5rem; display: block; margin-bottom: .5rem; }
.login-logo h1 { font-family: var(--font-display); font-size: 1.8rem; color: var(--text); }
.login-logo p  { font-size: .85rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Galerie admin ───────────────────────────────────────────────── */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: .65rem;
}
.gallery-admin-item {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--border);
  background: var(--bg);
  aspect-ratio: 1;
}
.gallery-admin-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.gallery-delete-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  padding: .4rem;
  background: linear-gradient(to top, rgba(139,26,74,.75) 0%, transparent 60%);
  opacity: 0;
  transition: opacity var(--transition);
  cursor: pointer;
  font-size: .72rem;
  font-weight: 700;
  color: white;
  gap: .25rem;
}
.gallery-admin-item:hover .gallery-delete-label { opacity: 1; }
.gallery-delete-label input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: #fff;
  cursor: pointer;
}
/* Coché = mise en évidence rouge */
.gallery-delete-label:has(input:checked) {
  opacity: 1;
  background: linear-gradient(to top, rgba(180,0,0,.8) 0%, rgba(180,0,0,.3) 100%);
}
.gallery-preview-name {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  font-size: .65rem;
  color: white;
  background: rgba(0,0,0,.5);
  padding: .2rem .4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── TinyMCE wrapper ─────────────────────────────────────────────── */
.tox-tinymce { border-radius: var(--radius-sm) !important; border-color: var(--border) !important; }

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-content { padding: 1.25rem; }
  .edit-layout { grid-template-columns: 1fr; }
  .form-grid   { grid-template-columns: 1fr; }
  .stats-grid  { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-topbar { padding: 0 1rem; }
  .login-card { padding: 2rem 1.5rem; }
}
