/* ============================================================
   ACHUP Manage — Custom Stylesheet
   ============================================================ */

:root {
  --sidebar-bg:     #1a2b4a;
  --sidebar-text:   #b8c7d9;
  --sidebar-hover:  #243659;
  --sidebar-active: #e8a020;
  --accent:         #e8a020;
  --accent-dark:    #c98a10;
  --topbar-height:  56px;
  --sidebar-width:  240px;
}

/* ---- Layout ---- */
body {
  background: #f4f6f9;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 0.925rem;
}

#app-wrapper {
  min-height: 100vh;
}

/* ---- Sidebar ---- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  transition: width 0.25s ease, min-width 0.25s ease;
  z-index: 100;
}

#sidebar.collapsed {
  width: 60px;
  min-width: 60px;
}

#sidebar.collapsed .brand-text,
#sidebar.collapsed .sidebar-nav a span,
#sidebar.collapsed li a > *:not(.bi),
#sidebar.collapsed .sidebar-footer .logout-link span {
  display: none;
}

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

.brand-icon {
  font-size: 1.4rem;
  color: var(--accent);
  flex-shrink: 0;
}

.brand-text {
  font-size: 1.05rem;
  color: #fff;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.brand-text strong {
  color: var(--accent);
}

.sidebar-nav {
  list-style: none;
  padding: 12px 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  font-size: 0.9rem;
  white-space: nowrap;
}

.sidebar-nav li a:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.sidebar-nav li a.active {
  background: var(--sidebar-hover);
  color: var(--accent);
  border-left: 3px solid var(--accent);
}

.sidebar-nav li a .bi {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.sidebar-divider {
  border-top: 1px solid rgba(255,255,255,0.07);
  margin: 8px 0;
}

.sidebar-footer {
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  transition: color 0.15s;
}

.logout-link:hover {
  color: #ff6b6b;
}

/* ---- Main content ---- */
#main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 99;
  gap: 12px;
}

/* ---- Topbar global search ---- */
.topbar-search {
  flex: 1;
  max-width: 340px;
  min-width: 0;
}

.topbar-search-input {
  font-size: 0.84rem;
  border-color: #e2e8f0;
}

.topbar-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232,160,32,0.12);
}

