/* ─── rhyn.digital Admin Panel ─────────────────────────────────────────────── */

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

:root {
  --sidebar-w:    240px;
  --topbar-h:     60px;
  --color-dark:   #1e2c2e;
  --color-darker: #162022;
  --color-blue:   #4a9eff;
  --color-green:  #22c55e;
  --color-yellow: #f59e0b;
  --color-red:    #ef4444;
  --color-bg:     #f0f2f5;
  --color-card:   #ffffff;
  --color-border: #e5e7eb;
  --color-text:   #111827;
  --color-muted:  #6b7280;
  --radius:       8px;
  --shadow:       0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:    0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-bg);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login Page ─────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-darker) 0%, #2a3f42 100%);
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo__wordmark {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-dark);
  letter-spacing: -0.5px;
}

.login-logo__sub {
  font-size: 11px;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-top: 4px;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 24px;
  text-align: center;
}

/* ─── Admin Layout ───────────────────────────────────────────────────────── */

.admin-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────── */

.admin-sidebar {
  grid-row: 1 / 3;
  background: var(--color-dark);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo__wordmark {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-logo__sub {
  font-size: 10px;
  color: rgba(255,255,255,.45);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 0;
}

.sidebar-nav__label {
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 8px 20px 4px;
  margin-top: 8px;
}

.sidebar-nav__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: rgba(255,255,255,.7);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.sidebar-nav__link:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
}

.sidebar-nav__link.active {
  color: #fff;
  background: rgba(74,158,255,.15);
  border-left-color: var(--color-blue);
}

.sidebar-nav__icon {
  width: 18px;
  height: 18px;
  opacity: .7;
  flex-shrink: 0;
}

.sidebar-nav__link.active .sidebar-nav__icon,
.sidebar-nav__link:hover .sidebar-nav__icon { opacity: 1; }

.sidebar-bottom {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: 12px;
  color: rgba(255,255,255,.4);
}

.sidebar-bottom a {
  color: rgba(255,255,255,.55);
  text-decoration: none;
}
.sidebar-bottom a:hover { color: #fff; }

/* ─── Topbar ─────────────────────────────────────────────────────────────── */

.admin-topbar {
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  box-shadow: var(--shadow);
}

.topbar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-dark);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--color-muted);
}

.topbar-user__avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-dark);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ─── Main Content ───────────────────────────────────────────────────────── */

.admin-main {
  padding: 28px;
  overflow-y: auto;
}

/* ─── Page header ────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-dark);
  line-height: 1.2;
}

.page-header p {
  margin-top: 4px;
  font-size: 13px;
  color: var(--color-muted);
}

/* ─── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--color-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 1px solid var(--color-border);
}

.card + .card { margin-top: 20px; }

.card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  margin-bottom: 16px;
}

/* ─── Stat Grid ──────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--color-border);
}

.stat-card__value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-dark);
  line-height: 1;
}
.stat-card__value--muted { color: var(--color-muted); }

.stat-card__label {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 6px;
}

/* ─── Forms ──────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-group:last-of-type { margin-bottom: 0; }

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

.form-hint {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(74,158,255,.15);
}

input.is-error { border-color: var(--color-red); }
input.is-error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }

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

.char-count {
  font-size: 11px;
  color: var(--color-muted);
  text-align: right;
  margin-top: 3px;
}

.char-count.over { color: var(--color-red); font-weight: 600; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn--primary {
  background: var(--color-dark);
  color: #fff;
}
.btn--primary:hover:not(:disabled) { background: var(--color-darker); }

.btn--blue {
  background: var(--color-blue);
  color: #fff;
}
.btn--blue:hover:not(:disabled) { background: #3a8eef; }

.btn--ghost {
  background: transparent;
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover:not(:disabled) { background: var(--color-bg); color: var(--color-text); }

.btn--danger {
  background: transparent;
  color: var(--color-red);
  border: 1px solid var(--color-red);
}
.btn--danger:hover:not(:disabled) { background: var(--color-red); color: #fff; }

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

/* Icon-only buttons */
.btn--icon {
  padding: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  justify-content: center;
  flex-shrink: 0;
  border: none;
  transition: opacity .15s;
}
.btn--icon.btn--sm { width: 28px; height: 28px; border-radius: 7px; }
.btn--icon svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn--icon:hover:not(:disabled) { opacity: .72; }

