/* ==========================================================================
   NewsArea 247 Admin — design system
   Instagram-web inspired: generous whitespace, hairline borders instead of
   shadows, circular avatars, a quiet neutral palette with one accent color,
   pill-shaped filter chips, and a fixed left icon+label sidebar.
   ========================================================================== */

:root {
  --ig-bg: #fafafa;
  --ig-surface: #ffffff;
  --ig-border: #dbdbdb;
  --ig-border-soft: #efefef;
  --ig-text: #262626;
  --ig-text-secondary: #8e8e8e;
  --ig-accent: #0095f6;
  --ig-accent-hover: #1877f2;
  --ig-accent-soft: #e7f4ff;
  --ig-danger: #ed4956;
  --ig-danger-soft: #fde8ea;
  --ig-success: #2ecc71;
  --ig-success-soft: #e8f9ef;
  --ig-warning: #f5a623;
  --ig-warning-soft: #fef4e3;
  --ig-radius-sm: 6px;
  --ig-radius: 10px;
  --ig-radius-lg: 16px;
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 72px;
  --font: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ig-bg);
  color: var(--ig-text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; display: block; }

h1, h2, h3, h4 { margin: 0 0 4px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
.text-muted { color: var(--ig-text-secondary); }
.text-sm { font-size: 12.5px; }

/* ---------------------------------------------------------------------
   Layout shell: fixed sidebar + scrollable main
   --------------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--ig-surface);
  border-right: 1px solid var(--ig-border-soft);
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px 28px;
}
.sidebar-brand .brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--ig-accent), #7c3aed);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.sidebar-brand .brand-name { font-weight: 700; font-size: 16px; white-space: nowrap; }

.nav-group { flex: 1; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 12px;
  border-radius: var(--ig-radius);
  color: var(--ig-text);
  font-size: 15px;
  transition: background-color .12s ease;
}
.nav-item i { font-size: 20px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item:hover { background: var(--ig-border-soft); }
.nav-item.active { font-weight: 700; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--ig-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  border-top: 1px solid var(--ig-border-soft);
  padding-top: 14px;
  margin-top: 10px;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--ig-radius);
  cursor: pointer;
  position: relative;
}
.sidebar-user:hover { background: var(--ig-border-soft); }
.sidebar-user .user-meta { min-width: 0; }
.sidebar-user .user-name { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: 12px; color: var(--ig-text-secondary); }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  padding: 32px 40px 80px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-header .subtitle { color: var(--ig-text-secondary); font-size: 13.5px; margin-top: 2px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Mobile: collapse sidebar into a bottom bar, IG-mobile style */
.topbar-mobile { display: none; }
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 16px 16px 90px; }
  .topbar-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky; top: 0; z-index: 40;
    background: var(--ig-surface);
    border-bottom: 1px solid var(--ig-border-soft);
    padding: 12px 16px;
    margin: -16px -16px 20px;
  }
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--ig-surface);
    border-top: 1px solid var(--ig-border-soft);
    display: flex;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  }
  .bottom-nav a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    font-size: 10.5px; color: var(--ig-text-secondary); padding: 4px 0;
  }
  .bottom-nav a i { font-size: 21px; }
  .bottom-nav a.active { color: var(--ig-text); }
}

/* Phone-width refinements, layered on top of the 900px tablet/mobile
   shift above. Everything from here down only further tightens spacing
   and stacks things that are still side-by-side at 900-640px. */
@media (max-width: 640px) {
  .main { padding: 14px 14px 88px; }

  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header h1 { font-size: 19px; }
  .header-actions { flex-direction: column; }
  .header-actions .btn { width: 100%; }

  .card { padding: 16px; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 10px; }
  .stat-tile { padding: 14px 16px; }
  .stat-tile .stat-value { font-size: 22px; }

  .data-table th, .data-table td { padding: 11px 12px; }

  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal-box, .modal-box.modal-wide {
    max-width: 100%;
    width: 100%;
    max-height: 94vh;
    border-radius: var(--ig-radius-lg) var(--ig-radius-lg) 0 0;
  }
  .modal-head, .modal-foot { padding: 14px 16px; }
  .modal-body { padding: 16px; -webkit-overflow-scrolling: touch; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }

  .form-row { grid-template-columns: 1fr; }
  .auth-box { padding: 28px 22px; }
  .auth-shell { padding: 16px; }

  .btn-icon { width: 40px; height: 40px; }
  .pagination button { min-width: 38px; height: 38px; }

  .toast-stack { left: 12px; right: 12px; top: 12px; max-width: none; }
}

/* ---------------------------------------------------------------------
   Cards, tables, stat tiles
   --------------------------------------------------------------------- */

