/* ─── ADMIN-SPECIFIC VARIABLES (extends common.css) ─── */
:root {
  --col-art-bg: #ffffff;
  --editor-bg: #ffffff;
  --tags-bg: #ffffff;
  --tiptap-bg: #ffffff;
  --tiptap-h-color: #22262d;
  --tiptap-h2-border: #f0f9ff;
  --tiptap-h3-color: #1f2937;
  --tiptap-bq-bg: #f0f9ff;
  --tiptap-code-bg: #f0f9ff;
  --tiptap-code-color: #0369a1;
  --tt-select-bg: #ffffff;
}

[data-theme="dark"] {
  --col-art-bg: #1e293b;
  --editor-bg: #1e293b;
  --tags-bg: #0f172a;
  --tiptap-bg: #0f172a;
  --tiptap-h-color: #f1f5f9;
  --tiptap-h2-border: #1e293b;
  --tiptap-h3-color: #e2e8f0;
  --tiptap-bq-bg: rgba(0,191,255,0.08);
  --tiptap-code-bg: #1e293b;
  --tiptap-code-color: #67e8f9;
  --tt-select-bg: #1e293b;
}

/* Reset + font-family inherited from common.css */
body { height: 100vh; overflow: hidden; }

/* ─── LOGIN ─── */
.login-page {
  position: fixed; inset: 0;
  background: var(--dark);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
  z-index: 9000;
}
.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 40px 36px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.4);
}
.login-logo {
  text-align: center;
  margin-bottom: 6px;
}
.login-logo img {
  height: 26px;
  width: auto;
  max-width: 160px;
}
.login-subtitle {
  text-align: center;
  color: var(--text-light);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 32px;
}
.login-card form { display: flex; flex-direction: column; gap: 0; }
.login-card label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}
.pwd-field {
  position: relative;
  margin-bottom: 20px;
}
.pwd-field input {
  width: 100%;
  padding: 12px 44px 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
  background: var(--input-bg2);
}
.pwd-field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,191,255,0.15);
  background: var(--input-bg);
}
.pwd-toggle {
  position: absolute;
  right: 12px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; color: var(--text-light);
  padding: 4px;
  display: flex; align-items: center;
}
.pwd-toggle:hover { color: var(--dark); }
.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--primary);
  color: var(--dark);
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.01em;
}
.btn-login:hover { opacity: 0.9; }
.btn-login:active { transform: scale(0.98); }
.btn-login:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.login-error {
  color: #ef4444;
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
  min-height: 18px;
}

/* ─── ADMIN TOPBAR ─── */
.admin-topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 500;
  height: 34px;
  background: #1a1f27;
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  padding: 0 16px;
  display: none;
  align-items: center;
  justify-content: space-between;
}
.admin-topbar-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
.admin-topbar-link:hover { text-decoration: underline; }

/* ─── APP LAYOUT ─── */
.app { display: none; height: 100vh; }
.app.visible {
  display: flex;
  padding-top: 34px;
}
.app.visible .admin-topbar { display: flex; }

/* theme-toggle, sidebar, sidebar-header, sidebar-section, sidebar-footer, nav-item, btn-icon, btn-logout — tous hérités de common.css */

