/* =============================================================
   Arab Media & Society — AMS Platform
   Design System · main.css  (v3 — Shadcn UI)
   ============================================================= */

/* ─── CSS Custom Properties (Shadcn tokens + AMS brand) ─────── */

:root {
  /* Geometry */
  --radius: 0.5rem;
  --radius-sm: 0.375rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;

  /* Surfaces */
  --background:        #ffffff;
  --foreground:        #09090b;
  --card:              #ffffff;
  --card-foreground:   #09090b;
  --popover:           #ffffff;
  --popover-foreground:#09090b;

  /* Brand */
  --primary:           #691919;
  --primary-foreground:#fafafa;
  --primary-hover:     #7a1b1a;
  --primary-light:     #f5eded;

  /* Secondary / Muted / Accent */
  --secondary:         #f4f4f5;
  --secondary-foreground: #18181b;
  --muted:             #f4f4f5;
  --muted-foreground:  #71717a;
  --accent:            #f4f4f5;
  --accent-foreground: #18181b;

  /* Semantic */
  --destructive:       #ef4444;
  --destructive-foreground: #fafafa;
  --border:            #e4e4e7;
  --input:             #e4e4e7;
  --ring:              #691919;

  /* Sidebar */
  --sidebar:           #fafafa;
  --sidebar-foreground:#374151;
  --sidebar-border:    #e4e4e7;
  --sidebar-accent:    #f5eded;
  --sidebar-accent-fg: #691919;

  /* Legacy compat */
  --cream:             #F8F7F4;
}

.dark {
  --background:        #09090b;
  --foreground:        #fafafa;
  --card:              #18181b;
  --card-foreground:   #fafafa;
  --popover:           #18181b;
  --popover-foreground:#fafafa;
  --primary:           #8a2222;
  --primary-foreground:#fafafa;
  --primary-hover:     #a02828;
  --primary-light:     #2a1010;
  --secondary:         #27272a;
  --secondary-foreground:#fafafa;
  --muted:             #27272a;
  --muted-foreground:  #a1a1aa;
  --accent:            #27272a;
  --accent-foreground: #fafafa;
  --border:            #27272a;
  --input:             #27272a;
  --ring:              #8a2222;
  --sidebar:           #18181b;
  --sidebar-foreground:#a1a1aa;
  --sidebar-border:    #27272a;
  --sidebar-accent:    #2a1010;
  --sidebar-accent-fg: #e57373;
}

/* ─── Base ──────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

body {
  background-color: var(--background);
  color: var(--foreground);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── RTL / Arabic ──────────────────────────────────────────── */

.rtl { direction: rtl; text-align: right; font-family: 'Noto Naskh Arabic', serif; }
[lang="ar"] body, .lang-ar { direction: rtl; font-family: 'Noto Naskh Arabic', serif; }

/* ─── Focus Ring ────────────────────────────────────────────── */

*:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ─── Smooth Transitions ────────────────────────────────────── */

button, a, input, select, textarea {
  transition-property: color, background-color, border-color, box-shadow, opacity;
  transition-duration: 150ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

/* =============================================================
   Shadcn — Button
   ============================================================= */

.btn,
.btn-primary,
.btn-secondary,
.btn-outline,
.btn-ghost,
.btn-destructive {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  white-space: nowrap;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  height: 2.25rem;          /* h-9 */
  padding: 0 1rem;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  user-select: none;
  font-family: 'Inter', sans-serif;
  line-height: 1;
}
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-outline:focus-visible,
.btn-ghost:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}
.btn:disabled,
.btn-primary:disabled,
.btn-secondary:disabled,
.btn-outline:disabled,
.btn-ghost:disabled {
  pointer-events: none;
  opacity: 0.5;
}

/* Default / Primary */
.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.btn-primary:hover { background-color: var(--primary-hover); }
.btn-primary:active { transform: scale(0.98); }

