/* ==============================================
   ADMIN PANEL STYLES
   ============================================== */

:root {
  --primary: #8c7358;
  --secondary: #2b2a28;
  --accent: #ebe4da;
  --text-dark: #2c2c2c;
  --text-light: #f5f5f5;
  --bg-light: #fafafa;
  --bg-lighter: #fff;
  --border: #e0e0e0;
  --hover: #75604a;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
  --info: #3498db;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg-light);
  color: var(--text-dark);
}

/* ==============================================
   LOGIN PAGE
   ============================================== */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--secondary) 0%, #0d0d0d 100%);
}

.login-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  max-width: 900px;
  width: 90%;
  align-items: center;
}

.login-box {
  background: var(--bg-lighter);
  border-radius: 15px;
  padding: 3rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideInLeft 0.6s ease;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-header h1 {
  color: var(--secondary);
  font-size: 2rem;
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
}

.login-header p {
  color: var(--primary);
  font-weight: 600;
}

.login-form[hidden],
#activationPreparation[hidden],
#activationResult[hidden],
.checkbox[hidden] {
  display: none;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"] {
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  transition: all 0.3s;
  font-family: inherit;
}

.form-group input[type="text"]:focus,
.form-group input[type="password"]:focus,
.form-group input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
  background: rgba(212, 165, 116, 0.05);
}

.form-group.checkbox {
  flex-direction: row;
  align-items: center;
  margin: 0;
}

.form-group.checkbox input {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.form-group.checkbox label {
  margin-bottom: 0;
  margin-left: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.login-button {
  padding: 0.9rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--hover) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
}

.login-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 165, 116, 0.3);
}

.login-button:active {
  transform: translateY(0);
}

.error-message {
  color: var(--danger);
  font-size: 0.9rem;
  text-align: center;
  min-height: 20px;
}

.login-footer {
  text-align: center;
  margin-top: 1.5rem;
}

.back-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.3s;
}

.back-link:hover {
  color: var(--hover);
}

.login-info {
  background: rgba(255, 255, 255, 0.1);
  padding: 2rem;
  border-radius: 15px;
  color: var(--text-light);
  animation: slideInRight 0.6s ease;
}

.login-info h3 {
  margin-bottom: 1rem;
  color: var(--primary);
}

.login-info p {
  margin: 0.5rem 0;
  font-family: 'Courier New', monospace;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.5rem;
  border-radius: 5px;
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==============================================
   ADMIN DASHBOARD
   ============================================== */

.admin-page {
  display: grid;
  grid-template-columns: 250px 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--secondary);
  color: var(--text-light);
  padding: 1.5rem;
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  position: relative;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 2px solid rgba(212, 165, 116, 0.2);
}

.sidebar-logo {
  font-size: 2rem;
}

.sidebar-header h2 {
  color: var(--primary);
  font-size: 1.3rem;
  letter-spacing: 1px;
  flex: 1;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.5rem;
  cursor: pointer;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  color: rgba(245, 245, 245, 0.7);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.3s;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(212, 165, 116, 0.1);
  color: var(--text-light);
}

.nav-item.active {
  background: var(--primary);
  color: var(--secondary);
  font-weight: 600;
}

.nav-item .icon {
  font-size: 1.3rem;
}

.sidebar-footer {
  position: absolute;
  bottom: 1.5rem;
  left: 1.5rem;
  right: 1.5rem;
}

.logout-btn {
  width: 100%;
  padding: 0.8rem;
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border: 2px solid #e74c3c;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}

.logout-btn:hover {
  background: #e74c3c;
  color: white;
}

/* MAIN CONTENT */
.admin-main {
  display: flex;
  flex-direction: column;
  background: var(--bg-light);
}

.topbar {
  background: white;
  padding: 1.5rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  border-bottom: 1px solid var(--border);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-dark);
}

.topbar h1 {
  flex: 1;
  color: var(--text-dark);
  font-size: 1.5rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  font-weight: 600;
  color: var(--text-dark);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.admin-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.content-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.content-section.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* DASHBOARD STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
}

.stat-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  font-size: 2.5rem;
}