/* Create — green */
.btn--create {
  background: #dcfce7;
  color: #16a34a;
  border: none;
}
.btn--create:hover:not(:disabled) { opacity: .72; background: #dcfce7; }

/* Edit — blue */
.btn--edit {
  background: #dbeafe;
  color: #2563eb;
  border: none;
}
.btn--edit:hover:not(:disabled) { opacity: .72; background: #dbeafe; }

/* View — blue (eye icon) */
.btn--view {
  background: #dbeafe;
  color: #2563eb;
  border: none;
}
.btn--view:hover:not(:disabled) { opacity: .72; background: #dbeafe; }

/* Convert — green */
.btn--convert {
  background: #dcfce7;
  color: #16a34a;
  border: none;
}
.btn--convert:hover:not(:disabled) { opacity: .72; background: #dcfce7; }

/* Delete — red */
.btn--del {
  background: #fee2e2;
  color: #dc2626;
  border: none;
}
.btn--del:hover:not(:disabled) { opacity: .72; background: #fee2e2; }

/* PDF / Download — orange */
.btn--pdf {
  background: #fef3c7;
  color: #d97706;
  border: none;
}
.btn--pdf:hover:not(:disabled) { opacity: .72; background: #fef3c7; }

/* Download — green */
.btn--dl {
  background: #dcfce7;
  color: #16a34a;
  border: none;
}
.btn--dl:hover:not(:disabled) { opacity: .72; background: #dcfce7; }

/* Warning / Archive — orange */
.btn--warn {
  background: #fef3c7;
  color: #d97706;
  border: none;
}
.btn--warn:hover:not(:disabled) { opacity: .72; background: #fef3c7; }

/* Send / Mail — purple */
.btn--mail {
  background: #f3e8ff;
  color: #9333ea;
  border: none;
}
.btn--mail:hover:not(:disabled) { opacity: .72; background: #f3e8ff; }

/* Neutral / Gray */
.btn--neutral {
  background: #f3f4f6;
  color: #6b7280;
  border: none;
}
.btn--neutral:hover:not(:disabled) { opacity: .72; background: #f3f4f6; }

/* ─── Select / Dropdown ──────────────────────────────────────────────────── */

.form-input,
select.form-input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
  appearance: none;
}

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 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-input:focus,
select.form-input:focus {
  outline: none;
  border-color: var(--color-blue);
  box-shadow: 0 0 0 3px rgba(74,158,255,.15);
}

/* ─── Alerts ─────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert--success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alert--error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert--warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.alert--info    { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }

/* ─── Table ──────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 480px; /* prevents squishing on mobile — scrolls in .table-wrap */
}

thead th {
  background: var(--color-bg);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: .8px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background .1s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #fafafa; }

tbody td {
  padding: 12px 14px;
  font-size: 13px;
  vertical-align: middle;
}

.td-meta { max-width: 280px; }

.td-meta__title {
  font-weight: 500;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

.td-meta__desc {
  font-size: 11px;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  margin-top: 2px;
}

/* ─── Language badge ─────────────────────────────────────────────────────── */

.lang-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.lang-badge--de { background: #e0f2fe; color: #0369a1; }
.lang-badge--en { background: #f3e8ff; color: #7c3aed; }
.lang-badge--fr { background: #dcfce7; color: #15803d; }

/* ─── Content ratio badge ────────────────────────────────────────────────── */

.ratio-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.ratio-badge__bar-wrap {
  width: 40px;
  height: 4px;
  background: rgba(0,0,0,.12);
  border-radius: 2px;
  overflow: hidden;
}

.ratio-badge__bar {
  height: 100%;
  border-radius: 2px;
  transition: width .3s;
}

.ratio-good   { background: #f0fdf4; color: #166534; }
.ratio-good   .ratio-badge__bar { background: #22c55e; }

.ratio-medium { background: #fffbeb; color: #92400e; }
.ratio-medium .ratio-badge__bar { background: #f59e0b; }

.ratio-low    { background: #fef2f2; color: #991b1b; }
.ratio-low    .ratio-badge__bar { background: #ef4444; }

.ratio-unknown { background: #f3f4f6; color: #6b7280; }

/* ─── Edit Modal / inline form ───────────────────────────────────────────── */

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.modal-box {
  background: #fff;
  border-radius: 10px;
  width: 100%;
  max-width: 580px;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
  overflow: hidden;
}

.modal-header {
  background: var(--color-dark);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 15px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
.modal-close:hover { color: #fff; }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafa;
}

/* ─── Section divider ────────────────────────────────────────────────────── */

.section-divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 24px 0;
}

/* ─── Profile avatar ─────────────────────────────────────────────────────── */

.profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--color-dark);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

/* ─── Grid utils ─────────────────────────────────────────────────────────── */

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ─── Mobile: Hamburger button (only visible on mobile) ──────────────────── */

.topbar-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: var(--color-dark);
  flex-shrink: 0;
  border-radius: 7px;
  transition: background .15s;
}
.topbar-hamburger:hover { background: var(--color-bg); }
.topbar-hamburger svg { pointer-events: none; }

/* ─── Mobile: Sidebar overlay backdrop ───────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 199;
}
.sidebar-overlay.open { display: block; }

/* ─── Responsive breakpoints ─────────────────────────────────────────────── */

@media (max-width: 900px) {
  /* Reduce topbar padding on tablets */
  .admin-topbar { padding: 0 18px; }
  .admin-main   { padding: 20px; }
}

@media (max-width: 768px) {
  /* ── Layout: sidebar becomes a slide-out drawer ──────────────────────── */
  .admin-layout {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) auto;
    min-height: 100svh;
  }

  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(280px, 85vw);
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform .25s ease;
    grid-row: auto;
    box-shadow: none;
  }

  .admin-sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,.35);
  }

  /* ── Topbar: show hamburger, full width ──────────────────────────────── */
  .admin-topbar {
    padding: 0 14px;
    gap: 12px;
  }

  .topbar-hamburger { display: flex; }

  .topbar-title { font-size: 14px; }

  /* Hide username on very small screens, keep avatar */
  .topbar-user > span:first-of-type { display: none; }

  /* ── Main content: full width, tighter padding, natural page scroll ──── */
  .admin-main {
    padding: 14px;
    overflow-y: visible;
  }

  /* ── Page header ─────────────────────────────────────────────────────── */
  .page-header {
    flex-wrap: wrap;
    margin-bottom: 16px;
  }
  .page-header h1 { font-size: 18px; }
  /* Actions drop below title on narrow screens */
  .page-header > div,
  .page-header > form,
  .page-header > a,
  .page-header > button {
    flex-shrink: 0;
  }

  /* ── Stat grid: max 2 columns ────────────────────────────────────────── */
  .stat-grid,
  .stat-grid[style] {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px;
    margin-bottom: 16px;
  }

  .stat-card { padding: 14px; }
  .stat-card__value { font-size: 22px; }

  /* ── Cards ───────────────────────────────────────────────────────────── */
  .card { padding: 16px; }

  /* ── Modals: bottom sheet on mobile ──────────────────────────────────── */
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal-box {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
  }

  .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── Grid utils ──────────────────────────────────────────────────────── */
  .grid-2 { grid-template-columns: 1fr; }

  /* ── Filter bars: wrap onto multiple lines ───────────────────────────── */
  .filter-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .filter-bar > * { flex-shrink: 0; }

  /* ── Tables: touch-friendly horizontal scroll ────────────────────────── */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }

  /* Increase touch target for action buttons */
  .btn--icon {
    width: 36px;
    height: 36px;
  }

  /* ── Form inputs: larger tap targets ─────────────────────────────────── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  textarea,
  .form-input,
  select.form-input {
    font-size: 16px; /* prevents iOS zoom on focus */
    padding: 10px 12px;
  }

  /* ── Login card: adjust padding on small screens ─────────────────────── */
  .login-card {
    padding: 28px 20px;
  }
}

@media (max-width: 480px) {
  /* Single column stat grid on very small phones */
  .stat-grid,
  .stat-grid[style] {
    grid-template-columns: 1fr !important;
  }

  .admin-main { padding: 12px; }
  .card { padding: 14px; }

  .modal-box { max-height: 95vh; }

  /* Tables: narrower min-width on very small screens */
  table { min-width: 360px; }

  /* Page header: stack title above actions */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  /* Action button groups: wrap tightly */
  .page-header > div[style*="display:flex"],
  .page-header > div[style*="display: flex"] {
    flex-wrap: wrap;
    gap: 6px !important;
  }

  /* Stat values: tighter on very small screens */
  .stat-card__value { font-size: 20px; }
}