.card {
  background: var(--ig-surface);
  border: 1px solid var(--ig-border-soft);
  border-radius: var(--ig-radius-lg);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-tile {
  background: var(--ig-surface);
  border: 1px solid var(--ig-border-soft);
  border-radius: var(--ig-radius-lg);
  padding: 18px 20px;
}
.stat-tile .stat-label { color: var(--ig-text-secondary); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat-tile .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -0.02em; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--ig-border-soft); border-radius: var(--ig-radius-lg); background: var(--ig-surface); }
table.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ig-text-secondary);
  font-weight: 600;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ig-border-soft);
  white-space: nowrap;
}
.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--ig-border-soft);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: #fbfbfb; }
.data-table .cell-title { font-weight: 600; }
.data-table .cell-muted { color: var(--ig-text-secondary); }

.row-flex { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-flex .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------------
   Avatars
   --------------------------------------------------------------------- */

.avatar {
  border-radius: 50%;
  object-fit: cover;
  background: var(--ig-border-soft);
  flex-shrink: 0;
}
.avatar-initials {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--ig-accent), #7c3aed);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.avatar-sm, .avatar-initials.avatar-sm { width: 32px; height: 32px; font-size: 12px; }
.avatar-md, .avatar-initials.avatar-md { width: 44px; height: 44px; font-size: 15px; }
.avatar-lg, .avatar-initials.avatar-lg { width: 88px; height: 88px; font-size: 26px; }

/* ---------------------------------------------------------------------
   Media thumbnails (post featured image/video)
   --------------------------------------------------------------------- */

.media-thumb {
  position: relative;
  background: var(--ig-border-soft);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-thumb .media-thumb-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 46%; height: 46%;
  min-width: 16px; min-height: 16px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-thumb .media-thumb-play i { font-size: 65%; margin-left: 8%; }
.media-thumb.media-thumb-lg .media-thumb-play i { margin-left: 6%; }

/* ---------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--ig-radius);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ig-accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--ig-accent-hover); }
.btn-secondary { background: var(--ig-border-soft); color: var(--ig-text); }
.btn-secondary:hover:not(:disabled) { background: var(--ig-border); }
.btn-outline { background: transparent; border-color: var(--ig-border); color: var(--ig-text); }
.btn-outline:hover:not(:disabled) { background: var(--ig-border-soft); }
.btn-danger { background: var(--ig-danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #d13847; }
.btn-danger-ghost { background: var(--ig-danger-soft); color: var(--ig-danger); }
.btn-ghost { background: transparent; color: var(--ig-text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--ig-border-soft); color: var(--ig-text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; }

/* ---------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------- */

.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--ig-text); }
.field-hint { font-size: 12px; color: var(--ig-text-secondary); margin-top: 5px; }
.field-error { font-size: 12px; color: var(--ig-danger); margin-top: 5px; }

input[type=text], input[type=email], input[type=password], input[type=search],
input[type=date], input[type=datetime-local], input[type=number], input[type=tel],
select, textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--ig-border);
  border-radius: var(--ig-radius-sm);
  background: var(--ig-surface);
  color: var(--ig-text);
  outline: none;
  transition: border-color .12s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--ig-accent); }
input.invalid, select.invalid, textarea.invalid { border-color: var(--ig-danger); }
textarea { resize: vertical; min-height: 90px; }

.input-group { position: relative; }
.input-group .input-suffix-btn {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ig-text-secondary); cursor: pointer;
  padding: 6px;
}

.chip-select { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--ig-border);
  background: var(--ig-surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--ig-text);
}
.chip.selected { background: var(--ig-text); border-color: var(--ig-text); color: #fff; }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: auto; }

/* ---------------------------------------------------------------------
   Tabs / filter pills (post status, etc.)
   --------------------------------------------------------------------- */

.tab-bar { display: flex; gap: 6px; border-bottom: 1px solid var(--ig-border-soft); margin-bottom: 20px; flex-wrap: wrap; }
.tab-bar .tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 10px 4px; margin-right: 20px;
  font-size: 14px; font-weight: 600; color: var(--ig-text-secondary);
  border-bottom: 2px solid transparent;
}
.tab-bar .tab-btn.active { color: var(--ig-text); border-bottom-color: var(--ig-text); }

