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

:root {
  --blue: #2563eb;
  --blue-light: #3b82f6;
  --blue-dark: #1d4ed8;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --green: #059669;
  --green-light: #d1fae5;
  --red: #dc2626;
  --red-light: #fee2e2;
  --yellow: #d97706;
  --yellow-light: #fef3c7;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #fff;
  color: var(--gray-800);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: var(--gray-900);
  color: #fff;
  padding: 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 20px 24px;
  border-bottom: 1px solid var(--gray-700);
  margin-bottom: 16px;
}

.sidebar-brand h2 {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.sidebar-brand small {
  font-size: 12px;
  color: var(--gray-400);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--gray-800);
  color: #fff;
}

.sidebar-user {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--gray-700);
  font-size: 13px;
  color: var(--gray-400);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-user a {
  color: var(--gray-400);
  text-decoration: none;
  font-size: 12px;
}

.sidebar-user a:hover { color: var(--red); }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

/* ── Login page ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gray-50);
}

.login-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}

.login-card h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-card p {
  color: var(--gray-500);
  font-size: 14px;
  margin-bottom: 24px;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
  background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-100);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

.form-group .help {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
}

.form-error {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
}

.btn-primary:hover { background: var(--blue-dark); }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn-secondary:hover { background: var(--gray-50); }

.btn-danger {
  background: var(--red);
  color: #fff;
}

.btn-danger:hover { opacity: 0.9; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-block { width: 100%; justify-content: center; }

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

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
}

.breadcrumb {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--blue);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

/* ── Cards ── */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

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

.card-header h3 {
  font-size: 16px;
  font-weight: 600;
}

/* ── Client grid ── */
.clients-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.client-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.client-card:hover {
  border-color: var(--blue-light);
  box-shadow: var(--shadow-md);
}

.client-logo {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  flex-shrink: 0;
}

.client-info h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.client-info p {
  font-size: 13px;
  color: var(--gray-500);
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.badge-active { background: var(--green-light); color: var(--green); }
.badge-paused { background: var(--yellow-light); color: var(--yellow); }
.badge-archived { background: var(--gray-100); color: var(--gray-500); }
.badge-draft { background: var(--blue-50); color: var(--blue); }
.badge-pending { background: var(--yellow-light); color: var(--yellow); }
.badge-submitted { background: var(--green-light); color: var(--green); }
.badge-confirmed { background: var(--green-light); color: var(--green); }
.badge-published { background: var(--green-light); color: var(--green); }
.badge-failed { background: var(--red-light); color: var(--red); }
.badge-ready { background: var(--blue-100); color: var(--blue-dark); }

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 24px;
  gap: 0;
}

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}

.tab:hover { color: var(--gray-700); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Table ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-weight: 500;
  color: var(--gray-500);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--gray-200);
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
}

tr:hover td { background: var(--gray-50); }

/* ── Post grid ── */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.post-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s;
}

.post-card:hover { border-color: var(--blue-light); }

.post-card-image {
  width: 100%;
  height: 180px;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-400);
  font-size: 13px;
}

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

.post-card-body {
  padding: 16px;
}

.post-card-body h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
}

.post-card-body p {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.post-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ── Post editor ── */
.post-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.post-preview {
  background: var(--gray-100);
  border-radius: var(--radius);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.post-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ── Month selector ── */
.month-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.month-btn {
  padding: 8px 16px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  background: #fff;
  color: var(--gray-700);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
}

.month-btn:hover { border-color: var(--blue); color: var(--blue); }
.month-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }

/* ── Week group ── */
.week-group {
  margin-bottom: 24px;
}

.week-group h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--gray-200);
}

/* ── Actions bar ── */
.actions-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

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

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

.modal {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Alert / Confirm popup ── */
#alert-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); display: none; align-items: center;
  justify-content: center; z-index: 2000;
}
#alert-overlay.active { display: flex; }
#alert-box {
  background: #fff; border-radius: var(--radius); padding: 24px;
  width: 100%; max-width: 480px; max-height: 80vh; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
}
#alert-msg {
  font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-word;
  overflow-y: auto; max-height: 60vh; color: var(--gray-700);
}
#alert-actions {
  display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-shrink: 0;
}
#alert-copy-btn {
  display: flex; align-items: center; gap: 4px; padding: 8px 14px;
  border: 1px solid var(--gray-200); border-radius: 6px; background: var(--gray-50);
  color: var(--gray-500); cursor: pointer; font-size: 13px; transition: all .15s;
}
#alert-copy-btn:hover { background: var(--gray-100); color: var(--gray-700); }
#alert-copy-btn.copied { background: #dcfce7; border-color: #86efac; color: #16a34a; }
#alert-ok-btn {
  padding: 8px 20px; border: none; border-radius: 6px; background: var(--blue);
  color: #fff; cursor: pointer; font-size: 13px; font-weight: 600;
}
#alert-ok-btn:hover { opacity: 0.9; }
#alert-cancel-btn {
  padding: 8px 16px; border: 1px solid var(--gray-200); border-radius: 6px;
  background: #fff; color: var(--gray-600); cursor: pointer; font-size: 13px;
}
#alert-cancel-btn:hover { background: var(--gray-50); }

/* ── Toast notifications ── */
#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 3000;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 8px; font-size: 13px; color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); pointer-events: auto;
  animation: toast-in 0.3s ease; max-width: 360px;
}
.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: var(--blue); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateX(20px); } }

/* ── Loading ── */
.loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Questionnaire public ── */
.questionnaire-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
}

.questionnaire-page h1 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.questionnaire-page .subtitle {
  color: var(--gray-500);
  margin-bottom: 32px;
}

.progress-bar {
  height: 4px;
  background: var(--gray-200);
  border-radius: 2px;
  margin-bottom: 32px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s ease;
}

.q-section {
  display: none;
}

.q-section.active {
  display: block;
}

.q-section h2 {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 4px;
}

.q-section .section-help {
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 20px;
}

.q-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.checkbox-group label,
.radio-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  transition: border-color 0.15s;
}

.checkbox-group label:hover,
.radio-group label:hover {
  border-color: var(--blue-light);
}

.checkbox-group input,
.radio-group input {
  accent-color: var(--blue);
}

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-500);
}

.empty-state h3 {
  font-size: 16px;
  color: var(--gray-700);
  margin-bottom: 8px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { padding: 20px; }
  .post-editor-layout { grid-template-columns: 1fr; }
  .clients-grid { grid-template-columns: 1fr; }
}
