/* ============================================================
   ADMIN PANEL – admin.css
   Support Portal v2026
   ============================================================ */

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

:root {
  --brand:       #10b981;
  --brand-dark:  #059669;
  --brand-light: #d1fae5;
  --danger:      #ef4444;
  --danger-dark: #dc2626;
  --warning:     #f59e0b;
  --purple:      #8b5cf6;
  --blue:        #3b82f6;

  --bg:          #f1f5f9;
  --surface:     #ffffff;
  --surface2:    #f8fafc;
  --border:      #e2e8f0;
  --border2:     #cbd5e1;

  --text:        #0f172a;
  --text2:       #475569;
  --text3:       #94a3b8;

  --shadow-sm:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:      0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
  --shadow-lg:   0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --shadow-xl:   0 20px 25px -5px rgba(0,0,0,.1), 0 10px 10px -5px rgba(0,0,0,.04);

  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   20px;

  --transition:  all .2s cubic-bezier(.4,0,.2,1);
  --sidebar-w:   260px;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ══════════════════════════════════════
   SIDEBAR
══════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  background: var(--text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.s-logo-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}

.s-logo-name {
  font-size: 14px;
  font-weight: 800;
  color: white;
  letter-spacing: .5px;
}

.s-logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,.45);
  font-weight: 500;
  margin-top: 1px;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: rgba(255,255,255,.6);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  text-align: left;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.9);
}

.nav-item.active {
  background: rgba(16,185,129,.15);
  color: var(--brand);
  font-weight: 600;
}

.nav-badge {
  position: absolute;
  right: 12px;
  background: var(--brand);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  min-width: 22px;
  text-align: center;
}

/* SIDEBAR USER */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), #059669);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}

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

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

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,.4);
  text-transform: capitalize;
}

.btn-logout {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}
.btn-logout:hover {
  background: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.3);
  color: #ef4444;
}

/* ══════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════ */
.admin-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 28px 32px 48px;
  min-height: 100vh;
}

/* TAB PANELS */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* PAGE HEADER */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.page-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}

.page-sub {
  font-size: 13.5px;
  color: var(--text3);
  margin-top: 4px;
}

/* ── BUTTONS ── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  font-family: inherit;
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16,185,129,.4);
}
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; transform: none; }

/* ══════════════════════════════════════
   TEAM GRID
══════════════════════════════════════ */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.team-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.team-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--team-color, var(--brand));
  border-radius: 16px 16px 0 0;
}
.team-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border2);
}

.team-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.team-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.team-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(0,0,0,.06);
}

.team-meta {
  font-size: 12px;
  color: var(--text3);
  display: flex;
  align-items: center;
  gap: 4px;
}

.team-actions {
  display: flex;
  gap: 8px;
}
.team-btn-sm {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.team-btn-sm:hover {
  background: var(--bg);
  border-color: var(--brand);
  color: var(--brand);
  transform: translateY(-2px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}
.team-btn-sm.danger:hover {
  background: #fff1f2;
  border-color: #fca5a5;
  color: #ef4444;
}
.team-btn-sm svg { width: 14px; height: 14px; }

/* ══════════════════════════════════════
   USER TABLE
══════════════════════════════════════ */
.table-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.admin-table thead tr {
  background: var(--surface2);
  border-bottom: 2px solid var(--border);
}

.admin-table th {
  padding: 13px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: .8px;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .15s;
}
.admin-table tbody tr:last-child { border-bottom: none; }
.admin-table tbody tr:hover { background: #f8fafc; }

.admin-table td {
  padding: 14px 16px;
  vertical-align: middle;
  font-size: 13.5px;
  color: var(--text);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-cell-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

.user-cell-name {
  font-weight: 600;
  font-size: 13.5px;
}

/* MULTI SELECT TEAMS */
.multi-select-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 100%;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: 200px;
  overflow-y: auto;
}

.team-checkbox-item {
  position: relative;
  cursor: pointer;
}
.team-checkbox-item input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}
.team-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  transition: all .2s;
  user-select: none;
}
.team-checkbox-label .t-dot {
  width: 8px; height: 8px; border-radius: 50%;
}
.team-checkbox-item input:checked + .team-checkbox-label {
  background: var(--brand-light);
  border-color: var(--brand);
  color: var(--brand-dark);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15);
}

.user-teams-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.user-team-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.user-cell-uid {
  font-size: 11px;
  color: var(--text3);
  font-family: 'Courier New', monospace;
}

.contact-email {
  font-size: 13px;
  color: var(--text2);
}

.contact-phone {
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}

