/* ─── HEPTHEX Admin Panel CSS ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --a-bg:       #060608;
  --a-surface:  #0d0d10;
  --a-panel:    #111115;
  --a-card:     #15151a;
  --a-border:   rgba(255,255,255,0.07);
  --a-border-h: rgba(255,255,255,0.14);
  --sidebar-w:  240px;
  --header-h:   60px;
  --c-accent:   #ffffff;
  --c-danger:   #f87171;
  --c-success:  #4ade80;
  --c-warning:  #fbbf24;
  --c-info:     #60a5fa;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--a-bg);
  color: #d0d0d8;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; }
::selection { background: rgba(255,255,255,0.12); color: #fff; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--a-bg); }
::-webkit-scrollbar-thumb { background: #222; border-radius: 2px; }

/* ─── Layout ───────────────────────────────────────────────────────────── */
.admin-layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Sidebar ──────────────────────────────────────────────────────────── */
.admin-sidebar {
  width: var(--sidebar-w);
  background: var(--a-surface);
  border-right: 1px solid var(--a-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-logo img { height: 28px; filter: brightness(0) invert(1); }
.sidebar-logo-text {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.08em;
}
.sidebar-logo-sub { font-size: 0.65rem; color: #555; letter-spacing: 0.05em; }

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

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #444;
  padding: 12px 10px 6px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  color: #888;
  transition: all 0.2s;
  margin-bottom: 2px;
  position: relative;
}
.sidebar-link svg { width: 16px; height: 16px; stroke: currentColor; flex-shrink: 0; }
.sidebar-link:hover { color: #d0d0d8; background: rgba(255,255,255,0.04); }
.sidebar-link.active {
  color: #fff;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
}

.sidebar-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: rgba(248,113,113,0.2);
  color: var(--c-danger);
  font-size: 0.68rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--a-border);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--a-border);
}
.sidebar-user-avatar {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name  { font-size: 0.8rem; font-weight: 600; color: #d0d0d8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: 0.68rem; color: #555; }
.sidebar-logout { margin-left: auto; color: #555; padding: 4px; border-radius: 4px; transition: color 0.2s; }
.sidebar-logout:hover { color: var(--c-danger); }
.sidebar-logout svg { width: 14px; height: 14px; stroke: currentColor; }

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

.admin-header {
  height: var(--header-h);
  background: var(--a-surface);
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-header-title { font-size: 0.9rem; font-weight: 600; color: #d0d0d8; }
.admin-header-actions { display: flex; align-items: center; gap: 10px; }
.admin-header-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--a-border);
  background: rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: center;
  color: #666;
  transition: all 0.2s;
}
.admin-header-btn:hover { color: #d0d0d8; border-color: var(--a-border-h); }
.admin-header-btn svg { width: 16px; height: 16px; stroke: currentColor; }

.admin-content { padding: 24px; flex: 1; }

/* ─── Stats Cards ───────────────────────────────────────────────────────── */
.admin-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.admin-stat {
  background: var(--a-card);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.admin-stat:hover { border-color: var(--a-border-h); }
.admin-stat-label  { font-size: 0.72rem; font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; color: #555; margin-bottom: 10px; }
.admin-stat-value  { font-size: 1.8rem; font-weight: 700; color: #fff; line-height: 1; margin-bottom: 8px; font-family: 'JetBrains Mono', monospace; }
.admin-stat-change { font-size: 0.75rem; color: #666; }
.admin-stat-change.up   { color: var(--c-success); }
.admin-stat-change.down { color: var(--c-danger); }
.admin-stat-icon {
  position: absolute;
  top: 20px; right: 20px;
  width: 36px; height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--a-border);
  display: flex; align-items: center; justify-content: center;
}
.admin-stat-icon svg { width: 16px; height: 16px; stroke: #666; }

/* ─── Tables ─────────────────────────────────────────────────────────────── */
.admin-card {
  background: var(--a-card);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 16px;
}
.admin-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-card-title { font-size: 0.9rem; font-weight: 600; color: #d0d0d8; }
.admin-card-body  { padding: 20px; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #555;
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--a-border);
}
.admin-table td {
  padding: 12px 16px;
  font-size: 0.85rem;
  color: #a0a0aa;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(255,255,255,0.015); }
.admin-table td.text-white { color: #d0d0d8; font-weight: 500; }

.table-wrap { overflow-x: auto; }

/* ─── Status Badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge-new     { background: rgba(96,165,250,0.12); color: var(--c-info); border: 1px solid rgba(96,165,250,0.2); }
.badge-open    { background: rgba(74,222,128,0.1);  color: var(--c-success); border: 1px solid rgba(74,222,128,0.2); }
.badge-closed  { background: rgba(255,255,255,0.04); color: #666; border: 1px solid var(--a-border); }
.badge-pending { background: rgba(251,191,36,0.1); color: var(--c-warning); border: 1px solid rgba(251,191,36,0.2); }
.badge-replied { background: rgba(167,139,250,0.1); color: #a78bfa; border: 1px solid rgba(167,139,250,0.2); }
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ─── Admin Buttons ─────────────────────────────────────────────────────── */
.a-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
}
.a-btn svg { width: 14px; height: 14px; stroke: currentColor; }
.a-btn-primary { background: #fff; color: #000; }
.a-btn-primary:hover { background: #e0e0e0; }
.a-btn-outline { border-color: var(--a-border-h); color: #d0d0d8; background: rgba(255,255,255,0.03); }
.a-btn-outline:hover { background: rgba(255,255,255,0.07); }
.a-btn-danger  { border-color: rgba(248,113,113,0.3); color: var(--c-danger); background: rgba(248,113,113,0.05); }
.a-btn-danger:hover { background: rgba(248,113,113,0.1); }
.a-btn-success { border-color: rgba(74,222,128,0.3); color: var(--c-success); background: rgba(74,222,128,0.05); }
.a-btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.a-btn-icon { padding: 7px; }

/* ─── Admin Forms ───────────────────────────────────────────────────────── */
.a-form-group { margin-bottom: 16px; }
.a-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: #888;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}
.a-input {
  width: 100%;
  padding: 9px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--a-border-h);
  border-radius: 8px;
  color: #d0d0d8;
  font-size: 0.875rem;
  outline: none;
  transition: all 0.2s;
}
.a-input::placeholder { color: #444; }
.a-input:focus {
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.06);
}
textarea.a-input { resize: vertical; min-height: 100px; }
select.a-input  { cursor: pointer; }
select.a-input option { background: #1a1a1f; }

/* ─── Admin Chat Panel ──────────────────────────────────────────────────── */
.admin-chat-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 0;
  height: calc(100vh - var(--header-h) - 48px);
  border: 1px solid var(--a-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--a-card);
}

.chat-list {
  border-right: 1px solid var(--a-border);
  overflow-y: auto;
}
.chat-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--a-border);
  font-size: 0.8rem;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.chat-list-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.15s;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.chat-list-item:hover { background: rgba(255,255,255,0.03); }
.chat-list-item.active { background: rgba(255,255,255,0.06); }
.chat-list-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem; font-weight: 600; color: #888;
}
.chat-list-name  { font-size: 0.85rem; font-weight: 500; color: #d0d0d8; }
.chat-list-preview { font-size: 0.78rem; color: #555; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px; }
.chat-list-meta  { margin-left: auto; text-align: right; }
.chat-list-time  { font-size: 0.68rem; color: #444; }
.chat-unread {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  color: #000;
  font-size: 0.65rem;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  margin: 3px 0 0 auto;
}

.admin-chat-view {
  display: flex;
  flex-direction: column;
}
.admin-chat-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.01);
}
.admin-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.admin-msg { max-width: 70%; }
.admin-msg.from-customer { align-self: flex-start; }
.admin-msg.from-admin    { align-self: flex-end; }
.admin-msg-bubble {
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.5;
}
.admin-msg.from-customer .admin-msg-bubble {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-bottom-left-radius: 4px;
}
.admin-msg.from-admin .admin-msg-bubble {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.admin-msg-meta { font-size: 0.68rem; color: #444; margin-top: 4px; }
.admin-msg.from-admin .admin-msg-meta { text-align: right; }

.admin-chat-input {
  padding: 14px 20px;
  border-top: 1px solid var(--a-border);
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

/* ─── Content Editor ────────────────────────────────────────────────────── */
.content-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--a-border);
  padding-bottom: 0;
}
.content-tab {
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #555;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 0.2s;
  cursor: pointer;
  border-radius: 4px 4px 0 0;
}
.content-tab:hover { color: #888; }
.content-tab.active { color: #d0d0d8; border-bottom-color: #fff; }

/* ─── Modal ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--a-panel);
  border: 1px solid var(--a-border-h);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.96) translateY(-8px);
  transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
  box-shadow: 0 32px 80px rgba(0,0,0,0.8);
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; color: #d0d0d8; }
.modal-close { color: #555; padding: 4px; border-radius: 4px; transition: color 0.2s; }
.modal-close:hover { color: #d0d0d8; }
.modal-close svg { width: 18px; height: 18px; stroke: currentColor; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--a-border); display: flex; gap: 10px; justify-content: flex-end; }

/* ─── Responsive Admin ───────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .admin-stats-grid { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .admin-stats-grid { grid-template-columns: 1fr 1fr; }
  .admin-chat-layout { grid-template-columns: 1fr; }
  .chat-list { display: none; }
  .chat-list.visible { display: block; }
}
@media (max-width: 480px) {
  .admin-stats-grid { grid-template-columns: 1fr; }
  .admin-content { padding: 16px; }
}