.stat-label {
  color: #999;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stat-value {
  font-size: 2rem;
  font-weight: bold;
  color: var(--primary);
}

/* RECENT ACTIVITY */
.recent-activity {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.recent-activity h3 {
  margin-bottom: 1.5rem;
  color: var(--text-dark);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  border-radius: 8px;
  background: var(--bg-light);
  transition: all 0.3s;
}

.activity-item:hover {
  background: rgba(212, 165, 116, 0.1);
}

.activity-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.activity-content p {
  margin: 0;
  color: var(--text-dark);
}

.activity-content small {
  color: #999;
}

/* CONTENT EDITOR */
.content-editor {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.editor-group {
  margin-bottom: 1.5rem;
}

.editor-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 0.8rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: all 0.3s;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(212, 165, 116, 0.1);
}

/* BUTTONS */
.save-btn {
  padding: 0.9rem 2rem;
  background: linear-gradient(135deg, var(--success) 0%, #229954 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s;
  font-size: 1rem;
}

.save-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(39, 174, 96, 0.3);
}

.add-btn {
  padding: 0.8rem 1.5rem;
  background: var(--info);
  color: white;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 1.5rem;
  transition: all 0.3s;
}

.add-btn:hover {
  background: #2980b9;
  transform: translateY(-2px);
}

.edit-btn,
.delete-btn {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s;
}

.edit-btn {
  background: var(--info);
  color: white;
}

.edit-btn:hover {
  background: #2980b9;
}

.delete-btn {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

.delete-btn:hover {
  background: #e74c3c;
  color: white;
}

.move-btn {
  min-width: 2.5rem;
  padding: 0.5rem;
  border: none;
  border-radius: 5px;
  background: #ecf0f1;
  color: #2c3e50;
  cursor: pointer;
  font-weight: 700;
}

.move-btn:hover:not(:disabled) {
  background: #d5dbdb;
}

.move-btn:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.menu-card[draggable="true"],
.gallery-admin-item[draggable="true"] {
  cursor: grab;
}

.is-dragging {
  opacity: 0.5;
}

.drag-over {
  outline: 3px dashed var(--info);
  outline-offset: 3px;
}

/* LIEN DE LA CARTE + APERÇU MOBILE */
.link-card {
  background: white;
  padding: 1.5rem 2rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.link-card h3 {
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.link-card > p {
  color: #666;
  margin-bottom: 1rem;
}

.link-card label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.link-card .link-card-check {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 1rem 0 0.25rem;
  font-weight: 500;
  cursor: pointer;
}

.link-card-check input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--primary);
}

.link-card-note {
  display: block;
  color: #777;
}

.link-card > .link-card-pdf-info {
  min-height: 1.4em;
  margin: 0.5rem 0 0;
  font-weight: 600;
  color: #444;
}

.link-card-preview {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--bg-light);
}

.link-card-preview-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #888;
}

.link-card [hidden] {
  display: none;
}

.link-card-button {
  display: inline-block;
  padding: 0.7rem 1.8rem;
  border: 2px solid var(--primary);
  border-radius: 50px;
  background: var(--primary);
  color: var(--secondary);
  font-weight: 700;
}

.link-card-empty {
  color: #888;
  font-style: italic;
}

.link-card > .link-card-status {
  min-height: 1.5em;
  margin: 0.75rem 0 0;
  color: #555;
}

.link-card > .link-card-status.is-error {
  color: var(--danger);
  font-weight: 600;
}

.link-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.link-card-actions button {
  padding: 0.9rem 1.5rem;
  font-size: 1rem;
}

.site-preview {
  max-width: 100vw;
  max-height: 100vh;
  padding: 0.75rem 1rem 1rem;
  border: none;
  border-radius: 16px;
  background: #15151b;
  color: #f0f0f5;
  overflow: hidden;
}

.site-preview::backdrop {
  background: rgba(10, 10, 20, 0.85);
}

.site-preview.is-docked {
  position: fixed;
  inset: 1rem 1rem auto auto;
  margin: 0;
  z-index: 3000;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

body.site-preview-docked .admin-main {
  padding-right: var(--phone-dock, 0);
}

.site-preview-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.75rem;
  margin-bottom: 0.75rem;
}

