/* =====================================================
   FSN ADMIN – Admin Panel Styles
   ===================================================== */

/* ---------- LOGIN SCREEN ---------- */
.admin-login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background-color: var(--bg);
  padding: var(--sp-5);
}

.login-card {
  background-color: var(--surface);
  padding: var(--sp-10) var(--sp-8);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  max-width: 440px;
  width: 100%;
  text-align: center;
  border: 1px solid var(--border);
}

.login-logo {
  width: 76px;
  height: auto;
  margin-bottom: var(--sp-6);
}

.login-card h2 {
  margin: 0 0 var(--sp-6) 0;
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  color: var(--text-primary);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.login-card input {
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-strong);
  border-radius: var(--r-md);
  background-color: var(--bg);
  color: var(--text-primary);
  font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.login-card input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.login-card button {
  width: 100%;
  margin-top: var(--sp-2);
}

.login-register-link {
  margin-top: var(--sp-6);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.login-register-link a {
  color: var(--accent);
  font-weight: 600;
}

/* ---------- DASHBOARD ---------- */
.admin-dashboard {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg);
}

.admin-dashboard.hidden {
  display: none;
}

/* ---------- ADMIN HEADER ---------- */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--green-900);
  padding: var(--sp-6) var(--sp-8);
  box-shadow: var(--shadow-md);
  margin-bottom: 0;
}

.admin-header h1 {
  margin: 0 0 var(--sp-1) 0;
  font-size: var(--text-2xl);
  color: var(--white);
  font-family: var(--font-display);
}

.admin-welcome {
  font-size: var(--text-sm);
  color: rgba(255,255,255,.75);
  margin: 0;
}

.admin-welcome strong {
  color: var(--white);
}

.admin-welcome span {
  color: var(--yellow-500);
  font-weight: 600;
}

.admin-header button {
  white-space: nowrap;
}

@media (max-width: 768px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4) var(--sp-5);
  }
  .admin-header h1 {
    font-size: var(--text-xl);
  }
}

/* ---------- ADMIN NOTICE ---------- */
.admin-notice {
  display: flex;
  gap: var(--sp-4);
  background-color: var(--accent-light);
  border: 1px solid var(--accent);
  padding: var(--sp-5);
  margin: var(--sp-5) var(--sp-5) var(--sp-5);
  border-radius: var(--r-lg);
  align-items: flex-start;
}

.admin-notice svg {
  flex-shrink: 0;
  color: var(--accent);
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.admin-notice p {
  margin: 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  line-height: 1.5;
}

/* ---------- ADMIN TABS ---------- */
.admin-tabs {
  display: flex;
  gap: 0;
  padding: 0 var(--sp-5);
  border-bottom: 2px solid var(--border);
  margin-bottom: var(--sp-6);
  overflow-x: auto;
  background: var(--surface);
}

.tab {
  padding: var(--sp-4) var(--sp-6);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  letter-spacing: 0.02em;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.tab.active {
  border-bottom-color: var(--accent);
  color: var(--accent);
}

@media (max-width: 768px) {
  .admin-tabs {
    padding: 0 var(--sp-3);
  }
  .tab {
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--text-xs);
  }
}

/* ---------- ADMIN MAIN ---------- */
.admin-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
  padding: 0 var(--sp-5) var(--sp-10);
}

@media (max-width: 768px) {
  .admin-main {
    padding: 0 var(--sp-4) var(--sp-8);
  }
}

/* ---------- TAB CONTENT ---------- */
.tab-content {
  animation: fadeIn 0.3s ease;
}

.tab-content.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ---------- TOOLBAR ---------- */
.admin-toolbar {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}

/* ---------- TABLES ---------- */
table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-6);
  border: 1px solid var(--border);
}

thead {
  background-color: var(--green-900);
  color: var(--white);
}

