@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --admin-bg: #f9fafb; /* Fond gris clair moderne */
  --panel-bg: #ffffff;
  --text-dark: #111827; /* Encre anthracite */
  --text-light: #4b5563; /* Muted gray */
  --accent: #0066cc; /* Bleu presse digitale */
  --accent-hover: #004ea1;
  --success: #10b981;
  --danger: #ef4444; /* Rouge modernisé */
  --warning: #f59e0b; /* Orange warning */
  --border: #e5e7eb; /* Bordure fine grise */
  
  --font-sans: 'Inter', sans-serif;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
  
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--admin-bg);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
}

a {
  color: inherit;
  text-decoration: none;
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  background-color: #0c0c0e; /* Noir carbone de Smile.eu */
  color: #f8fafc;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10;
}

.sidebar-logo {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-logo span {
  color: var(--accent); /* Orange Smile */
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.menu-item {
  padding: 0.8rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: #94a3b8;
  transition: all 0.2s;
}

.menu-item:hover, .menu-item.active {
  background-color: #111827; /* Noir ardoise */
  color: #fff;
}

.menu-item.active {
  border-left: 3px solid var(--accent); /* Orange Smile */
  border-radius: 0 6px 6px 0;
  padding-left: calc(1rem - 3px);
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid #111827;
  padding-top: 1.5rem;
}

.logout-btn {
  width: 100%;
  padding: 0.8rem;
  border-radius: 6px;
  background-color: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.logout-btn:hover {
  background-color: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* --- MAIN CONTENT PANELS --- */
.content-wrapper {
  margin-left: var(--sidebar-width);
  flex-grow: 1;
  padding: 2.5rem 3rem;
  min-height: 100vh;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.admin-header h1 {
  font-size: 1.8rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  gap: 1rem;
}

.btn {
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary {
  background-color: var(--accent);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-hover);
}

.btn-secondary {
  background-color: white;
  color: var(--text-dark);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background-color: var(--admin-bg);
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.panel {
  background-color: var(--panel-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 2rem;
  margin-bottom: 2rem;
  display: none; /* Cache par défaut, contrôlé par JS */
}

.panel.active {
  display: block;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.8rem;
}

/* --- FORMS --- */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  font-weight: 500;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--text-dark);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text-dark);
  transition: border-color 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.form-control {
  resize: vertical;
  min-height: 120px;
}

.editor-textarea {
  font-family: Georgia, serif;
  font-size: 1.05rem;
  line-height: 1.6;
  min-height: 350px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.help-text {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.3rem;
}

/* Toggle Switch */
.switch-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: .4s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--success);
}

input:checked + .slider:before {
  transform: translateX(24px);
}

/* --- POSTS TABLE/LIST --- */
.posts-list {
  width: 100%;
  border-collapse: collapse;
}

.posts-list th, .posts-list td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.posts-list th {
  font-weight: 600;
  color: var(--text-light);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.posts-list tr:hover {
  background-color: var(--admin-bg);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-secondary { background-color: #f1f5f9; color: #475569; }
.badge-info { background-color: #dbeafe; color: #1e40af; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }
.badge-warning { background-color: #fef3c7; color: #92400e; }

.action-links {
  display: flex;
  gap: 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.action-links a, .action-links button {
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 600;
}

.link-edit { color: var(--accent); }
.link-delete { color: var(--danger); }
.link-share { color: var(--success); }

/* --- DIALOG MODALS --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background-color: white;
  border-radius: 8px;
  width: 95%;
  max-width: 850px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
}

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

.modal-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* --- INSTAGRAM CARD GENERATOR --- */
.card-generator-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.generator-preview-pane {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #cbd5e1;
  padding: 2rem;
  border-radius: 6px;
  position: relative;
}

#canvas-preview {
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.generator-settings-pane {
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

/* --- TOAST NOTIFICATIONS --- */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.toast {
  background-color: #1e293b;
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  min-width: 300px;
}

.toast-success { border-left: 4px solid var(--success); }
.toast-error { border-left: 4px solid var(--danger); }
.toast-info { border-left: 4px solid var(--accent); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- LOGIN FORM PAGE --- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  background-color: var(--admin-bg);
}

.login-card {
  background-color: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  border-radius: 8px;
  padding: 3rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  font-family: 'Playfair Display', serif;
  font-size: 2.2rem;
  margin-bottom: 2rem;
  font-weight: 700;
}

.login-logo span {
  color: var(--accent);
}