/* Sidebar dans l'admin : position relative (pas fixed comme sur l'accueil) */
#col-categories {
  position: relative;
  min-height: 0;
}
/* Sur mobile, masquer le sidebar-header (le mobile-header-dark le remplace) */
@media (max-width: 768px) { #col-categories .sidebar-header { display: none; } }

/* Brouillons */
.nav-item-drafts { border-bottom: 1px solid var(--sidebar-border); margin-bottom: 4px; }
.draft-count { display: inline-flex; align-items: center; justify-content: center; background: rgba(251,191,36,0.25); color: #fbbf24; border-radius: 10px; font-size: 10px; font-weight: 700; padding: 1px 6px; margin-left: 4px; }

/* Colonne articles */
.col-articles {
  width: 280px; background: var(--col-art-bg); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
  transition: background 0.2s;
}
.col-articles .col-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.col-articles .col-header h3 { font-size: 13px; font-weight: 600; color: var(--text); text-transform: uppercase; letter-spacing: 0.05em; }
.articles-list { flex: 1; overflow-y: auto; padding: 8px; }
.article-item {
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  transition: background 0.15s; margin-bottom: 2px;
}
.article-item:hover { background: var(--bg); }
.article-item.active { background: rgba(0,191,255,0.1); border-left: 3px solid var(--primary); padding-left: 9px; }
.article-item .a-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 3px; }
.article-item .a-meta { display: flex; align-items: center; gap: 6px; }
.badge-published { background: #dcfce7; color: #166534; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.badge-draft { background: #f3f4f6; color: var(--text-light); font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 10px; }
.btn-new-article {
  margin: 8px; padding: 8px 12px; background: var(--primary); color: var(--dark);
  border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}
.btn-new-article:hover { opacity: 0.85; }

/* Zone éditeur */
.col-editor {
  flex: 1; display: flex; flex-direction: column; overflow: hidden; background: var(--editor-bg);
  transition: background 0.2s;
}
.editor-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 8px 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; background: var(--toolbar-bg);
}
.toolbar-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.tb-btn {
  min-width: 30px; height: 30px; padding: 0 6px;
  background: none; border: none; border-radius: 5px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text); transition: all 0.15s;
  display: flex; align-items: center; justify-content: center;
}
.tb-btn:hover { background: var(--bg); }
.tb-btn.active { background: var(--primary); color: white; }
.tb-btn-md { background: #d1fae5; color: #065f46; font-size: 12px; }
.tb-btn-md:hover { background: #a7f3d0; }
.tb-btn-img { background: #dbeafe; color: #1e40af; font-size: 12px; }
.tb-btn-img:hover { background: #bfdbfe; }

/* Form fields */
.editor-form { flex: 1; overflow-y: auto; padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.form-row { display: flex; gap: 12px; }
/* .form-group inherited from common.css */
.title-input { font-size: 18px !important; font-weight: 600 !important; color: var(--dark) !important; }

/* Tags chips */
.tags-input-wrap {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  min-height: 40px; background: var(--tags-bg); cursor: text;
}
.tags-input-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,191,255,0.12); }
.tag-chip {
  display: flex; align-items: center; gap: 4px;
  background: #e0f9ff; color: #0369a1; padding: 3px 10px 3px 10px;
  border-radius: 20px; font-size: 12px; font-weight: 500;
}
.tag-chip button { background: none; border: none; cursor: pointer; color: #0369a1; font-size: 14px; padding: 0; line-height: 1; }
.tag-chip button:hover { color: #ef4444; }
.tag-input { border: none; outline: none; font-size: 13px; flex: 1; min-width: 80px; }

/* TipTap editor zone */
.tiptap-wrap {
  border: 1px solid var(--border); border-radius: 8px; background: var(--tiptap-bg);
  min-height: 350px; cursor: text; overflow: hidden;
}
.ProseMirror {
  padding: 16px; min-height: 350px; outline: none;
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.ProseMirror:focus { outline: none; }
.ProseMirror p.is-editor-empty:first-child::before {
  content: attr(data-placeholder); color: #9ca3af; pointer-events: none; float: left; height: 0;
}
.ProseMirror h1 { font-size: 1.8rem; font-weight: 800; color: var(--dark); margin: 1.5rem 0 0.75rem; }
.ProseMirror h2 { font-size: 1.4rem; font-weight: 700; color: var(--dark); margin: 1.5rem 0 0.75rem; }
.ProseMirror h3 { font-size: 1.1rem; font-weight: 600; color: var(--dark); margin: 1.2rem 0 0.5rem; }
.ProseMirror ul, .ProseMirror ol { padding-left: 1.5rem; margin: 0.75rem 0; }
.ProseMirror li { margin-bottom: 0.3rem; }
.ProseMirror blockquote { border-left: 4px solid var(--primary); background: #f0f9ff; padding: 0.75rem 1rem; border-radius: 0 6px 6px 0; margin: 1rem 0; color: var(--text); }
.ProseMirror code { background: #f0f9ff; color: #0369a1; padding: 2px 6px; border-radius: 4px; font-size: 0.88em; }
.ProseMirror pre { background: #1e293b; color: #e2e8f0; padding: 1rem; border-radius: 8px; margin: 1rem 0; overflow-x: auto; }
.ProseMirror pre code { background: none; color: inherit; padding: 0; }
.ProseMirror table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.ProseMirror th { background: #f8fafc; padding: 10px 14px; font-weight: 600; border: 1px solid var(--border); }
.ProseMirror td { padding: 10px 14px; border: 1px solid var(--border); }
.ProseMirror a { color: var(--primary); text-decoration: underline; }
.ProseMirror p { margin-bottom: 0.75rem; }
.ProseMirror hr { border: none; border-top: 2px solid var(--border); margin: 1.5rem 0; }

/* Bottom bar */
.editor-bottom {
  padding: 12px 24px; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--bottom-bar-bg);
}
.publish-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.toggle-switch {
  position: relative; width: 44px; height: 24px; display: inline-block;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: #d1d5db; border-radius: 24px; cursor: pointer; transition: background 0.2s;
}
.toggle-slider:before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: white; border-radius: 50%; transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--primary); }
.toggle-switch input:checked + .toggle-slider:before { transform: translateX(20px); }
.btn-save {
  padding: 9px 20px; background: #22262d; color: white;
  border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; transition: opacity 0.2s;
}
[data-theme="dark"] .btn-save { background: #334155; color: #f1f5f9; }
.btn-save:hover { opacity: 0.85; }
.btn-delete {
  padding: 9px 16px; background: none; color: #ef4444; border: 1px solid #fecaca;
  border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.btn-delete:hover { background: #fef2f2; }
.editor-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-light); font-size: 14px; flex-direction: column; gap: 8px;
}

/* .modal-overlay + .modal base inherited from common.css */
.modal-cat-item {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px;
}
.modal-cat-item input { flex: 1; padding: 5px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; background: var(--input-bg); color: var(--text); }
.modal-cat-item input:focus { border-color: var(--primary); }
.modal-cat-item .icon-input { width: 46px; text-align: center; }
.btn-remove { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 16px; padding: 2px 6px; }
.modal-add-row { display: flex; gap: 8px; margin-top: 12px; }
.modal-add-row input { flex: 1; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; background: var(--input-bg); color: var(--text); }
.modal-add-row input:focus { border-color: var(--primary); }
.btn-add-cat {
  padding: 8px 16px; background: var(--primary); color: var(--dark);
  border: none; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.modal-close { float: right; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-light); }
/* .toast inherited from common.css */

/* ─── RESPONSIVE MOBILE ADMIN ─── */
@media (max-width: 768px) {
  body { overflow: auto; height: auto; }

  /* Header fixe en haut — toujours sombre (.mobile-header-dark hérité de common.css) */
  .mobile-header-dark {
    display: flex;
    position: fixed;
    top: 34px; left: 0; right: 0;
    height: 52px;
    z-index: 500;
  }

  /* L'app devient un conteneur plein écran avec padding-top pour le header */
  .app.visible {
    flex-direction: column;
    height: calc(100vh - 52px - 34px);
    margin-top: calc(52px + 34px);
    overflow: hidden;
    position: relative;
    padding-top: 0;
  }

  /* Chaque colonne devient un panel plein écran */
  #col-categories,
  .col-articles,
  .col-editor {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    transition: transform 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
  }

  /* État de base : articles visible, éditeur caché à droite, catégories tiroir à gauche */
  #col-categories { transform: translateX(-100%); z-index: 10; width: min(var(--sidebar-width), 85vw); box-shadow: none; }
  .col-articles   { transform: translateX(0); z-index: 2; }
  .col-editor     { transform: translateX(100%); z-index: 1; }

  /* Tiroir catégories ouvert */
  #col-categories.panel-active { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }

  /* Articles actifs */
  .col-articles.panel-active { transform: translateX(0); z-index: 2; }

  /* Éditeur actif */
  .col-editor.panel-active { transform: translateX(0); z-index: 3; }

  /* Overlay pour fermer le tiroir catégories (.overlay hérité de common.css) */
  #admin-cats-overlay {
    display: none; position: absolute; inset: 0; z-index: 9;
  }
  #admin-cats-overlay.visible { display: block; }

  /* Masquer le footer desktop (logout), la sidebar-header (remplacée par mobile-header-dark) */
  .sidebar-footer { display: none; }

  /* Sidebar catégories */
  #col-categories {
    display: flex;
    flex-direction: column;
  }
  .sidebar-nav-dark {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Articles */
  .col-articles {
    background: var(--col-art-bg);
    display: flex;
    flex-direction: column;
  }
  .articles-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Éditeur */
  .col-editor {
    background: var(--editor-bg);
    display: flex;
    flex-direction: column;
  }
  #editor-form-wrap {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .editor-form {
    padding: 16px;
  }
  .form-row {
    flex-direction: column;
  }
  #editor-container {
    min-height: 250px !important;
  }
  .editor-bottom {
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 16px;
    position: sticky;
    bottom: 0;
    background: var(--bottom-bar-bg);
    border-top: 1px solid var(--border);
  }
  .editor-bottom > div {
    flex: 1;
    justify-content: flex-end;
  }
  .btn-save, .btn-delete {
    flex: 1;
  }

  /* Modal plein écran sur mobile */
  .modal {
    width: calc(100vw - 32px);
    max-height: 85vh;
    margin: 0 16px;
  }


  .tiptap-toolbar {
    flex-wrap: wrap;
  }
}
