/* ─────────────────────────────────────────────────────────────────────────────
   Rankaya Writing — Global Design System
   ───────────────────────────────────────────────────────────────────────────── */

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

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --bg-primary:    #0d0d0f;
  --bg-sidebar:    #111113;
  --bg-card:       #1a1a1e;
  --bg-input:      #1f1f24;
  --border:        rgba(255,255,255,0.08);
  --border-hover:  rgba(255,255,255,0.16);
  --accent:        #00e096;
  --accent-dim:    rgba(0,224,150,0.12);
  --accent-hover:  #00c882;
  --text-primary:  #f0f0f0;
  --text-secondary:#888;
  --text-muted:    #555;
  --danger:        #ff4d4f;
  --danger-dim:    rgba(255,77,79,0.12);
  --warning:       #f0a500;
  --warning-dim:   rgba(240,165,0,0.12);
  --success:       #00e096;
  --success-dim:   rgba(0,224,150,0.12);
  --radius:        10px;
  --radius-sm:     6px;
  --radius-lg:     14px;
  --font:          'Inter', system-ui, -apple-system, sans-serif;
  --sidebar-w:     240px;
  --topbar-h:      60px;
  --transition:    0.18s ease;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typography ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 24px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

p { color: var(--text-secondary); }

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

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

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.sidebar-logo-icon {
  font-size: 22px;
  line-height: 1;
}

.sidebar-logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.sidebar-logo-text span {
  color: var(--text-primary);
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 0;
  transition: color var(--transition), background var(--transition);
  position: relative;
}

.nav-item:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

.nav-item.active {
  color: var(--accent);
  background: var(--accent-dim);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 16px;
  flex-shrink: 0;
}

.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 20px 4px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00e096, #0090ff);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #0d0d0f;
  flex-shrink: 0;
}

.user-info {
  flex: 1;
  overflow: hidden;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Main Content ─────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
}

.page-body {
  padding: 24px 32px 48px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition), transform var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn:hover { opacity: .88; text-decoration: none; }
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--accent);
  color: #0d0d0f;
}

.btn-secondary {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255,77,79,0.2);
}

.btn-danger:hover { background: rgba(255,77,79,0.2); }

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

.btn-ghost:hover { color: var(--text-primary); background: rgba(255,255,255,0.04); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

.btn:disabled, .btn[disabled] {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Form Controls ────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-control::placeholder { color: var(--text-muted); }

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

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
}

.char-counter {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.char-counter.warn { color: var(--warning); }
.char-counter.over { color: var(--danger); }

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .form-control { flex: 1; }

.password-wrap {
  position: relative;
}

.password-wrap .form-control { padding-right: 44px; }

.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 15px;
  line-height: 1;
}

.password-toggle:hover { color: var(--text-secondary); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

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

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

/* ── Badges / Pills ───────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
}

.badge-draft    { background: rgba(136,136,136,0.14); color: #888; }
.badge-published{ background: var(--success-dim); color: var(--success); }
.badge-warning  { background: var(--warning-dim);  color: var(--warning); }
.badge-danger   { background: var(--danger-dim);   color: var(--danger); }
.badge-accent   { background: var(--accent-dim);   color: var(--accent); }
.badge-admin    { background: rgba(0,144,255,0.12); color: #4db6ff; }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 14px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.015); }

/* ── Alerts / Flash ───────────────────────────────────────────────────────── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
}

.alert-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-dim); border: 1px solid rgba(0,224,150,0.2); color: #00e096; }
.alert-error   { background: var(--danger-dim);  border: 1px solid rgba(255,77,79,0.2);  color: #ff4d4f; }
.alert-warning { background: var(--warning-dim); border: 1px solid rgba(240,165,0,0.2);  color: #f0a500; }
.alert-info    { background: rgba(0,144,255,0.1);border: 1px solid rgba(0,144,255,0.2);  color: #4db6ff; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  backdrop-filter: blur(4px);
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 440px;
  width: 100%;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-title { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.modal-body  { color: var(--text-secondary); font-size: 14px; margin-bottom: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 24px; }

.tab {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--transition), border-color var(--transition);
  user-select: none;
}

.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

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

/* ── Loading / Spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}

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

.loading-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13,13,15,.6);
  border-radius: inherit;
  z-index: 10;
}

/* ── Hamburger (mobile) ───────────────────────────────────────────────────── */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: var(--transition);
}

.mobile-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 56px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 90;
}

.mobile-logo {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* ── Stats Row ────────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-pill strong {
  color: var(--text-primary);
  font-weight: 700;
  font-size: 15px;
}

/* ── Empty state ──────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
}

.empty-state-icon {
  font-size: 56px;
  margin-bottom: 16px;
  opacity: .6;
}

.empty-state h3 { font-size: 18px; margin-bottom: 8px; }
.empty-state p  { color: var(--text-secondary); margin-bottom: 24px; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 32px;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.page-btn:hover { border-color: var(--border-hover); color: var(--text-primary); text-decoration: none; }
.page-btn.active { background: var(--accent); border-color: var(--accent); color: #0d0d0f; font-weight: 700; }
.page-btn:disabled { opacity: .3; cursor: default; }

/* ── Separator ────────────────────────────────────────────────────────────── */
.sep { height: 1px; background: var(--border); margin: 24px 0; }

/* ── Section heading ──────────────────────────────────────────────────────── */
.section-heading {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 16px;
  margin-top: 32px;
}

.section-heading:first-child { margin-top: 0; }

/* ── Toast notifications ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: all;
  animation: toastIn .25s ease;
  min-width: 260px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid #4db6ff; }

.toast-icon { font-size: 16px; flex-shrink: 0; }
.toast-msg  { flex: 1; color: var(--text-primary); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Scrollbar global ─────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.flex    { display: flex; }
.flex-1  { flex: 1; }
.gap-8   { gap: 8px; }
.gap-12  { gap: 12px; }
.gap-16  { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-backdrop.open { display: block; }

  .main-content {
    margin-left: 0;
  }

  .mobile-topbar { display: flex; }
  .hamburger { display: flex; }
}

@media (max-width: 768px) {
  .page-header { padding: 16px 16px 0; flex-wrap: wrap; }
  .page-body   { padding: 16px 16px 48px; }
  .stats-row   { gap: 8px; }
  .stat-pill   { font-size: 12px; padding: 6px 14px; }
  .modal       { padding: 24px; }
}
