/* ============================================================
   X Network Admin Panel
   ============================================================ */

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

:root {
  --blue:       #0c2b6f;
  --blue-mid:   #122e7a;
  --blue-dark:  #0b1b47;
  --green:      #00a74f;
  --amber:      #e8a000;
  --red:        #d63031;
  --text:       #0a0a0a;
  --text-muted: #5f6b76;
  --border:     #dfe6ef;
  --bg:         #f0f4fb;
  --bg-faint:   #f7f9fc;
  --white:      #ffffff;
  --radius:     10px;
  --shadow-sm:  0 2px 8px rgba(12,43,111,0.07);
  --shadow-md:  0 6px 20px rgba(12,43,111,0.11);
}

html { font-size: 16px; }

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

h1, h2, h3, h4 { font-family: 'Archivo Black', sans-serif; line-height: 1.2; }

/* ── Login ───────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-logo { height: 64px; margin-bottom: 16px; }
.login-card h1 { font-size: 1.3rem; color: var(--blue-dark); margin-bottom: 4px; }
.login-sub { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 24px; }

.alert {
  background: rgba(214,48,49,0.08);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 14px;
  text-align: left;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
  flex: 1;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
  padding: 10px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s;
  background: var(--white);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(12,43,111,0.09);
}

.field textarea { resize: vertical; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.btn-google:hover { border-color: #4285F4; box-shadow: 0 2px 8px rgba(66,133,244,0.15); }

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

.input-with-btn input { flex: 1; }

.btn-generate {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--blue);
  background: var(--white);
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-generate:hover { background: var(--blue); color: var(--white); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  background: var(--blue);
  color: var(--white);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.18s;
  white-space: nowrap;
}

.btn-primary:hover { background: var(--blue-mid); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.full { width: 100%; justify-content: center; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }

.btn-text {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  padding: 6px 0;
  margin-bottom: 12px;
}

.btn-text:hover { text-decoration: underline; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--red);
  background: rgba(214,48,49,0.06);
  color: var(--red);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 7px;
}

.btn-resolve {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 7px;
  border: 1.5px solid var(--green);
  background: rgba(0,167,79,0.06);
  color: var(--green);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-resolve:hover { background: var(--green); color: var(--white); }

/* ── Admin layout ────────────────────────────────────────── */
#view-admin {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 240px;
  background: var(--blue-dark);
  color: var(--white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo { height: 36px; }
.sidebar-title {
  font-family: 'Archivo Black', sans-serif;
  font-size: 0.95rem;
  opacity: 0.9;
}

.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-footer { padding: 10px; border-top: 1px solid rgba(255,255,255,0.08); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: none;
  color: rgba(255,255,255,0.65);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.15s;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--white); }
.nav-item.active { background: rgba(255,255,255,0.12); color: var(--white); }
.nav-item.logout { color: rgba(255,100,100,0.8); }
.nav-item.logout:hover { background: rgba(255,100,100,0.12); color: #ff6b6b; }

/* Main content */
#main-content {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
  min-height: 100vh;
}

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

.page-header h1 { font-size: 1.4rem; color: var(--blue-dark); }
.page-sub { font-size: 0.85rem; color: var(--text-muted); }

/* Stat cards */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--blue);
}

.stat-card.warn { border-left-color: var(--amber); }
.stat-card.danger { border-left-color: var(--red); }

.stat-val {
  font-family: 'Archivo Black', sans-serif;
  font-size: 1.6rem;
  color: var(--blue-dark);
  margin-bottom: 2px;
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.card h3 { font-size: 1.05rem; color: var(--blue-dark); margin-bottom: 16px; }
.card h4 { font-size: 0.88rem; color: var(--blue-dark); }

.help-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.help-text code {
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.78rem;
}

.form-row {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.form-row > .field { min-width: 200px; }

.account-row { align-items: flex-end; }

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.form-status {
  margin-top: 12px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-weight: 600;
}

.form-status.success { background: rgba(0,167,79,0.08); color: var(--green); }
.form-status.error { background: rgba(214,48,49,0.08); color: var(--red); }

/* Loading / empty */
.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── List items ──────────────────────────────────────────── */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-wrap: wrap;
}

.list-item:last-child { border-bottom: none; }

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

.list-item-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--blue-dark);
  margin-bottom: 2px;
}

.list-item-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.list-item-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-active { background: rgba(214,48,49,0.1); color: var(--red); }
.badge-resolved { background: rgba(0,167,79,0.1); color: var(--green); }
.badge-open { background: rgba(232,160,0,0.12); color: #9a6c00; }

/* Ticket filters */
.ticket-filters { display: flex; gap: 6px; }

.filter-pill {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--white);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-pill:hover { border-color: var(--blue); color: var(--blue); }
.filter-pill.active { background: var(--blue); border-color: var(--blue); color: var(--white); }

/* Ticket detail */
.ticket-detail {
  background: var(--bg-faint);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
}

.ticket-detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.ticket-detail-label {
  font-weight: 700;
  color: var(--text-muted);
  min-width: 100px;
  flex-shrink: 0;
}

/* ── Permissions ─────────────────────────────────────────── */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.perm-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
}

.perm-item:hover { border-color: var(--blue); }
.perm-item:has(input:checked) { border-color: var(--blue); background: rgba(12,43,111,0.04); }
.perm-item input { cursor: pointer; }

.perm-tag {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(12,43,111,0.06);
  color: var(--blue);
  margin: 1px 2px;
}

.perm-tag.super {
  background: rgba(0,167,79,0.1);
  color: var(--green);
}

.nav-locked {
  opacity: 0.35;
  pointer-events: none;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    width: 100%;
    height: auto;
    bottom: 0;
    top: auto;
    flex-direction: row;
    z-index: 200;
  }

  .sidebar-brand { display: none; }
  .sidebar-footer { display: none; }

  .sidebar-nav {
    flex-direction: row;
    padding: 6px 8px;
    width: 100%;
    justify-content: space-around;
    gap: 0;
  }

  .nav-item {
    flex-direction: column;
    gap: 2px;
    font-size: 0.68rem;
    padding: 8px 4px;
    text-align: center;
  }

  #main-content {
    margin-left: 0;
    padding: 20px 16px 80px;
  }

  .form-row { flex-direction: column; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}
