/* =========================================================
   Kaskol — Admin panel styles (light, professional)
   ========================================================= */

.admin-body {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  background: var(--bg);
}

.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  padding: 22px 18px;
}
.admin-sidebar .brand { margin-bottom: 28px; }
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-size: .94rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.admin-nav a:hover { color: var(--text); background: var(--surface-2); }
.admin-nav a.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #e0e7ff;
}
.admin-nav .ico {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  font-size: 14px;
  color: var(--primary);
}
.admin-sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }

.admin-main { display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.admin-page-title { font-size: 1.35rem; margin: 0; font-family: var(--font-display); }
.admin-user { display: flex; align-items: center; gap: 1rem; }

.admin-content { padding: 28px 32px 60px; display: flex; flex-direction: column; gap: 24px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .18s ease, transform .18s ease;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-label {
  font-size: .78rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  font-family: var(--font-display);
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--text);
}
.stat-actions { display: flex; gap: .5rem; margin-top: .25rem; flex-wrap: wrap; }

.admin-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h2 { margin: 0; font-size: 1.05rem; font-family: var(--font-display); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: .76rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.data-table tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.simple-list { list-style: none; padding: 0; margin: 0; }
.simple-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.simple-list li:last-child { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
}
.badge-new { background: #eef2ff; color: #4338ca; border-color: #c7d2fe; }
.badge-reviewing { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.badge-shortlisted { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.badge-hired { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-rejected { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.badge-published { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.badge-draft { background: var(--surface-2); color: var(--muted); }

.filter-pills { display: flex; gap: .35rem; flex-wrap: wrap; }
.filter-pills a {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: .82rem;
  color: var(--muted);
}
.filter-pills a:hover { color: var(--text); border-color: var(--border-strong); }
.filter-pills a.is-active {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}

.apps-list { display: flex; flex-direction: column; gap: 10px; }
.app-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-xs);
}
.app-item.is-unread { border-color: #c7d2fe; }
.app-item summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.app-item summary::-webkit-details-marker { display: none; }
.app-item summary::after {
  content: '⌄';
  color: var(--muted);
  margin-left: 12px;
  transition: transform .2s ease;
}
.app-item[open] summary::after { transform: rotate(180deg); }
.app-meta { display: flex; align-items: center; gap: .8rem; }
.app-body { padding: 0 18px 18px; border-top: 1px solid var(--border); }
.app-message {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  margin-top: 12px;
  white-space: pre-wrap;
  color: var(--text-2);
}
.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 6px 14px;
  margin: 12px 0;
  font-size: .92rem;
}
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.app-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form { display: inline-flex; gap: 6px; align-items: center; }

/* ---------- Auth shell ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
  background:
    radial-gradient(800px 400px at 80% 0%, rgba(99, 102, 241, .14), transparent 60%),
    radial-gradient(800px 400px at 0% 100%, rgba(14, 165, 233, .10), transparent 60%),
    var(--bg);
}
.auth-shell { width: 100%; max-width: 420px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand { margin-bottom: 1.4rem; }
.auth-card h1 { font-size: 1.5rem; margin: 0 0 .35em; }

/* ---------- WhatsApp panel ---------- */
.wa-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 540px;
  box-shadow: var(--shadow-xs);
}
.wa-sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg-2); }
.wa-sidebar-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.wa-sidebar-head h2 { margin: 0; font-size: 1rem; font-family: var(--font-display); }
.wa-new summary { list-style: none; cursor: pointer; }
.wa-new summary::-webkit-details-marker { display: none; }
.wa-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; max-height: 70vh; }
.wa-list li a {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  color: inherit;
}
.wa-list li.is-active a { background: var(--primary-soft); }
.wa-list li a:hover { background: var(--surface-2); }
.wa-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  font-weight: 700;
  font-size: .8rem;
}
.wa-meta { min-width: 0; }
.wa-meta strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.wa-preview {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.wa-badge {
  background: #25d366;
  color: #fff;
  font-weight: 700;
  font-size: .7rem;
  border-radius: 999px;
  padding: 2px 8px;
}

.wa-thread { display: flex; flex-direction: column; }
.wa-thread-head { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.wa-thread-body {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 60vh;
}
.wa-msg { display: flex; }
.wa-msg-inbound { justify-content: flex-start; }
.wa-msg-outbound { justify-content: flex-end; }
.wa-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .94rem;
  line-height: 1.5;
  position: relative;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: var(--shadow-xs);
}
.wa-msg-inbound .wa-bubble {
  background: #fff;
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}
.wa-msg-outbound .wa-bubble {
  background: linear-gradient(135deg, #16a34a, #128c7e);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.wa-time {
  display: block;
  font-size: .68rem;
  opacity: .7;
  margin-top: 4px;
}
.wa-compose {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg-2);
}
.wa-compose textarea {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  resize: none;
}
.wa-empty { padding: 60px 24px; text-align: center; }

/* Make every data table horizontally scrollable on small screens
   without crushing the cells. */
.panel { overflow-x: auto; }
.data-table { min-width: 540px; }
.panel > .data-table { display: table; }

@media (max-width: 1100px) {
  .admin-body { grid-template-columns: 220px 1fr; }
}

@media (max-width: 980px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .admin-grid { grid-template-columns: 1fr; }
  .wa-shell { grid-template-columns: 1fr; }
  .wa-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .wa-list { max-height: 280px; }
  .stat-value { font-size: 1.7rem; }
}

@media (max-width: 760px) {
  .admin-body { grid-template-columns: 1fr; }
  .admin-sidebar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
    gap: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .admin-sidebar .brand { margin: 0; flex-shrink: 0; }
  .admin-nav { flex-direction: row; gap: 4px; flex-shrink: 0; }
  .admin-nav a { padding: 8px 12px; white-space: nowrap; }
  .admin-sidebar-foot { display: none; }
  .admin-content { padding: 18px 14px 40px; gap: 16px; }
  .admin-topbar {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .admin-page-title { font-size: 1.1rem; }
  .admin-user { gap: .5rem; }
  .admin-user .small { display: none; }
  .panel { padding: 16px; }
  .panel-head { gap: 8px; }
  .panel-head h2 { font-size: 1rem; }
  .stat-value { font-size: 1.5rem; }
  .stat-card { padding: 16px; }
  .auth-card { padding: 24px; }
  .filter-pills { flex-wrap: wrap; }
  .row-actions { flex-wrap: wrap; justify-content: flex-start; }
  .wa-thread-body { max-height: 50vh; padding: 14px; }
  .wa-bubble { max-width: 85%; }
  .form .row { grid-template-columns: 1fr; }
}

/* ---------- RTL admin overrides ---------- */
html[dir="rtl"] .admin-body { grid-template-columns: 1fr 260px; }
html[dir="rtl"] .admin-sidebar { border-right: none; border-left: 1px solid var(--border); }
html[dir="rtl"] .wa-sidebar { border-right: none; border-left: 1px solid var(--border); }
html[dir="rtl"] .wa-msg-inbound { justify-content: flex-end; }
html[dir="rtl"] .wa-msg-outbound { justify-content: flex-start; }
html[dir="rtl"] .wa-msg-inbound .wa-bubble { border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
html[dir="rtl"] .wa-msg-outbound .wa-bubble { border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
html[dir="rtl"] .data-table { min-width: 540px; }
html[dir="rtl"] .data-table th, html[dir="rtl"] .data-table td { text-align: right; }
html[dir="rtl"] .row-actions { justify-content: flex-start; }
html[dir="rtl"] .kv { grid-template-columns: 1fr 120px; }

@media (max-width: 1100px) {
  html[dir="rtl"] .admin-body { grid-template-columns: 1fr 220px; }
}

@media (max-width: 760px) {
  html[dir="rtl"] .admin-body { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 14px 12px 32px; }
  .admin-topbar { padding: 10px 12px; }
  .panel { padding: 14px; }
  .auth-card { padding: 20px; border-radius: 14px; }
  .wa-list li a { grid-template-columns: 32px 1fr auto; gap: 8px; padding: 10px 12px; }
  .wa-avatar { width: 32px; height: 32px; font-size: .75rem; }
  .wa-thread-body { max-height: 45vh; }
  .wa-compose { padding: 8px; }
  .wa-bubble { font-size: .9rem; padding: 8px 12px; }
}
