/* Kadir Kasım Admin — Design System & Custom Styles */
:root {
  --bg-app: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #f1f5f9;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --teal-primary: #0d9488;
  --teal-hover: #0f766e;
  --teal-active: #115e59;
  --teal-tint: #f0fdfa;
  --teal-pill: #e6f4f2;
  --amber-bg: #fef3c7;
  --amber-text: #92400e;
  --amber-dot: #f59e0b;
  --green-bg: #dcfce7;
  --green-text: #15803d;
  --red-bg: #fee2e2;
  --red-text: #b91c1c;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-drawer: -4px 0 25px rgba(15, 23, 42, 0.12);
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Permanent Demo Watermark Bar */
.demo-banner {
  background: #0f172a;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.demo-banner-badge {
  background: #f59e0b;
  color: #0f172a;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-right: 8px;
}
.demo-banner a {
  color: #5eead4;
  text-decoration: none;
}

/* Header */
.app-header {
  height: 64px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: var(--teal-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  box-shadow: 0 2px 4px rgba(13, 148, 136, 0.25);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
}
.brand-subtitle {
  font-size: 14px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.env-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  border: 1px solid transparent;
}
.env-pill.staging {
  background-color: var(--amber-bg);
  color: var(--amber-text);
  border-color: #fde68a;
}
.env-pill.staging .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--amber-dot);
}

.env-pill.production {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.75;
}
.env-pill.production .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--text-light);
}

.user-profile-badge {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

/* App Layout Grid */
.admin-container {
  display: flex;
  flex: 1;
}

.sidebar {
  width: 230px;
  min-width: 230px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border-color);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}
.sidebar-back-link:hover {
  color: var(--text-main);
  background-color: var(--bg-subtle);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  transition: all 0.15s ease;
}
.sidebar-nav-item:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}
.sidebar-nav-item.active {
  background-color: var(--teal-pill);
  color: var(--teal-hover);
  font-weight: 600;
}
.sidebar-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}

/* Page Titles */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}
.page-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}
.page-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Filter and Action Bars */
.toolbar-tabs {
  display: flex;
  align-items: center;
  gap: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
}
.toolbar-tab {
  padding: 10px 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
}
.toolbar-tab:hover {
  color: var(--text-main);
}
.toolbar-tab.active {
  color: var(--teal-hover);
  font-weight: 600;
}
.toolbar-tab.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--teal-primary);
  border-radius: 2px 2px 0 0;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-light);
  pointer-events: none;
}
.search-input {
  width: 100%;
  height: 40px;
  padding: 8px 14px 8px 38px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-input:focus {
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.select-filter {
  height: 40px;
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2364748b'%3e%3cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
}
.select-filter:focus {
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}
.btn-primary {
  background-color: var(--teal-primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--teal-hover);
}
.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: #334155;
}
.btn-secondary:hover {
  background-color: var(--bg-subtle);
  border-color: #cbd5e1;
}
.btn-disabled {
  background-color: #f1f5f9;
  border-color: #e2e8f0;
  color: #94a3b8;
  cursor: not-allowed;
}
.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* Tables */
.card-table-wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  margin-bottom: 24px;
}

.table-custom {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
.table-custom th {
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background-color: #fafbfc;
  border-bottom: 1px solid var(--border-color);
}
.table-custom td {
  padding: 14px 18px;
  font-size: 14px;
  color: var(--text-main);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table-custom tr:last-child td {
  border-bottom: none;
}
.table-custom tbody tr {
  transition: background-color 0.12s ease;
}
.table-custom tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 9999px;
  white-space: nowrap;
}
.badge-green {
  background-color: var(--green-bg);
  color: var(--green-text);
}
.badge-amber {
  background-color: var(--amber-bg);
  color: var(--amber-text);
}
.badge-red {
  background-color: var(--red-bg);
  color: var(--red-text);
}
.badge-gray {
  background-color: var(--bg-subtle);
  color: var(--text-muted);
}
.badge-blue {
  background-color: #e0f2fe;
  color: #0369a1;
}

/* Notices and Callouts */
.callout-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: #f0fdfa;
  border: 1px solid #ccfbf1;
  border-radius: var(--radius-md);
  font-size: 13px;
  color: #0f766e;
  margin-top: 16px;
}
.callout-box svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* Bottom Draft Bar */
.draft-floating-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fffbeb;
  border: 1px solid #fef3c7;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  margin-top: 20px;
}
.draft-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.draft-icon {
  color: #b45309;
}
.draft-title {
  font-size: 14px;
  font-weight: 700;
  color: #92400e;
}
.draft-subtitle {
  font-size: 13px;
  color: #b45309;
}