th {
  padding: var(--sp-4);
  text-align: left;
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  padding: var(--sp-4);
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

tbody tr:hover {
  background-color: var(--surface-alt);
}

/* ---------- STATUS BADGES ---------- */
.status-badge {
  display: inline-block;
  padding: 0.2em 0.75em;
  border-radius: var(--r-full);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.4;
}

.status-published        { background-color: var(--green-100); color: var(--green-700); border: 1px solid var(--green-300); }
.status-draft            { background-color: var(--gray-100);  color: var(--gray-600); border: 1px solid var(--gray-200); }
.status-scheduled        { background-color: var(--highlight-bg); color: #8a6e00; border: 1px solid var(--yellow-400); }
.status-pending_approval { background-color: var(--highlight-bg); color: #8a6e00; border: 1px solid var(--yellow-400); }
.status-active           { background-color: var(--green-100); color: var(--green-700); border: 1px solid var(--green-300); }
.status-suspended        { background-color: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

html.dark .status-published        { background-color: var(--accent-light); color: var(--green-300); }
html.dark .status-draft            { background-color: var(--border); color: var(--text-muted); }
html.dark .status-scheduled        { background-color: var(--highlight-bg); color: var(--yellow-400); }
html.dark .status-pending_approval { background-color: var(--highlight-bg); color: var(--yellow-400); }
html.dark .status-active           { background-color: var(--accent-light); color: var(--green-300); }
html.dark .status-suspended        { background-color: var(--danger-bg); color: var(--danger); }

/* ---------- POST EDITOR / WIZARD ---------- */
.post-editor {
  background-color: var(--surface);
  padding: var(--sp-6) var(--sp-8);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
  margin-bottom: var(--sp-6);
  border: 1px solid var(--border);
}

.post-editor.hidden {
  display: none;
}

.post-editor h3 {
  margin-top: 0;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: var(--text-xl);
}

.wizard-step h4 {
  color: var(--accent);
  margin: 0 0 var(--sp-4) 0;
  font-size: var(--text-lg);
}

.wizard-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

.wizard-actions button {
  flex: 1;
}

.cancel-btn {
  margin-top: var(--sp-4);
  width: 100%;
  background-color: transparent;
  border-color: var(--border-strong);
  color: var(--text-muted);
}

.cancel-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- QUILL EDITOR ---------- */
#quill-editor {
  background-color: var(--surface) !important;
  border: 2px solid var(--border-strong) !important;
  border-radius: var(--r-md) !important;
  margin-bottom: var(--sp-4) !important;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#quill-editor:focus-within {
  border-color: var(--accent) !important;
  box-shadow: var(--shadow-glow) !important;
}

.ql-toolbar {
  border-top-left-radius: var(--r-md) !important;
  border-top-right-radius: var(--r-md) !important;
  background-color: var(--bg-secondary) !important;
  border-color: var(--border-strong) !important;
}

.ql-container {
  border-bottom-left-radius: var(--r-md) !important;
  border-bottom-right-radius: var(--r-md) !important;
  border-color: var(--border-strong) !important;
  background-color: var(--surface) !important;
}

.ql-editor {
  color: var(--text-primary) !important;
  min-height: 250px;
  font-size: var(--text-base);
  line-height: 1.7;
}

/* ---------- IMAGE UPLOAD ---------- */
.image-upload-group {
  margin-bottom: var(--sp-5);
}

.upload-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-3);
  align-items: center;
}

.hidden-file-input {
  display: none !important;
}

.camera-btn {
  background-color: var(--accent) !important;
  color: var(--white) !important;
  width: 40px;
  height: 40px;
  border-radius: var(--r-md) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.camera-btn:hover {
  background-color: var(--accent-dark) !important;
}

.url-input {
  flex: 1;
  min-width: 180px;
}

.image-preview {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background-color: var(--bg);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-preview {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,.65);
  color: var(--white);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  font-size: 14px;
}

/* ---------- POST PREVIEW ---------- */
.post-preview {
  background-color: var(--bg-secondary);
  padding: var(--sp-6);
  border-radius: var(--r-lg);
  max-height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.post-preview h2 {
  color: var(--accent);
  margin-top: 0;
  font-family: var(--font-display);
}

.post-preview img {
  max-width: 100%;
  border-radius: var(--r-lg);
  margin: var(--sp-3) 0;
}

.post-preview p {
  margin: var(--sp-2) 0;
}

/* ---------- SUBSCRIBERS ---------- */
.subscribers-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--sp-6);
}

.subscribers-header h2 {
  margin: 0;
  font-family: var(--font-display);
  color: var(--text-primary);
}

.subscribers-header p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* ---------- INTERACTIONS ---------- */
#post-selector {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-6);
}

#post-selector label {
  font-weight: 600;
  color: var(--text-secondary);
}

.interactions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}

@media (max-width: 768px) {
  .interactions-grid {
    grid-template-columns: 1fr;
  }
}

#likes-list,
#comments-list {
  background-color: var(--surface);
  padding: var(--sp-6);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