/* ---------------------------------------------------------------------
   Badges
   --------------------------------------------------------------------- */

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.badge-published, .badge-active, .badge-resolved { background: var(--ig-success-soft); color: #1a9c53; }
.badge-draft, .badge-pending { background: var(--ig-warning-soft); color: #b9790a; }
.badge-scheduled { background: var(--ig-accent-soft); color: var(--ig-accent-hover); }
.badge-trash, .badge-suspended, .badge-dismissed { background: var(--ig-danger-soft); color: var(--ig-danger); }
.badge-neutral { background: var(--ig-border-soft); color: var(--ig-text-secondary); }

/* ---------------------------------------------------------------------
   Dropdown menu (row actions "...")
   --------------------------------------------------------------------- */

.menu-trigger { background: none; border: none; cursor: pointer; color: var(--ig-text-secondary); padding: 6px; border-radius: 50%; }
.menu-trigger:hover { background: var(--ig-border-soft); color: var(--ig-text); }
.menu {
  position: absolute;
  min-width: 170px;
  background: var(--ig-surface);
  border: 1px solid var(--ig-border-soft);
  border-radius: var(--ig-radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  padding: 6px;
  z-index: 60;
  display: none;
}
.menu.open { display: block; }
.menu button, .menu a {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: none; border: none; text-align: left; cursor: pointer;
  padding: 9px 10px; border-radius: var(--ig-radius-sm); font-size: 13.5px; color: var(--ig-text);
}
.menu button:hover, .menu a:hover { background: var(--ig-border-soft); }
.menu .menu-danger { color: var(--ig-danger); }
.menu-divider { height: 1px; background: var(--ig-border-soft); margin: 6px 2px; }
.menu-anchor { position: relative; display: inline-block; }

/* ---------------------------------------------------------------------
   Modal
   --------------------------------------------------------------------- */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(38,38,38,.5);
  display: none; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--ig-surface);
  border-radius: var(--ig-radius-lg);
  width: 100%; max-width: 520px;
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal-box.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--ig-border-soft); flex-shrink: 0; }
.modal-head h3 { margin: 0; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--ig-text-secondary); line-height: 1; padding: 4px; }
.modal-body { padding: 20px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--ig-border-soft); flex-shrink: 0; }

/* ---------------------------------------------------------------------
   Toast notifications
   --------------------------------------------------------------------- */

.toast-stack { position: fixed; top: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; max-width: 340px; }
.toast {
  background: var(--ig-text);
  color: #fff;
  padding: 13px 16px;
  border-radius: var(--ig-radius);
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  animation: toast-in .18s ease;
}
.toast i { font-size: 16px; margin-top: 1px; }
.toast.toast-success { background: #1a1a1a; }
.toast.toast-success i { color: var(--ig-success); }
.toast.toast-danger i { color: #ff7a85; }
.toast.toast-warning i { color: var(--ig-warning); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }

/* ---------------------------------------------------------------------
   Spinner
   --------------------------------------------------------------------- */

.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
.spinner-dark { border-color: rgba(38,38,38,.2); border-top-color: var(--ig-text); }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, var(--ig-border-soft) 25%, #f5f5f5 37%, var(--ig-border-soft) 63%); background-size: 400% 100%; animation: skeleton-shine 1.4s ease infinite; border-radius: var(--ig-radius-sm); }
.skeleton-line { height: 14px; width: 100%; }
@keyframes skeleton-shine { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------------------------------------------------------------------
   Empty state
   --------------------------------------------------------------------- */

.empty-state { text-align: center; padding: 60px 20px; color: var(--ig-text-secondary); }
.empty-state i { font-size: 34px; opacity: .5; margin-bottom: 10px; display: block; }

/* ---------------------------------------------------------------------
   Pagination
   --------------------------------------------------------------------- */

.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; }
.pagination button {
  min-width: 34px; height: 34px;
  border: 1px solid var(--ig-border-soft);
  background: var(--ig-surface);
  border-radius: var(--ig-radius-sm);
  cursor: pointer; font-size: 13px; font-weight: 600;
}
.pagination button.active { background: var(--ig-text); color: #fff; border-color: var(--ig-text); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------------------------------------------------------------
   Auth pages (login/register/forgot/reset)
   --------------------------------------------------------------------- */

.auth-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: var(--ig-bg);
}
.auth-box {
  width: 100%; max-width: 380px;
  background: var(--ig-surface);
  border: 1px solid var(--ig-border-soft);
  border-radius: var(--ig-radius-lg);
  padding: 36px 32px;
}
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand .brand-mark { width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 14px; }
.auth-box h1 { text-align: center; font-size: 19px; }
.auth-sub { text-align: center; color: var(--ig-text-secondary); margin-bottom: 22px; font-size: 13.5px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--ig-text-secondary); }
.auth-alt a { color: var(--ig-accent); font-weight: 600; }
.auth-links { display: flex; justify-content: space-between; margin-top: 4px; margin-bottom: 18px; font-size: 12.5px; }
.auth-links a { color: var(--ig-accent); font-weight: 600; }
.auth-error {
  background: var(--ig-danger-soft); color: var(--ig-danger);
  padding: 10px 12px; border-radius: var(--ig-radius-sm);
  font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start;
}
.auth-notice {
  background: var(--ig-accent-soft); color: var(--ig-accent-hover);
  padding: 10px 12px; border-radius: var(--ig-radius-sm);
  font-size: 13px; margin-bottom: 16px; display: flex; gap: 8px; align-items: flex-start;
}

/* Honeypot field: present in the DOM for bots, invisible + unreachable for humans */
.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------------------------------------------------------------------
   Utility
   --------------------------------------------------------------------- */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }