/* ═══════════════════════════════════════════════════════════
   ATEL — Administration locale (prototype)
   Isolation : /admin/ uniquement — ne pas importer dans styles.css
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────── */
:root {
  --adm-orange:      #C84E18;
  --adm-orange-lt:   #FFF1E8;
  --adm-orange-hover:#a8400f;
  --adm-blue:        #1B5DA0;
  --adm-blue-lt:     #EBF3FB;
  --adm-bg:          #F2F4F7;
  --adm-white:       #FFFFFF;
  --adm-text:        #1C2B38;
  --adm-mid:         #536070;
  --adm-light:       #8896A4;
  --adm-border:      #E0E6ED;
  --adm-success:     #16A34A;
  --adm-success-lt:  #DCFCE7;
  --adm-danger:      #DC2626;
  --adm-danger-lt:   #FEE2E2;
  --adm-shadow-sm:   0 1px 3px rgba(0,0,0,.05), 0 4px 12px rgba(0,0,0,.07);
  --adm-shadow-md:   0 2px 8px rgba(0,0,0,.06), 0 12px 32px rgba(0,0,0,.10);
  --adm-radius:      12px;
  --adm-font-head:   'Poppins', sans-serif;
  --adm-font-body:   'Nunito', sans-serif;
  --header-h:        64px;
  --sidebar-w:       240px;
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--adm-font-body);
  background: var(--adm-bg);
  color: var(--adm-text);
  line-height: 1.65;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { font-family: var(--adm-font-body); cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: var(--adm-font-body); font-size: 1rem; color: var(--adm-text); }
h1, h2, h3 { font-family: var(--adm-font-head); color: var(--adm-text); line-height: 1.25; }

/* ── Utility ─────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════
   BOUTONS
══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-family: var(--adm-font-body);
  font-weight: 700;
  font-size: .9rem;
  padding: .6rem 1.25rem;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, opacity .2s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

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

.btn--secondary {
  background: var(--adm-white);
  color: var(--adm-text);
  border-color: var(--adm-border);
}
.btn--secondary:hover { border-color: var(--adm-mid); }

.btn--ghost {
  background: transparent;
  color: var(--adm-mid);
}
.btn--ghost:hover { background: rgba(0,0,0,.05); color: var(--adm-text); }

.btn--danger {
  background: var(--adm-danger);
  color: #fff;
  border-color: var(--adm-danger);
}
.btn--danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn--full { width: 100%; justify-content: center; }
.btn--logout { font-size: .85rem; padding: .5rem 1rem; gap: .4rem; }

/* Bouton fichier (label déguisé en bouton) */
.btn--file {
  display: inline-flex;
  align-items: center;
  padding: .55rem 1rem;
  border-radius: 8px;
  border: 2px solid var(--adm-border);
  background: var(--adm-white);
  color: var(--adm-mid);
  font-weight: 700;
  font-size: .88rem;
  cursor: pointer;
  transition: border-color .2s, color .2s;
  white-space: nowrap;
}
.btn--file:hover { border-color: var(--adm-orange); color: var(--adm-orange); }

