/* ============================================================
   PRABUWEB AFILIASI - STYLESHEET UTAMA
   ============================================================ */

:root {
  --primary:        #1A73E8;
  --primary-hover:  #1557B0;
  --primary-light:  #E8F0FE;
  --success:        #0D904F;
  --success-light:  #E6F4EE;
  --danger:         #DC3545;
  --danger-light:   #FCE8EA;
  --warning:        #F0AD4E;
  --warning-light:  #FFF3CD;
  --bg:             #F5F7FA;
  --card:           #FFFFFF;
  --text:           #1A1A2E;
  --text-muted:     #6B7280;
  --border:         #E5E7EB;
  --sidebar-w:      250px;
  --radius:         12px;
  --radius-sm:      8px;
  --shadow:         0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg:      0 8px 24px rgba(0,0,0,0.12);
  --font:           -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
   LAYOUT UTAMA
   ============================================================ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #1A1A2E;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 16px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-brand span { color: var(--primary); }

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

.sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  color: rgba(255,255,255,0.7);
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.sidebar-menu li a:hover,
.sidebar-menu li.active a {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-left-color: var(--primary);
}

.sidebar-menu li a .icon { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* ---- MAIN CONTENT ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- TOP HEADER ---- */
.top-header {
  background: var(--card);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

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

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-user {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---- PAGE CONTENT ---- */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 24px;
  color: var(--text);
}

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

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

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

/* ---- STAT CARDS ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.stat-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--primary-light); }
.stat-icon.green  { background: var(--success-light); }
.stat-icon.yellow { background: var(--warning-light); }
.stat-icon.red    { background: var(--danger-light); }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--text); line-height: 1.2; word-break: break-all; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: #fff; }
.btn-primary:hover   { background: var(--primary-hover); color: #fff; }
.btn-success   { background: var(--success);   color: #fff; }
.btn-success:hover   { background: #0a7340; color: #fff; }
.btn-danger    { background: var(--danger);    color: #fff; }
.btn-danger:hover    { background: #b82d3a; color: #fff; }
.btn-warning   { background: var(--warning);   color: #fff; }
.btn-warning:hover   { background: #d9922e; color: #fff; }
.btn-secondary { background: #6B7280; color: #fff; }
.btn-secondary:hover { background: #4b5563; color: #fff; }
.btn-outline   { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover   { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: var(--font);
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

.form-control[readonly] { background: var(--bg); color: var(--text-muted); }
.form-control.is-invalid { border-color: var(--danger); }

textarea.form-control { resize: vertical; min-height: 90px; }

.input-group { position: relative; display: flex; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); flex: 1; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; flex-shrink: 0; }

.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 42px; }
.pw-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  padding: 0;
  line-height: 1;
}

.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 16px; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  background: var(--bg);
  padding: 11px 14px;
  text-align: left;
  font-weight: 700;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:hover { background: #FAFBFF; }
tbody tr:last-child td { border-bottom: none; }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 0;
  font-size: 13px;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-warning { background: var(--warning-light); color: #856404; }
.badge-muted   { background: var(--border);        color: var(--text-muted); }

/* ============================================================
   ALERT MESSAGES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: var(--success-light); color: #0a5c34; border-left: 4px solid var(--success); }
.alert-danger  { background: var(--danger-light);  color: #721c24; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #856404; border-left: 4px solid var(--warning); }
.alert-info    { background: var(--primary-light); color: #0d47a1; border-left: 4px solid var(--primary); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active { display: flex; }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  line-height: 1;
}

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

/* ============================================================
   NOTIFIKASI DROPDOWN
   ============================================================ */
.notif-wrap { position: relative; }

.notif-btn {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  position: relative;
  padding: 4px;
  color: var(--text);
  line-height: 1;
}

.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 320px;
  z-index: 200;
}

.notif-dropdown.open { display: block; }

.notif-header {
  padding: 14px 16px 10px;
  font-weight: 700;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.notif-list { max-height: 300px; overflow-y: auto; }

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text);
}

.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: var(--primary-light); }
.notif-item p { margin: 0; line-height: 1.5; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.notif-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-page.admin-theme { background: #1A1A2E; }
.login-page.aff-theme   { background: var(--bg); }

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

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

.login-brand h1 {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--text);
}

.login-brand h1 span { color: var(--primary); }
.login-brand p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   INSTALL PAGE
   ============================================================ */
.install-step {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.install-step.ok   { background: var(--success-light); color: #0a5c34; }
.install-step.err  { background: var(--danger-light);  color: #721c24; }
.install-step.info { background: var(--primary-light); color: #0d47a1; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.page-link {
  padding: 6px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  text-decoration: none;
  transition: all 0.2s;
}

.page-link:hover, .page-link.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box {
  position: relative;
  max-width: 280px;
}

.search-box .form-control { padding-left: 36px; }
.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
}

/* ============================================================
   DETAIL ROW (key-value)
   ============================================================ */
.detail-row {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}

.detail-row:last-child { border-bottom: none; }
.detail-key { width: 150px; flex-shrink: 0; color: var(--text-muted); font-weight: 500; }
.detail-val { flex: 1; font-weight: 600; color: var(--text); word-break: break-all; }

/* ============================================================
   LOADING SPINNER
   ============================================================ */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ============================================================
   MOBILE RESPONSIVE
   ============================================================ */

/* Bottom Nav (mobile only) */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #1A1A2E;
  z-index: 100;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.bottom-nav-inner {
  display: flex;
  justify-content: space-around;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 4px;
  color: rgba(255,255,255,0.5);
  font-size: 10px;
  text-decoration: none;
  transition: color 0.2s;
  gap: 3px;
}

.bottom-nav-item .bnav-icon { font-size: 18px; line-height: 1; }
.bottom-nav-item.active, .bottom-nav-item:hover { color: #fff; }

/* Mobile sidebar toggle */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--text);
  padding: 4px;
}

/* ---- Breakpoints ---- */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
  }

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

  .main-content {
    margin-left: 0;
  }

  .sidebar-toggle { display: block; }

  .bottom-nav { display: block; }

  .page-content {
    padding: 16px;
    padding-bottom: 80px; /* untuk bottom nav */
  }

  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .stat-value { font-size: 16px; }

  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }

  .modal-box {
    max-width: 100%;
    margin: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
  }

  .modal-overlay { align-items: flex-end; padding: 0; }

  .login-card { padding: 28px 20px; }

  .notif-dropdown { width: 280px; right: -80px; }

  .top-header { padding: 12px 16px; }
  .header-user { display: none; }
}

@media (max-width: 400px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger);  }
.text-warning { color: var(--warning); }
.text-muted   { color: var(--text-muted); }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.fw-bold      { font-weight: 700; }
.fw-semibold  { font-weight: 600; }
.d-flex       { display: flex; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.hidden { display: none !important; }