/* ROLE BADGE */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.role-superadmin { background: #fef3c7; color: #92400e; }
.role-admin      { background: #dbeafe; color: #1d4ed8; }
.role-viewer     { background: #f0fdf4; color: #15803d; }

/* STATUS BADGE in admin */
.status-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}
.status-dot::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.active   { color: var(--brand-dark); }
.status-dot.active::before { background: var(--brand); box-shadow: 0 0 0 3px rgba(16,185,129,.2); }
.status-dot.inactive { color: var(--danger); }
.status-dot.inactive::before { background: var(--danger); }

.date-text {
  font-size: 12px;
  color: var(--text3);
}

/* USER ACTIONS */
.user-actions {
  display: flex;
  gap: 6px;
}

.act-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  color: var(--text3);
}
.act-btn:hover {
  background: var(--bg);
  border-color: var(--border2);
  color: var(--text);
}
.act-btn.role-act:hover   { background: #eff6ff; border-color: #93c5fd; color: var(--blue); }
.act-btn.toggle-act:hover { background: #fefce8; border-color: #fde68a; color: #b45309; }
.act-btn.delete-act:hover { background: #fff1f2; border-color: #fca5a5; color: var(--danger); }

/* ══════════════════════════════════════
   MODALS
══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  transform: translateY(20px) scale(.97);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
}

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

/* FORM */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .4px;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: var(--transition);
  resize: vertical;
  width: 100%;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}

.info-box {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 12.5px;
  color: #0c4a6e;
  line-height: 1.5;
}

/* COLOR PICKER */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text);
}

.color-custom {
  width: 28px;
  height: 28px;
  border: 1.5px solid var(--border);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
}
.color-custom::-webkit-color-swatch-wrapper { padding: 0; }
.color-custom::-webkit-color-swatch { border: none; border-radius: 50%; }

/* MODAL BUTTONS */
.btn-cancel-md {
  padding: 9px 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text2);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-cancel-md:hover { border-color: var(--border2); background: var(--bg); }

.btn-primary-md {
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-primary-md:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary-md:disabled { opacity: .6; cursor: not-allowed; transform: none; }

.btn-danger-md {
  padding: 9px 20px;
  background: var(--danger);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-danger-md:hover { background: var(--danger-dark); transform: translateY(-1px); }

/* ROLE OPTIONS */
.role-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-opt {
  cursor: pointer;
}
.role-opt input[type="radio"] {
  display: none;
}

.role-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  transition: var(--transition);
}
.role-card:hover {
  border-color: var(--brand);
  background: #f0fdf4;
}

.role-opt input:checked + .role-card {
  border-color: var(--brand);
  background: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(16,185,129,.12);
}

.role-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.role-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
}

.role-desc {
  font-size: 11.5px;
  color: var(--text3);
  margin-top: 1px;
}

/* EMPTY STATE */
.empty-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--text3);
  font-size: 13.5px;
}

/* ══════════════════════════════════════
   TOAST
══════════════════════════════════════ */
.admin-toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 18px;
  background: var(--text);
  color: white;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  max-width: 380px;
  pointer-events: all;
  animation: at-slideUp .3s cubic-bezier(.34,1.56,.64,1);
}
.admin-toast-item.success { background: var(--brand-dark); }
.admin-toast-item.error   { background: var(--danger); }
.admin-toast-item.warning { background: var(--warning); color: var(--text); }
.admin-toast-item.fade-out { animation: at-fadeOut .3s ease forwards; }

@keyframes at-slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes at-fadeOut {
  to { opacity: 0; transform: translateY(10px); }
}

/* ══════════════════════════════════════
   LOADING OVERLAY
══════════════════════════════════════ */
.admin-loading {
  position: fixed;
  inset: 0;
  background: rgba(241,245,249,.85);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}

.admin-loading .spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.admin-loading p {
  font-size: 14px;
  color: var(--text2);
  font-weight: 500;
}

/* ══════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    width: 220px;
  }
  .admin-main {
    margin-left: 220px;
    padding: 20px;
  }
  --sidebar-w: 220px;
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sidebar-logo { padding: 14px 16px; }
  .sidebar-nav {
    flex-direction: row;
    padding: 8px 12px;
    gap: 4px;
    flex-wrap: wrap;
  }
  .sidebar-user { padding: 12px 16px; }
  .admin-main {
    margin-left: 0;
    padding: 16px;
  }
  .page-header { flex-direction: column; }
  .team-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .admin-table { min-width: 700px; }
  .table-card { overflow-x: auto; }
}