/* Search results page */
.search-result-group { margin-bottom: 28px; }
.search-result-group h6 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #718096;
  font-weight: 700;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #edf2f7;
}
.search-hit {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 6px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.15s;
}
.search-hit:hover { box-shadow: 0 3px 10px rgba(0,0,0,0.1); }
.search-hit-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.search-hit-icon.type-client  { background:#dbeafe; color:#2563eb; }
.search-hit-icon.type-site    { background:#dcfce7; color:#16a34a; }
.search-hit-icon.type-domain  { background:#fef3c7; color:#d97706; }
.search-hit-icon.type-cpanel  { background:#ede9fe; color:#7c3aed; }
.search-hit-title { font-weight: 600; font-size: 0.9rem; color: #1a202c; }
.search-hit-sub   { font-size: 0.78rem; color: #718096; margin-top: 2px; }

/* ---- Hosting page ---- */
.cpanel-card { margin-bottom: 16px; }
.cpanel-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.cpanel-card .card-header:hover { background: #f8fafc; }
.cpanel-meta-badge {
  font-size: 0.75rem;
  background: rgba(26,43,74,0.08);
  color: var(--navy);
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.topbar-user {
  color: #4a5568;
  font-size: 0.88rem;
}

.btn-icon {
  background: none;
  border: none;
  color: #4a5568;
  padding: 4px 8px;
  cursor: pointer;
}

.btn-icon:hover {
  color: var(--accent);
}

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

/* ---- Page header ---- */
.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;
  font-weight: 600;
  color: #1a202c;
  margin: 0;
}

/* ---- Stat cards ---- */
.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border-left: 4px solid var(--accent);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card.stat-green  { border-left-color: #22c55e; }
.stat-card.stat-red    { border-left-color: #ef4444; }
.stat-card.stat-blue   { border-left-color: #3b82f6; }
.stat-card.stat-orange { border-left-color: var(--accent); }
.stat-card.stat-purple { border-left-color: #8b5cf6; }

.stat-icon {
  font-size: 2rem;
  opacity: 0.7;
}

.stat-card.stat-green  .stat-icon { color: #22c55e; }
.stat-card.stat-red    .stat-icon { color: #ef4444; }
.stat-card.stat-blue   .stat-icon { color: #3b82f6; }
.stat-card.stat-orange .stat-icon { color: var(--accent); }
.stat-card.stat-purple .stat-icon { color: #8b5cf6; }

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a202c;
  line-height: 1;
}

.stat-label {
  font-size: 0.78rem;
  color: #718096;
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Cards ---- */
.card {
  border: none;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #edf2f7;
  font-weight: 600;
  padding: 14px 18px;
}

/* ---- Tables ---- */
/*
 * .table-card wraps the scroll container.
 * The inner .table-scroll div handles horizontal overflow so the card's
 * border-radius is preserved while the table can scroll freely.
 */
.table-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  /* No overflow:hidden here — it would clip the inner scroll container
     and hide the scrollbar. Border-radius still applies to the card's
     own background; row hover backgrounds at corners are imperceptible. */
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;  /* iOS momentum scroll */
  width: 100%;
  border-radius: 10px;  /* round the scroll viewport itself */
}

.table-card .table {
  margin-bottom: 0;
  width: max-content;   /* natural column width — allows overflow */
  min-width: 100%;      /* still fills the card when space is available */
}

.table thead th {
  background: #f8fafc;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #718096;
  font-weight: 600;
  border-bottom: 1px solid #e2e8f0;
  padding: 11px 14px;
  white-space: nowrap;  /* headers never wrap — forces column to natural width */
}

.table tbody td {
  padding: 11px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #edf2f7;
  color: #2d3748;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.table-clickable tbody tr {
  cursor: pointer;
}

/* ---- Badges ---- */
.badge {
  font-weight: 500;
  letter-spacing: 0.02em;
}

/* ---- Forms ---- */
.form-card {
  background: #fff;
  border-radius: 10px;
  padding: 28px 32px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  max-width: 680px;
}

.form-label {
  font-weight: 500;
  font-size: 0.875rem;
  color: #4a5568;
}

.form-control, .form-select {
  font-size: 0.9rem;
  border-color: #e2e8f0;
}

.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(232, 160, 32, 0.15);
}

/* ---- Buttons ---- */
.btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover, .btn-primary:focus {
  background-color: var(--accent-dark);
  border-color: var(--accent-dark);
  color: #fff;
}

.btn-outline-primary {
  color: var(--accent);
  border-color: var(--accent);
}

.btn-outline-primary:hover {
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ---- Alert cards (domain expiry) ---- */
.alert-card {
  background: #fff;
  border-radius: 8px;
  padding: 14px 16px;
  border-left: 4px solid #f59e0b;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.alert-card.alert-critical {
  border-left-color: #ef4444;
}

/* ---- Filter bar ---- */
.filter-bar {
  background: #fff;
  border-radius: 10px;
  padding: 14px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.filter-bar .form-control,
.filter-bar .form-select {
  font-size: 0.85rem;
}

/* ---- Toast notification ---- */
.toast-wrapper {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
}

/* ---- Misc ---- */
.text-accent { color: var(--accent) !important; }
.fw-600 { font-weight: 600; }
.currency { font-variant-numeric: tabular-nums; }

/* ---- API key input ---- */
.api-key-input {
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  background: #f8fafc;
}

/* ---- Login page ---- */
.login-wrapper {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #fff;
  border-radius: 14px;
  padding: 40px 44px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

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

.login-logo .logo-icon {
  font-size: 2.5rem;
  color: var(--accent);
}

.login-logo h1 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--sidebar-bg);
  margin-top: 8px;
}

.login-logo h1 span {
  color: var(--accent);
}

/* ============================================================
   RESPONSIVE — Mobile / Tablet
   ============================================================ */

/* ---- Tablet and below (≤ 768px) ---- */
@media (max-width: 768px) {

  /* Sidebar: slide off-canvas */
  #sidebar {
    position: fixed;
    left: calc(-1 * var(--sidebar-width));
    top: 0;
    height: 100vh;
    z-index: 200;
    transition: left 0.25s ease;
    /* always full-width when open — never collapsed on mobile */
    width: var(--sidebar-width) !important;
    min-width: var(--sidebar-width) !important;
  }

  #sidebar.mobile-open {
    left: 0;
  }

  /* Main content fills full width when sidebar is off-screen */
  #main-content {
    width: 100%;
    min-width: 0;
  }

  /* Topbar: tighter padding */
  .topbar {
    padding: 0 12px;
    gap: 8px;
  }

  /* Search: let it grow to fill available space */
  .topbar-search-wrap {
    max-width: none;
    flex: 1;
    min-width: 0;
  }

  /* Page content */
  .page-content {
    padding: 14px;
  }

  /* Page header */
  .page-header h1 {
    font-size: 1.15rem;
  }

  /* Stat cards: smaller padding + fonts */
  .stat-card {
    padding: 14px 16px;
    gap: 12px;
  }

  .stat-value {
    font-size: 1.25rem;
  }

  .stat-icon {
    font-size: 1.6rem;
  }

  .stat-label {
    font-size: 0.73rem;
  }

  /* Form card: full width, tighter padding */
  .form-card {
    max-width: 100%;
    padding: 20px 18px;
  }

  /* Alert cards: stack content */
  .alert-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  /* Filter bar: tighter */
  .filter-bar {
    padding: 12px 14px;
    gap: 8px;
  }

  /* Text/search inputs fill full row; selects share space; buttons stay auto */
  .filter-bar > div[style*="flex"] {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }

  .filter-bar select {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }

  /* Hosting cPanel cards: narrower meta */
  .cpanel-meta-badge {
    font-size: 0.7rem;
  }

  /* Toast: top-center on mobile instead of top-right */
  .toast-wrapper {
    right: 10px;
    left: 10px;
    top: 64px;
  }
}

/* ---- Small phones (≤ 480px) ---- */
@media (max-width: 480px) {

  /* Hide username text, keep icon */
  .topbar-user .topbar-username {
    display: none;
  }

  /* Page content: minimal padding */
  .page-content {
    padding: 10px;
  }

  /* Page header */
  .page-header {
    margin-bottom: 16px;
  }

  .page-header h1 {
    font-size: 1rem;
  }

  /* Stat cards: minimal */
  .stat-card {
    padding: 12px;
    gap: 10px;
  }

  .stat-value {
    font-size: 1.1rem;
  }

  .stat-icon {
    font-size: 1.35rem;
  }

  /* Table: smaller text + tighter cells */
  .table thead th {
    padding: 8px 10px;
    font-size: 0.7rem;
  }

  .table tbody td {
    padding: 9px 10px;
    font-size: 0.82rem;
  }

  /* Topbar search: allow full shrink */
  .topbar-search-wrap {
    min-width: 0;
  }

  .topbar-search-input {
    font-size: 0.8rem;
  }

  /* Stack filter bar items */
  .filter-bar {
    padding: 10px 12px;
  }

  /* Buttons in page-header: smaller */
  .page-header .btn {
    font-size: 0.8rem;
    padding: 5px 10px;
  }

  /* Login card: full-width on tiny screens */
  .login-card {
    padding: 28px 20px;
    border-radius: 10px;
  }
}

/* ---- Sidebar overlay on mobile ---- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 150;
}

#sidebar-overlay.active {
  display: block;
}