.site-preview-bar strong {
  flex: 1;
}

#sitePreviewState {
  order: 3;
  flex-basis: 100%;
  font-size: 0.8rem;
  color: #c8c8d8;
}

.site-preview-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-weight: 700;
  cursor: pointer;
}

.phone-scaler {
  --phone-scale: 1;
  margin: 0 auto;
}

.phone {
  width: 391px;
  height: 828px;
  padding: 8px;
  border-radius: 48px;
  background: linear-gradient(160deg, #2c2c2e, #141416);
  box-shadow: 0 0 0 2px #4a4a4e, 0 12px 40px rgba(0, 0, 0, 0.6);
  transform: scale(var(--phone-scale));
  transform-origin: top left;
}

.phone iframe {
  display: block;
  width: 375px;
  height: 812px;
  border: none;
  border-radius: 40px;
  background: white;
}

/* MENU LIST */
.menu-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.menu-card {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: all 0.3s;
}

.menu-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.menu-card-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.menu-card-content {
  padding: 1.5rem;
}

.menu-card-content h3 {
  color: var(--text-dark);
  margin-bottom: 0.5rem;
}

.menu-card-content p {
  color: #999;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.menu-card-price {
  color: var(--primary);
  font-size: 1.5rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

.menu-card-actions {
  display: flex;
  gap: 0.5rem;
}

.menu-card-actions button {
  flex: 1;
}

/* GALLERY ADMIN */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1.5rem;
}

.gallery-admin-item {
  position: relative;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: 250px;
}

.gallery-admin-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-admin-actions {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 0.5rem;
  padding: 0.5rem;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.gallery-admin-item:hover .gallery-admin-actions,
.gallery-admin-item:focus-within .gallery-admin-actions {
  opacity: 1;
}

@media (hover: none) {
  .gallery-admin-actions {
    opacity: 1;
    top: auto;
    bottom: 0;
    height: auto;
    padding: 0.5rem;
  }
}

/* SETTINGS */
.message-card {
  background: white;
  color: #252525;
  padding: 1.25rem;
  border: 1px solid #c9c0b5;
  border-left: 4px solid #a56d37;
  border-radius: 10px;
  margin-bottom: 1rem;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.12);
  overflow-wrap: anywhere;
}

.message-body {
  white-space: pre-wrap;
  margin: 0.75rem 0;
}

.message-delete:focus-visible {
  outline: 3px solid #1a1a1a;
  outline-offset: 3px;
}

.settings-group {
  background: white;
  padding: 2rem;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.settings-group h3 {
  margin-bottom: 1.5rem;
  color: var(--text-dark);
  border-bottom: 2px solid var(--border);
  padding-bottom: 1rem;
}

.setting-item {
  margin-bottom: 1.5rem;
}

.setting-item label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

/* MODAL */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 15px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: slideInUp 0.3s ease;
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.modal-header h2 {
  color: var(--text-dark);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #999;
}

.modal-close:hover {
  color: var(--danger);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.modal-form button {
  align-self: flex-start;
}

/* ==============================================
   RESPONSIVE DESIGN
   ============================================== */

@media (max-width: 768px) {
  .admin-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: -250px;
    top: 0;
    height: 100vh;
    z-index: 999;
    width: 250px;
    transition: left 0.3s ease;
  }

  .sidebar.active {
    left: 0;
  }

  .sidebar-close {
    display: block;
  }

  .menu-toggle {
    display: block;
  }

  .login-container {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .login-info {
    display: none;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .menu-list {
    grid-template-columns: 1fr;
  }

  .gallery-admin-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .contact-content {
    grid-template-columns: 1fr;
  }

  .topbar {
    padding: 1rem;
  }

  .topbar h1 {
    font-size: 1.2rem;
  }

  .admin-content {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .login-box {
    padding: 1.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-card {
    flex-direction: column;
    text-align: center;
  }

  .gallery-admin-grid {
    grid-template-columns: 1fr;
  }

  .modal-content {
    width: 95%;
    padding: 1.5rem;
  }
}