/* Secondary */
.btn-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-secondary:hover { background-color: #e4e4e7; }
.dark .btn-secondary:hover { background-color: #3f3f46; }

/* Outline */
.btn-outline {
  background-color: var(--background);
  color: var(--foreground);
  border-color: var(--border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-outline:hover { background-color: var(--accent); color: var(--accent-foreground); }

/* Ghost */
.btn-ghost {
  background-color: transparent;
  color: var(--foreground);
}
.btn-ghost:hover { background-color: var(--accent); color: var(--accent-foreground); }

/* Destructive */
.btn-destructive {
  background-color: var(--destructive);
  color: var(--destructive-foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.btn-destructive:hover { background-color: #dc2626; }

/* Size variants */
.btn-sm  { height: 2rem; padding: 0 0.75rem; font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn-lg  { height: 2.75rem; padding: 0 2rem; font-size: 1rem; }
.btn-icon { width: 2.25rem; padding: 0; }
.btn-icon.btn-sm { width: 2rem; }

/* =============================================================
   Shadcn — Label
   ============================================================= */

.label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  color: var(--foreground);
  margin-bottom: 0.375rem;
  cursor: default;
}
.label .req { color: var(--destructive); margin-left: 2px; }

/* Legacy alias */
.form-label { display: block; font-size: 0.875rem; font-weight: 500; line-height: 1; color: var(--foreground); margin-bottom: 0.375rem; }
.form-label .req { color: var(--destructive); margin-left: 2px; }

/* =============================================================
   Shadcn — Input
   ============================================================= */

.input,
.form-input {
  display: flex;
  width: 100%;
  height: 2.25rem;          /* h-9 */
  border-radius: var(--radius);
  border: 1px solid var(--input);
  background-color: transparent;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  font-family: 'Inter', sans-serif;
  color: var(--foreground);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: border-color 150ms, box-shadow 150ms;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.input::placeholder,
.form-input::placeholder {
  color: var(--muted-foreground);
}
.input:focus,
.form-input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 15%, transparent);
}
.input:disabled,
.form-input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  background-color: var(--muted);
}
/* Hide native browser calendar icon on all date inputs */
.input[type="date"]::-webkit-calendar-picker-indicator,
.form-input[type="date"]::-webkit-calendar-picker-indicator {
  display: none;
  -webkit-appearance: none;
}

.input[type="file"],
.form-input[type="file"] {
  border: none;
  padding: 0;
  background: none;
  box-shadow: none;
  font-size: 0.875rem;
  color: var(--foreground);
}
.input.is-error,
.form-input.is-error {
  border-color: var(--destructive);
}
.input.is-error:focus,
.form-input.is-error:focus {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.15);
}

/* Textarea */
textarea.input,
textarea.form-input {
  height: auto;
  min-height: 6rem;
  padding: 0.5rem 0.75rem;
  resize: vertical;
}

/* Select */
select.input,
select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* =============================================================
   Shadcn — Card
   ============================================================= */

.card {
  background-color: var(--card);
  color: var(--card-foreground);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}
.card-header {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 1.5rem;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--card-foreground);
}
.card-description {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  line-height: 1.5;
}
.card-content {
  padding: 0 1.5rem 1.5rem;
}
.card-footer {
  display: flex;
  align-items: center;
  padding: 0 1.5rem 1.5rem;
}

/* Section header bar inside card (accent left strip) */
.card-section-hd {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--foreground);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--card);
}
.card-section-hd::before {
  content: '';
  width: 3px;
  height: 14px;
  background: var(--primary);
  border-radius: 2px;
  flex-shrink: 0;
}

/* =============================================================
   Shadcn — Badge
   ============================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

/* Semantic badges */
.badge-default    { background: var(--secondary); color: var(--secondary-foreground); border-color: var(--border); }
.badge-primary    { background: var(--primary); color: var(--primary-foreground); }
.badge-outline    { background: transparent; color: var(--foreground); border-color: var(--border); }
.badge-draft      { background: #f4f4f5; color: #71717a; border-color: #e4e4e7; }
.badge-submitted  { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge-review     { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.badge-revision   { background: #fff7ed; color: #ea580c; border-color: #fed7aa; }
.badge-accepted   { background: #f0fdf4; color: #16a34a; border-color: #bbf7d0; }
.badge-rejected   { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.badge-published  { background: #f0fdf4; color: #15803d; border-color: #86efac; }

/* =============================================================
   Shadcn — Table
   ============================================================= */

.tbl-wrap {
  position: relative;
  width: 100%;
  overflow: auto;
}
.tbl {
  width: 100%;
  caption-side: bottom;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.tbl caption {
  margin-top: 1rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-align: center;
}
.tbl thead { border-bottom: 1px solid var(--border); }
.tbl thead tr:hover { background: transparent !important; }
.tbl th {
  height: 2.5rem;
  padding: 0 0.75rem;
  text-align: left;
  vertical-align: middle;
  font-weight: 500;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}
.tbl tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 120ms;
}
.tbl tbody tr:last-child { border-bottom: none; }
.tbl tbody tr:hover { background-color: var(--muted); }
.tbl td {
  padding: 0.75rem;
  vertical-align: middle;
  color: var(--foreground);
}

/* =============================================================
   Shadcn — Sidebar
   ============================================================= */

.sidebar {
  display: flex;
  flex-direction: column;
  width: 220px;
  flex-shrink: 0;
  background-color: var(--sidebar);
  border-right: 1px solid var(--sidebar-border);
  height: 100%;
  overflow-y: auto;
}
.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 0.875rem 0.75rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.5rem;
}
.sidebar-footer {
  padding: 0.75rem 0.875rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-group-label {
  display: block;
  padding: 0 0.375rem;
  margin-bottom: 0.25rem;
  margin-top: 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.sidebar-group-label:first-child { margin-top: 0.25rem; }
.sidebar-menu { display: flex; flex-direction: column; gap: 1px; }
.sidebar-menu-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.4375rem 0.625rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--sidebar-foreground);
  cursor: pointer;
  text-decoration: none;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
  border-left: 2px solid transparent;
}
.sidebar-menu-item:hover {
  background-color: var(--accent);
  color: var(--accent-foreground);
}
.sidebar-menu-item.active {
  background-color: var(--primary);
  color: #ffffff;
  border-left-color: transparent;
  font-weight: 600;
  padding-left: calc(0.625rem - 2px);
}
.sidebar-menu-item.active:hover {
  background-color: var(--primary);
  color: #ffffff;
}
.sidebar-menu-item svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  opacity: 0.7;
}
.sidebar-menu-item.active svg { opacity: 1; }
.sidebar-count {
  margin-left: auto;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.0625rem 0.375rem;
  border-radius: 9999px;
  line-height: 1.4;
}

/* =============================================================
   Step Sidebar (Submission Wizard)
   ============================================================= */

.step-sidebar { display: flex; flex-direction: column; padding: 0.5rem 0; }

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  cursor: default;
  position: relative;
}
.step-item:hover:not(.active) { background-color: var(--accent); }
.step-item.active { background-color: var(--primary-light); }

.step-number {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  background-color: var(--background);
  color: var(--muted-foreground);
  transition: all 0.2s;
}
.step-item.active .step-number {
  border-color: var(--primary);
  color: var(--primary);
  background-color: var(--background);
}
.step-item.completed .step-number {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.step-item.completed .step-number::after { content: '✓'; font-size: 0.625rem; }
.step-item.completed .step-number span  { display: none; }

.step-info { flex: 1; min-width: 0; }

.step-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  line-height: 1.3;
}
.step-sublabel {
  font-size: 0.6875rem;
  color: var(--muted-foreground);
  opacity: 0.6;
  margin-top: 1px;
  line-height: 1.3;
}
.step-item.active    .step-label    { color: var(--foreground); font-weight: 600; }
.step-item.active    .step-sublabel { color: var(--muted-foreground); opacity: 1; }
.step-item.completed .step-label    { color: var(--foreground); opacity: 0.8; }

.step-connector {
  width: 1.5px;
  height: 12px;
  margin-left: calc(0.875rem + 10px);
  background: var(--border);
  border-radius: 1px;
}
.step-connector.done { background: var(--primary); opacity: 0.35; }

/* =============================================================
   Shadcn — Separator / Divider
   ============================================================= */

.separator {
  flex-shrink: 0;
  background-color: var(--border);
  height: 1px;
  width: 100%;
}
.separator-vertical { width: 1px; height: 100%; }

.divider {
  display: flex; align-items: center;
  gap: 0.75rem; color: var(--muted-foreground); font-size: 0.8125rem;
}
.divider::before, .divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* =============================================================
   Navigation Links (top tab bar)
   ============================================================= */

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color 150ms, border-color 150ms;
}
.nav-link:hover   { color: var(--foreground); }
.nav-link.active  { color: var(--primary); border-bottom-color: var(--primary); }

/* =============================================================
   Top Tab variants (filter pills)
   ============================================================= */

.filter-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.3125rem 0.875rem;
  border-radius: 9999px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--muted-foreground);
  border: 1px solid var(--border);
  background: var(--background);
  cursor: pointer;
  transition: all 120ms;
}
.filter-tab:hover { border-color: var(--primary); color: var(--foreground); }
.filter-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* =============================================================
   Form Helpers
   ============================================================= */

.form-field { display: flex; flex-direction: column; gap: 0.375rem; }
.form-hint  { font-size: 0.75rem; color: var(--muted-foreground); }
.form-error { font-size: 0.75rem; color: var(--destructive); }
.form-checkbox {
  width: 1rem; height: 1rem;
  border: 1px solid var(--input);
  border-radius: var(--radius-sm);
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* =============================================================
   Scrollbar
   ============================================================= */

::-webkit-scrollbar           { width: 5px; height: 5px; }
::-webkit-scrollbar-track     { background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-foreground); opacity: 0.5; }

/* =============================================================
   Dark Mode Toggle Icon
   ============================================================= */

html:not(.dark) #icon-sun { display: none; }
html.dark       #icon-moon { display: none; }

/* =============================================================
   Dark Mode overrides for inline Tailwind classes
   ============================================================= */

.dark body { background-color: var(--background); color: var(--foreground); }

.dark .bg-white       { background-color: var(--card) !important; }
.dark .bg-gray-50,
.dark .bg-gray-100    { background-color: var(--muted) !important; }
.dark .bg-cream,
.dark .bg-background  { background-color: var(--background) !important; }

.dark .border-gray-200,
.dark .border-gray-100 { border-color: var(--border) !important; }

.dark .text-gray-900,
.dark .text-gray-800   { color: var(--foreground) !important; }
.dark .text-gray-700   { color: #d4d4d8 !important; }
.dark .text-gray-600   { color: #a1a1aa !important; }
.dark .text-gray-500,
.dark .text-gray-400   { color: var(--muted-foreground) !important; }
.dark .text-ink        { color: var(--foreground) !important; }
.dark .text-muted      { color: var(--muted-foreground) !important; }
.dark .text-primary    { color: #e57373 !important; }

.dark .bg-primary-light { background-color: var(--primary-light) !important; }

/* Table dark */
.dark .tbl tbody tr:hover { background-color: var(--muted); }
.dark .tbl thead { border-color: var(--border); }

/* =============================================================
   Mobile Responsive
   ============================================================= */

/* Sidebar backdrop overlay (mobile) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 49;
  animation: backdropIn 200ms ease;
}
@keyframes backdropIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (max-width: 767px) {
  /* Sidebar becomes a fixed left drawer */
  .sidebar {
    position: fixed;
    left: -260px;
    top: 0;
    bottom: 0;
    height: 100dvh;
    z-index: 50;
    transition: left 220ms cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 220ms ease;
    width: 260px;
    transform: none !important;
  }
  .sidebar.open {
    left: 0;
    box-shadow: 6px 0 28px rgba(0, 0, 0, 0.18);
  }
  .sidebar-backdrop.open {
    display: block;
  }

  /* Notification panel — don't overflow screen */
  #notif-panel {
    width: calc(100vw - 1rem);
    right: 0.5rem;
  }

  /* Main content — tighter padding on small screens */
  .main-content-inner {
    padding-left: 1rem;
    padding-right: 1rem;
    padding-top: 1rem;
  }

  /* Filter tabs — allow wrapping more freely */
  .filter-tab {
    font-size: 0.75rem;
    padding: 0.25rem 0.625rem;
  }

  /* Nav links — already scrollable via base .nav-tabs-row styles */
}

/* Hamburger toggle — hidden on desktop */
@media (min-width: 768px) {
  .btn-sidebar-toggle { display: none !important; }
}

/* Role tab nav — flex-grow so it fills middle, min-width:0 allows shrinking */
.nav-tabs-row {
  display: flex;
  align-items: stretch;
  flex: 1 1 auto;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs-row::-webkit-scrollbar { display: none; }

/* Right utility bar — never shrink off screen */
.nav-utils {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  border-left: 1px solid var(--border);
}

/* Logo container — fixed width on desktop, shrink-proof on mobile */
.nav-logo {
  display: flex;
  align-items: center;
  padding-left: 1rem;
  padding-right: 1rem;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  width: 220px;
}
@media (max-width: 767px) {
  .nav-logo {
    width: auto;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }
}
