/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #FAFAF9;
  --bg-card: #FFFFFF;
  --border: #E5E5E5;
  --text: #1A1A1A;
  --text-secondary: #737373;
  --accent: #8B7355;
  --accent-light: #C4B5A0;
  --success: #22C55E;
  --warning: #F59E0B;
  --info: #3B82F6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
}

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* Header */
.header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 24px;
  font-weight: 600;
  color: var(--accent);
}

.nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.nav-btn:hover {
  background: var(--bg);
}

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

/* Main */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

/* Posts view */
.posts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.posts-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.posts-header h2 {
  font-size: 24px;
  font-weight: 600;
}

.posts-count {
  font-size: 14px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 10px;
  border-radius: 12px;
}

/* New post button */
.new-post-wrapper {
  position: relative;
}

.btn-new-post {
  font-size: 13px;
  padding: 8px 14px;
}

.new-post-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 200px;
  overflow: hidden;
}

.new-post-dropdown.hidden {
  display: none;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: transparent;
  text-align: left;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s;
}

.dropdown-item:hover {
  background: var(--bg);
}

.dropdown-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.posts-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
}

.search-input {
  width: 200px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-card);
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(139, 115, 85, 0.1);
}

.search-input::placeholder {
  color: var(--text-secondary);
}

.type-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-card);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

.type-select:focus {
  outline: none;
  border-color: var(--accent);
}

.filters {
  display: flex;
  gap: 8px;
}

.filter-btn {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover {
  border-color: var(--accent);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Posts grid */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.post-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}

.post-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.post-thumbnail {
  aspect-ratio: 1;
  background: #F6EEE3;
  position: relative;
  overflow: hidden;
}

.post-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Thumbnail preview avec blobs */
.thumb-preview {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.thumb-blob {
  position: absolute;
  width: 100px;
  height: 100px;
  opacity: 0.4;
}

.thumb-blob svg {
  width: 100%;
  height: 100%;
}

.thumb-blob.top-left { top: -30px; left: -30px; }
.thumb-blob.top-right { top: -30px; right: -30px; }
.thumb-blob.bottom-left { bottom: -30px; left: -30px; }
.thumb-blob.bottom-right { bottom: -30px; right: -30px; }

/* Forme SVG centrale pour punchline */
.thumb-shape {
  position: absolute;
  width: 140%;
  height: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 0;
  opacity: 0.85;
}

.thumb-title {
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: #7D845A;
  text-align: center;
  line-height: 1.35;
  position: relative;
  z-index: 2;
  max-width: 90%;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.post-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  background: rgba(0,0,0,0.7);
  color: white;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.post-status {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: white;
}

.post-status.draft { background: var(--text-secondary); }
.post-status.validated { background: var(--warning); }
.post-status.ready { background: var(--info); }
.post-status.published { background: var(--success); }

.post-info {
  padding: 16px;
}

.post-title {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.post-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  gap: 12px;
}

/* Calendar view */
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.cal-nav-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
}

.cal-nav-btn:hover {
  background: var(--bg);
}

#current-month {
  font-size: 18px;
  font-weight: 500;
  min-width: 160px;
  text-align: center;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  background: var(--bg-card);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.calendar-day-header {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px;
}

.calendar-day {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.calendar-day:hover {
  border-color: var(--accent);
}

.calendar-day.other-month {
  opacity: 0.3;
}

.calendar-day.today {
  border-color: var(--accent);
  border-width: 2px;
}

.calendar-day.has-post {
  background: var(--bg);
}

.calendar-day .day-number {
  font-weight: 500;
}

.calendar-day .day-posts {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.calendar-day .day-post {
  font-size: 10px;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.day-post.published { background: #DCFCE7; color: #166534; }
.day-post.scheduled { background: #FEF3C7; color: #92400E; }
.day-post.ready { background: #DBEAFE; color: #1E40AF; }

.calendar-legend {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot.published { background: var(--success); }
.dot.scheduled { background: var(--warning); }
.dot.ready { background: var(--info); }

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.close-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 8px;
}

.close-btn:hover {
  background: var(--bg);
}

/* Editor */
.editor-container {
  display: grid;
  grid-template-columns: 1fr 650px;
  flex: 1;
  overflow: hidden;
}

.slides-editor {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.slide-editor {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
}

.slide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.slide-header h3 {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
}

.slide-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.field-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s;
}

.field-input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea.field-input {
  min-height: 80px;
}

/* Preview panel */
.preview-panel {
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 500;
}

.preview-nav {
  display: flex;
  align-items: center;
  gap: 12px;
}

#slide-counter {
  font-size: 16px;
  font-weight: 500;
  min-width: 40px;
  text-align: center;
}

.preview-nav-btn {
  width: 44px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
}

.preview-nav-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
}

.preview-nav-btn:active {
  background: var(--accent-light);
}

.preview-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.slide-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.preview-frame {
  flex: 1;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview-frame iframe {
  width: 504px;
  height: 630px;
  border: none;
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  background: #F9F0E2;
}

/* Modal footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.save-status {
  font-size: 13px;
  color: var(--success);
}

.save-status.saving {
  color: var(--warning);
}

.footer-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.btn-secondary:hover:not(:disabled) {
  background: var(--border);
}

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

.btn-primary:hover:not(:disabled) {
  background: #7A654A;
}

.btn-icon {
  font-size: 16px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 12px;
  }

  .posts-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .posts-header-right {
    width: 100%;
  }

  .search-input {
    width: 100%;
  }

  .type-select {
    flex: 1;
  }

  .filters {
    flex-wrap: wrap;
  }

  .editor-container {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    display: none;
  }

  .modal-content {
    max-height: 100vh;
    border-radius: 0;
  }

  .footer-actions {
    flex-wrap: wrap;
  }
}
