@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@500&display=swap');

:root {
  --bg: #0f172a;
  --bg2: #1e293b;
  --text: #f1f5f9;
  --accent: #3b82f6;
  --border: #334155;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #eab308;
  --radius: 14px;
  --shadow: 0 10px 40px rgba(0,0,0,0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Inter', system-ui, -apple-system, sans-serif; }

html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* ============ AUTH PAGE ============ */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  position: relative;
}

.auth-banner {
  background: linear-gradient(135deg, rgba(0,0,0,0.6), rgba(0,0,0,0.3)),
              url('/assets/banner.jpg') center/cover no-repeat;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 60px; position: relative; overflow: hidden;
  min-height: 400px;
}
.banner-overlay {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 30% 40%, rgba(59,130,246,0.35), transparent 60%);
  animation: pulse 6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.banner-content { position: relative; z-index: 2; }
.banner-content h1 {
  font-size: 3.5rem; font-weight: 800;
  background: linear-gradient(90deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; letter-spacing: -2px;
}
.banner-content p { color: #cbd5e1; font-size: 1.1rem; margin-top: 12px; }

.auth-panel {
  background: var(--bg2);
  padding: 60px 50px;
  display: flex; flex-direction: column; justify-content: center;
  position: relative;
}

.theme-switcher {
  position: absolute; top: 20px; right: 20px;
  display: flex; gap: 8px;
}
.theme-switcher button {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border);
  cursor: pointer; transition: transform 0.2s;
}
.theme-switcher button:hover { transform: scale(1.15); }
.theme-switcher button.active { border-color: var(--accent); transform: scale(1.2); }
[data-theme-btn="dark"] { background: #0f172a; }
[data-theme-btn="blue"] { background: #0c4a6e; }
[data-theme-btn="white"] { background: #ffffff; }
[data-theme-btn="yellow"] { background: #eab308; }
[data-theme-btn="red"] { background: #ef4444; }
[data-theme-btn="green"] { background: #22c55e; }

.auth-tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 28px; }
.auth-tabs button {
  flex: 1; padding: 12px; border: none; background: transparent;
  color: var(--text); cursor: pointer; border-radius: 8px;
  font-weight: 600; font-size: 0.95rem; transition: all 0.3s;
}
.auth-tabs button.active { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(59,130,246,0.3); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 0.85rem; font-weight: 500; opacity: 0.8; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 13px 16px; border-radius: 10px;
  border: 1.5px solid var(--border); background: var(--bg);
  color: var(--text); font-size: 0.95rem; transition: all 0.2s;
  font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.form-group input:disabled { opacity: 0.6; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 13px 22px; border-radius: 10px;
  border: none; font-weight: 600; font-size: 0.95rem;
  cursor: pointer; transition: all 0.25s; width: 100%;
  font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(59,130,246,0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-google { background: #fff; color: #1f2937; border: 1px solid #e5e7eb; }
.btn-google:hover { background: #f9fafb; }
.btn-github { background: #24292e; color: #fff; }
.btn-github:hover { background: #1b1f23; }

.divider { display: flex; align-items: center; gap: 12px; margin: 20px 0; opacity: 0.5; font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.oauth-row { display: flex; gap: 10px; }
.oauth-row .btn { flex: 1; }

/* ============ LOADING ============ */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  backdrop-filter: blur(6px); display: flex; flex-direction: column;
  align-items: center; justify-content: center; z-index: 9999;
  opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.loading-overlay.show { opacity: 1; pointer-events: all; }

.dots-loader { display: flex; gap: 10px; }
.dots-loader span {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  animation: dotBounce 1.2s infinite ease-in-out;
}
.dots-loader span:nth-child(2) { animation-delay: 0.15s; }
.dots-loader span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-18px); opacity: 1; }
}
.loading-overlay p { color: #fff; margin-top: 22px; font-weight: 500; letter-spacing: 0.5px; }

/* ============ POPUP SUCCESS ============ */
.popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 10000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.popup-overlay.show { opacity: 1; pointer-events: all; }

.popup-box {
  background: var(--bg2); padding: 40px 50px; border-radius: 20px;
  text-align: center; transform: scale(0.8); transition: transform 0.4s cubic-bezier(.5,1.8,.5,1);
  max-width: 90vw;
}
.popup-overlay.show .popup-box { transform: scale(1); }

.check-circle {
  width: 80px; height: 80px; margin: 0 auto 20px;
  border-radius: 50%; background: var(--success);
  display: flex; align-items: center; justify-content: center;
  animation: popIn 0.5s ease;
}
.check-circle svg { stroke-dasharray: 100; stroke-dashoffset: 100; animation: drawCheck 0.6s 0.3s ease forwards; }
@keyframes popIn { 0% { transform: scale(0); } 60% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes drawCheck { to { stroke-dashoffset: 0; } }
.popup-box h3 { font-size: 1.3rem; margin-bottom: 8px; }
.popup-box p { opacity: 0.8; font-size: 0.95rem; }

/* ============ DASHBOARD ============ */
.app-layout { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--bg2); border-right: 1px solid var(--border);
  padding: 20px; overflow-y: auto; position: sticky; top: 0; height: 100vh;
}
.brand-block {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg); border-radius: 12px; margin-bottom: 20px;
}
.brand-block img { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.brand-block .info { min-width: 0; }
.brand-block .info strong { display: block; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-block .info span {
  font-size: 0.7rem; padding: 2px 8px; border-radius: 20px;
  background: var(--accent); color: #fff; display: inline-block; margin-top: 4px;
}

.side-section { margin-bottom: 22px; }
.side-section h4 {
  font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px;
  opacity: 0.5; margin-bottom: 8px; padding-left: 8px;
}
.side-section a {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; color: var(--text); text-decoration: none;
  font-size: 0.9rem; transition: all 0.2s; cursor: pointer; margin-bottom: 2px;
  user-select: none;
}
.side-section a:hover { background: var(--bg); }
.side-section a.active { background: var(--accent); color: #fff; }
.side-section a svg { width: 18px; height: 18px; flex-shrink: 0; }

.main-area { padding: 28px 32px; overflow-x: hidden; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border);
}
.topbar h2 { font-size: 1.5rem; font-weight: 700; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; background: var(--bg2); border-radius: 40px;
}
.user-chip img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.user-chip span { font-size: 0.85rem; font-weight: 500; }

.panel-view { display: none; animation: fadeSlide 0.4s ease; }
.panel-view.active { display: block; }
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.alert-info {
  background: linear-gradient(135deg, rgba(59,130,246,0.15), rgba(59,130,246,0.05));
  border-left: 4px solid var(--accent); padding: 16px 20px;
  border-radius: 10px; margin-bottom: 20px;
}
.alert-info h3 { font-size: 1.1rem; margin-bottom: 6px; }
.alert-info p { opacity: 0.85; font-size: 0.9rem; line-height: 1.6; }
.alert-info a { color: var(--accent); }

.paket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin-bottom: 24px; }

.paket-card {
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 18px; cursor: pointer;
  transition: all 0.25s; position: relative;
}
.paket-card:hover { border-color: var(--accent); transform: translateY(-3px); }
.paket-card.selected {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(59,130,246,0.15), var(--bg2));
  box-shadow: 0 10px 30px rgba(59,130,246,0.2);
}
.paket-card.selected::after {
  content: '✓'; position: absolute; top: 12px; right: 12px;
  width: 26px; height: 26px; background: var(--accent); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; animation: popIn 0.3s ease;
}
.paket-card .icon {
  width: 42px; height: 42px; background: var(--bg);
  border-radius: 10px; display: flex; align-items: center; justify-content: center;
  margin-bottom: 12px; color: var(--accent);
}
.paket-card h4 { font-size: 1rem; margin-bottom: 4px; }
.paket-card p { font-size: 0.78rem; opacity: 0.65; }
.paket-card .price { margin-top: 10px; font-weight: 700; color: var(--accent); font-size: 1.05rem; }

.order-list { display: flex; flex-direction: column; gap: 10px; }
.order-item {
  background: var(--bg2); padding: 16px 20px; border-radius: 12px;
  display: flex; justify-content: space-between; align-items: center;
  border-left: 4px solid var(--border); transition: all 0.2s;
}
.order-item:hover { transform: translateX(4px); }
.order-item .info strong { font-size: 0.95rem; display: block; }
.order-item .info small { opacity: 0.6; font-size: 0.78rem; }

.badge {
  padding: 5px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.3px;
}
.badge.proses { background: rgba(234,179,8,0.15); color: var(--warning); }
.badge.sukses { background: rgba(34,197,94,0.15); color: var(--success); }
.badge.gagal { background: rgba(239,68,68,0.15); color: var(--danger); }

/* ============ CHAT ============ */
.chat-container { display: grid; grid-template-columns: 280px 1fr; gap: 16px; height: calc(100vh - 160px); }
.chat-sidebar { background: var(--bg2); border-radius: var(--radius); padding: 14px; overflow-y: auto; }
.chat-sidebar h4 { font-size: 0.75rem; opacity: 0.5; text-transform: uppercase; margin-bottom: 10px; padding-left: 8px; letter-spacing: 1.2px; }
.chat-user {
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  display: flex; align-items: center; gap: 10px; transition: all 0.2s;
}
.chat-user:hover { background: var(--bg); }
.chat-user.active { background: var(--accent); color: #fff; }
.chat-user .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.chat-user.active .avatar { background: rgba(255,255,255,0.25); }
.chat-user .meta strong { font-size: 0.88rem; display: block; }
.chat-user .meta small { font-size: 0.72rem; opacity: 0.7; }

.chat-main { background: var(--bg2); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.chat-header .status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 8px var(--success); display: inline-block; }

.chat-body { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 70%; padding: 10px 14px; border-radius: 14px; font-size: 0.9rem; word-wrap: break-word; animation: msgIn 0.3s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.msg.other { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.msg .time { font-size: 0.65rem; opacity: 0.7; margin-top: 4px; display: block; text-align: right; }

.chat-input-row { padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1; padding: 12px 16px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--text); font-family: inherit;
}
.chat-input-row input:focus { outline: none; border-color: var(--accent); }
.chat-input-row button {
  padding: 0 20px; background: var(--accent); color: #fff; border: none;
  border-radius: 10px; cursor: pointer; font-weight: 600;
}
.chat-input-row button:hover { transform: translateY(-1px); }

/* ============ ADMIN ============ */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg2); padding: 20px; border-radius: var(--radius);
  border-left: 4px solid var(--accent);
}
.stat-card h3 { font-size: 0.75rem; opacity: 0.6; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 6px; }
.stat-card .num { font-size: 1.8rem; font-weight: 800; }

.chart-box { background: var(--bg2); border-radius: var(--radius); padding: 20px; margin-bottom: 20px; }
.chart-box h3 { margin-bottom: 14px; font-size: 1rem; }

/* ============ MISC ============ */
.empty { text-align: center; padding: 40px 20px; opacity: 0.5; font-size: 0.9rem; }
.mobile-menu-btn { display: none; background: var(--bg2); border: none; color: var(--text); width: 40px; height: 40px; border-radius: 10px; cursor: pointer; font-size: 1.2rem; }
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--bg2);
  padding: 14px 20px; border-radius: 10px; box-shadow: var(--shadow);
  border-left: 4px solid var(--accent); z-index: 10001;
  animation: toastIn 0.3s ease; max-width: 340px;
  font-size: 0.9rem;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
@keyframes toastIn { from { transform: translateX(120%); } to { transform: translateX(0); } }

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-banner { min-height: 180px; padding: 30px; }
  .banner-content h1 { font-size: 2rem; }
  .auth-panel { padding: 40px 24px; }
  .app-layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -280px; top: 0; width: 260px; z-index: 100;
    transition: left 0.3s; box-shadow: var(--shadow);
  }
  .sidebar.open { left: 0; }
  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }
  .main-area { padding: 16px; }
  .chat-container { grid-template-columns: 1fr; height: auto; }
  .chat-main { height: 70vh; }
  .chat-sidebar { display: none; }
  .msg { max-width: 85%; }
}