#likes-list h3,
#comments-list h3 {
  margin-top: 0;
  color: var(--accent);
  font-family: var(--font-display);
}

#likes-ul {
  list-style: none;
  padding: 0;
}

#likes-ul li {
  padding: var(--sp-3) var(--sp-4);
  background-color: var(--bg-secondary);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-2);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

#comments-thread {
  max-height: 400px;
  overflow-y: auto;
}

#comments-thread > div {
  padding: var(--sp-4);
  background-color: var(--bg-secondary);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-3);
  font-size: var(--text-sm);
  border-left: 3px solid var(--accent);
}

#comments-thread > div p {
  margin: var(--sp-1) 0;
  color: var(--text-secondary);
}

#comments-thread strong {
  color: var(--accent);
  font-weight: 600;
}

#reply-editor {
  background-color: var(--surface);
  padding: var(--sp-6);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

#reply-editor.hidden {
  display: none;
}

#reply-editor textarea {
  margin-bottom: var(--sp-4);
}

/* ---------- SCROLLABLE TABLES ON MOBILE ---------- */
@media (max-width: 768px) {
  #posts-table-container {
    overflow-x: auto;
  }
  table {
    font-size: var(--text-xs);
  }
  th, td {
    padding: var(--sp-3);
  }
}

/* ---------- DARK MODE OVERRIDES ---------- */
html.dark .admin-notice {
  background-color: var(--accent-light);
  border-color: var(--accent);
}

html.dark .ql-toolbar button svg,
html.dark .ql-toolbar button .ql-stroke {
  stroke: var(--text-secondary) !important;
}

html.dark .ql-toolbar button:hover,
html.dark .ql-toolbar button.ql-active {
  color: var(--accent) !important;
}

html.dark .ql-toolbar button:hover svg,
html.dark .ql-toolbar button.ql-active svg {
  stroke: var(--accent) !important;
}

/* ---------- MOBILE RESPONSIVE ---------- */
@media (max-width: 600px) {
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-4);
  }

  .admin-toolbar {
    flex-direction: column;
    gap: var(--sp-3);
  }

  .admin-toolbar button {
    width: 100%;
  }

  .admin-main {
    padding: 0 var(--sp-4) var(--sp-8);
  }

  .admin-tabs {
    gap: var(--sp-1);
    padding: 0 var(--sp-3);
  }

  .tab {
    padding: var(--sp-3) var(--sp-3);
    font-size: var(--text-xs);
  }

  .post-editor {
    padding: var(--sp-4);
  }

  .wizard-actions {
    flex-direction: column;
  }

  .wizard-actions button {
    width: 100%;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions button {
    width: 100%;
  }

  .interactions-grid {
    grid-template-columns: 1fr;
  }

  #posts-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    font-size: var(--text-xs);
    min-width: 600px;   /* allows horizontal scroll */
  }

  th, td {
    padding: var(--sp-2) var(--sp-3);
  }

  .login-card {
    padding: var(--sp-6) var(--sp-5);
  }

  .admin-notice {
    flex-direction: column;
    align-items: flex-start;
    margin: var(--sp-4);
    padding: var(--sp-4);
  }
}

/* ---------- FACEBOOK‑STYLE POST FEED ---------- */
.posts-feed {
  display: flex;
  flex-direction: column;
  gap: var(--sp-6);
}

.admin-post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.post-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.post-author-feed {
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.post-date {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.post-menu-wrapper {
  position: relative;
}

.three-dot-btn {
  border-radius: var(--r-full);
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}
.three-dot-btn:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.post-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 140px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  z-index: 10;
  overflow: hidden;
}

.dropdown-item {
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  border: none;
  background: none;
  text-align: left;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  cursor: pointer;
  color: var(--text-primary);
  transition: background var(--transition);
}
.dropdown-item:hover {
  background: var(--accent-light);
  color: var(--accent);
}

.post-card-body {
  padding: var(--sp-5);
}

.post-feed-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--sp-2);
  color: var(--text-primary);
}

.post-feed-content {
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: var(--sp-4);
}

.post-feed-images {
  display: grid;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}

.post-feed-images img:only-child {
  width: 100%;
  border-radius: var(--r-lg);
}

.post-feed-images:has(img:nth-child(2)) {
  grid-template-columns: 1fr 1fr;
}

.post-feed-image {
  width: 100%;
  border-radius: var(--r-lg);
  object-fit: cover;
  max-height: 320px;
}

.post-scheduled {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--sp-3);
}