/* Drawer / Slide-Over */
.drawer-backdrop,
.drawer-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.drawer-backdrop.active,
.drawer-backdrop.open,
.drawer-overlay.active,
.drawer-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background-color: var(--bg-surface);
  box-shadow: var(--shadow-drawer);
  z-index: 101;
  transform: translateX(100%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.25s;
  display: flex;
  flex-direction: column;
}
.drawer.active,
.drawer.open {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
}

.drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}
.drawer-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}
.drawer-close:hover {
  background-color: var(--bg-subtle);
  color: var(--text-main);
}

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

.drawer-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  background-color: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Forms in Drawer */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
  background-color: var(--bg-surface);
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.checkbox-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #ffffff;
  cursor: pointer;
}
.checkbox-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal-primary);
  margin-top: 2px;
  cursor: pointer;
}
.checkbox-label-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}
.checkbox-label-desc {
  font-size: 12px;
  color: var(--text-muted);
}

/* Comparison Cards (Before / After) */
.comparison-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}
.comparison-box {
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background-color: #fafbfc;
}
.comparison-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.comparison-content {
  font-size: 13px;
  color: var(--text-main);
  font-weight: 500;
}

/* Product Selection Cards */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 24px;
  margin-top: 24px;
}
.product-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
}
.product-card.active-card {
  border-color: #5eead4;
}
.product-header {
  display: flex;
  align-items: center;
  gap: 16px;
}
.product-icon-large {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  color: #fff;
}
.product-info-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
}
.product-info-cat {
  font-size: 13px;
  color: var(--text-muted);
}
.product-status-tag {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Auth / Login Page Cards */
.login-page-wrapper {
  min-height: calc(100vh - 40px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  text-align: center;
}
.login-brand-logo {
  width: 48px;
  height: 48px;
  background-color: var(--bg-subtle);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #0f172a;
  margin: 0 auto 16px;
}
.login-domain-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.six-digit-inputs {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 0;
}
.digit-box {
  width: 48px;
  height: 52px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  outline: none;
}
.digit-box:focus {
  border-color: var(--teal-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

/* Modal Popover */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.modal-overlay.active,
.modal-overlay.open,
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-box {
  background-color: #ffffff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Accessible Focus States */
:focus-visible {
  outline: 2px solid var(--teal-primary);
  outline-offset: 2px;
}

/* Player Balances Grid - Valid track definitions */
.player-balances-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
  align-items: stretch;
}
.balance-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
}
.balance-action-card {
  display: flex;
  align-items: stretch;
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .admin-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 12px 20px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
  .sidebar-back-link {
    margin-bottom: 0;
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }
  .main-content {
    padding: 20px 16px;
  }
}

@media (max-width: 768px) {
  .app-header {
    height: auto;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }
  .header-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  .page-header {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }
  .toolbar-tabs {
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px;
  }
  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .card-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-custom {
    min-width: 640px;
  }
  .drawer {
    width: 100%;
    max-width: 100vw;
  }
  .comparison-container {
    grid-template-columns: 1fr;
  }
  .products-grid {
    grid-template-columns: 1fr;
  }
}

/* ADMIN103: Draft table row state */
tr.draft-row {
  background-color: #fffbeb;
}
tr.draft-row:hover {
  background-color: #fef3c7 !important;
}