/* Boutons action dans la liste */
.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .38rem .875rem;
  border-radius: 6px;
  font-family: var(--adm-font-body);
  font-size: .82rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  white-space: nowrap;
}
.btn-edit {
  background: var(--adm-blue-lt);
  color: var(--adm-blue);
  border-color: rgba(27,93,160,.2);
}
.btn-edit:hover { background: var(--adm-blue); color: #fff; border-color: var(--adm-blue); }

.btn-retire {
  background: var(--adm-danger-lt);
  color: var(--adm-danger);
  border-color: rgba(220,38,38,.2);
}
.btn-retire:hover { background: var(--adm-danger); color: #fff; border-color: var(--adm-danger); }

.btn-republish {
  background: var(--adm-success-lt);
  color: var(--adm-success);
  border-color: rgba(22,163,74,.2);
}
.btn-republish:hover { background: var(--adm-success); color: #fff; border-color: var(--adm-success); }

/* ══════════════════════════════════════════════
   ÉCRAN DE CONNEXION
══════════════════════════════════════════════ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(145deg, #eef1f5 0%, #e4eaf2 100%);
}

.login-card {
  background: var(--adm-white);
  border-radius: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,.04), 0 24px 64px rgba(0,0,0,.11);
  padding: 3rem 2.5rem 2.5rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.125rem;
}

.login-logo {
  height: 68px;
  width: auto;
  object-fit: contain;
}

.login-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-top: -.25rem;
}

.login-subtitle {
  font-size: .88rem;
  color: var(--adm-mid);
  text-align: center;
  margin-top: -.5rem;
}

.login-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: .25rem;
}

.login-error {
  color: var(--adm-danger);
  font-size: .84rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.2em;
}

.login-forgot-link {
  background: none;
  border: none;
  padding: 0;
  font-size: .84rem;
  color: var(--adm-mid);
  text-decoration: underline;
  cursor: pointer;
  text-align: center;
}

.login-message {
  color: var(--adm-success);
  font-size: .84rem;
  font-weight: 600;
  text-align: center;
}
.login-message:empty { display: none; }

/* ══════════════════════════════════════════════
   LAYOUT TABLEAU DE BORD
══════════════════════════════════════════════ */
.dashboard { min-height: 100vh; display: flex; flex-direction: column; }

/* ── En-tête ─────────────────────────────────────────────── */
.admin-header {
  height: var(--header-h);
  background: var(--adm-white);
  border-bottom: 1px solid var(--adm-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.admin-header__left {
  display: flex;
  align-items: center;
  gap: .875rem;
}

.sidebar-toggle {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  color: var(--adm-mid);
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.sidebar-toggle:hover { background: var(--adm-bg); color: var(--adm-text); }
.sidebar-toggle svg { width: 20px; height: 20px; }

.header-logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.admin-header__title {
  font-family: var(--adm-font-head);
  font-size: .95rem;
  font-weight: 700;
  color: var(--adm-text);
}

/* ── Corps du layout ─────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: calc(100vh - var(--header-h));
  margin-top: var(--header-h);
}

/* ── Overlay sidebar mobile ──────────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.42);
  z-index: 150;
}
.sidebar-backdrop.active { display: block; }

/* ── Barre latérale ──────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--adm-white);
  border-right: 1px solid var(--adm-border);
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 1.25rem .875rem;
  z-index: 160;
  transition: transform .25s ease, box-shadow .25s ease;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--adm-mid);
  transition: background .2s, color .2s;
}
.sidebar-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-link:hover { background: var(--adm-bg); color: var(--adm-text); }
.sidebar-link.active { background: var(--adm-orange-lt); color: var(--adm-orange); }

/* ── Contenu principal ───────────────────────────────────── */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 2rem 2.25rem;
  min-width: 0;
}

.admin-section { display: block; }

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

.section-title { font-size: 1.35rem; font-weight: 700; }
.section-count { font-size: .82rem; color: var(--adm-mid); margin-top: .2rem; }

/* ── Tableau de bord : bienvenue + stats ─────────────────── */
.dashboard-welcome {
  background: var(--adm-white);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 1.5rem 2rem;
  color: var(--adm-mid);
  line-height: 1.8;
  margin-bottom: 1.5rem;
}
.dashboard-welcome strong { color: var(--adm-text); }

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

.stat-card {
  background: var(--adm-white);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--adm-shadow-sm);
}
.stat-card__number {
  font-family: var(--adm-font-head);
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--adm-orange);
  line-height: 1;
  margin-bottom: .5rem;
}
.stat-card__label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--adm-mid);
}

/* ══════════════════════════════════════════════
   LISTE DES ACTIVITÉS
══════════════════════════════════════════════ */
.activites-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.activity-row {
  background: var(--adm-white);
  border: 1px solid var(--adm-border);
  border-radius: var(--adm-radius);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
  transition: box-shadow .2s;
}
.activity-row:hover { box-shadow: var(--adm-shadow-sm); }

.activity-row__thumb {
  flex-shrink: 0;
  width: 96px;
  height: 68px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--adm-bg);
}
.activity-row__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.activity-row__info {
  flex: 1;
  min-width: 0;
}
.activity-row__title {
  font-family: var(--adm-font-head);
  font-size: .93rem;
  font-weight: 700;
  color: var(--adm-text);
  margin-bottom: .4rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-row__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .45rem;
}
.meta-date {
  font-size: .8rem;
  color: var(--adm-mid);
}
.meta-platform {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 20px;
}
.meta-platform--instagram { background: #fce4ec; color: #c13584; }
.meta-platform--facebook  { background: #e3f2fd; color: #1877f2; }
.meta-status {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: .18rem .5rem;
  border-radius: 20px;
}
.status-published { background: var(--adm-success-lt); color: var(--adm-success); }
.status-draft     { background: #f1f5f9;               color: var(--adm-light);   }

.activity-row__actions {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  align-items: stretch;
}

.empty-state {
  text-align: center;
  color: var(--adm-mid);
  padding: 3rem 2rem;
  font-size: 1rem;
  background: var(--adm-white);
  border: 1px dashed var(--adm-border);
  border-radius: var(--adm-radius);
}

/* ══════════════════════════════════════════════
   FORMULAIRES
══════════════════════════════════════════════ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}
.form-group label:first-child {
  font-weight: 700;
  font-size: .9rem;
  color: var(--adm-text);
}
.required { color: var(--adm-orange); margin-left: .1em; }

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="date"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--adm-border);
  border-radius: 8px;
  background: var(--adm-white);
  color: var(--adm-text);
  font-size: .95rem;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
  -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--adm-orange);
  box-shadow: 0 0 0 3px rgba(200,78,24,.12);
}
.form-group input.invalid,
.form-group select.invalid,
.form-group textarea.invalid {
  border-color: var(--adm-danger);
}
.form-group textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-group select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23536070' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; background-size: 16px; padding-right: 2.25rem; cursor: pointer; }

.file-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}
.file-row input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; overflow: hidden;
  pointer-events: none;
}
.file-name-display {
  font-size: .85rem;
  color: var(--adm-mid);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.image-preview {
  margin-top: .5rem;
  max-width: 100%;
  max-height: 200px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--adm-border);
}

.field-error {
  font-size: .82rem;
  color: var(--adm-danger);
  font-weight: 600;
}
.field-error:empty { display: none; }

.radio-group {
  display: flex;
  gap: 1.75rem;
  flex-wrap: wrap;
  margin-top: .2rem;
}
.radio-label {
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-weight: 600;
  font-size: .9rem;
  color: var(--adm-text);
}
.radio-label input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--adm-orange);
  cursor: pointer;
}

.form-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding-top: .625rem;
  border-top: 1px solid var(--adm-border);
  flex-wrap: wrap;
}

/* ══════════════════════════════════════════════
   MODAL
══════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.52);
}
.modal-panel {
  position: relative;
  background: var(--adm-white);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  width: 100%;
  max-width: 600px;
  max-height: calc(100vh - 2.5rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}
.modal-panel--sm { max-width: 440px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.375rem 1.75rem 1.125rem;
  border-bottom: 1px solid var(--adm-border);
  flex-shrink: 0;
}
.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--adm-mid);
  transition: background .2s, color .2s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--adm-bg); color: var(--adm-text); }
.modal-close svg { width: 17px; height: 17px; }

.modal-body {
  padding: 1.5rem 1.75rem;
  overflow-y: auto;
  flex: 1;
}

.activity-form { display: flex; flex-direction: column; gap: 1.1rem; }

.confirm-message {
  font-size: .93rem;
  color: var(--adm-mid);
  line-height: 1.75;
  margin-bottom: 1rem;
}

/* ══════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 210px; }
  .dashboard-stats { grid-template-columns: repeat(3, 1fr); }
  .admin-main { padding: 1.75rem 1.5rem; }
}

@media (max-width: 768px) {
  /* Afficher le burger */
  .sidebar-toggle { display: flex; }
  .header-logo { display: none; }

  /* Sidebar cachée par défaut, slide depuis la gauche */
  .admin-sidebar {
    transform: translateX(calc(-1 * var(--sidebar-w)));
    box-shadow: none;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.15);
  }

  /* Contenu prend toute la largeur */
  .admin-main { margin-left: 0; padding: 1.25rem; }

  /* Liste activités : actions en bas */
  .activity-row { flex-wrap: wrap; gap: .75rem; }
  .activity-row__thumb { width: 72px; height: 52px; }
  .activity-row__info { flex: 1 0 calc(100% - 84px); min-width: 0; }
  .activity-row__actions {
    flex-direction: row;
    width: 100%;
    justify-content: flex-end;
  }

  /* Formulaire */
  .section-header { align-items: flex-start; }
  .section-header .btn svg { display: none; }

  /* Stats */
  .dashboard-stats { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .login-card { padding: 2.25rem 1.5rem 2rem; }

  /* Modal plein écran depuis le bas */
  .modal { padding: 0; align-items: flex-end; }
  .modal-panel {
    border-radius: 16px 16px 0 0;
    max-height: 96vh;
  }

  /* Footer boutons pleine largeur */
  .form-footer { flex-direction: column-reverse; }
  .form-footer .btn { width: 100%; justify-content: center; }

  .activity-row__actions { flex-wrap: wrap; }
  .admin-main { padding: 1rem; }
  .dashboard-stats { grid-template-columns: 1fr; }
  .activity-row__title { white-space: normal; }
}
