/* =========================
   GPD — Modern UI Enhanced
   ========================= */

:root {
  /* Colors - Modern Palette */
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --surface-hover: #f8fafc;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-light: #dbeafe;
  --primary-dark: #1e40af;

  --border: #e2e8f0;
  --border-light: #f1f5f9;
  
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;

  /* Design System */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Table Settings */
  --table-max-h: 65vh;
}

/* ===== Base Reset ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  padding: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== Messages / Banner ===== */
.msg {
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  line-height: 1.5;
  font-weight: 600;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ===== Form Controls ===== */
.txtlstcmbstyle,
input[type="text"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 400;
  outline: none;
  transition: var(--transition);
  line-height: 1.5;
}

.txtlstcmbstyle:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
  background: var(--surface);
}

.txtlstcmbstyle:hover,
input[type="text"]:hover,
input[type="password"]:hover,
input[type="email"]:hover,
select:hover,
textarea:hover {
  border-color: var(--text-muted);
}

.txtonlydisplay {
  border: 1px solid var(--border-light);
  background: var(--surface-2);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 14px;
}

.txtdisabled {
  color: var(--text-muted);
  border: 1px solid var(--border-light);
  background-color: var(--surface-2);
  border-radius: var(--radius-sm);
  cursor: not-allowed;
  opacity: 0.6;
}

/* ===== Buttons ===== */
.btnstyle,
button,
input[type="button"],
input[type="submit"],
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: var(--transition);
  white-space: nowrap;
  min-height: 36px;
}

.btnstyle:hover,
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover,
.btn:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btnstyle:active,
button:active,
input[type="button"]:active,
input[type="submit"]:active,
.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow);
}

.btnstyle:focus,
button:focus,
input[type="button"]:focus,
input[type="submit"]:focus,
.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.btn--secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
}

.btn--secondary:hover {
  background: var(--surface-hover);
  border-color: var(--primary);
}

/* ===== Typography ===== */
.headertext {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.subheadertext {
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 8px;
}

/* ===== Links ===== */
a,
a:active,
a:visited {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ==============================
   TABLES - Modern Design
   ============================== */

#gridDiv,
#inqGridDiv,
.regGridDiv {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  margin-bottom: 16px;
}

/* Table wrapper dengan scroll */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  max-height: var(--table-max-h);
}

#gridDiv,
#inqGridDiv,
.regGridDiv {
  overflow-x: auto;
  overflow-y: auto;
  max-height: var(--table-max-h);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

/* Header */
.thstyle,
thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 600;
  font-size: 13px;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

/* Cells */
.tdstyle,
tbody td {
  font-size: 13px;
  color: var(--text);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
}

/* Row States */
tbody tr {
  background: var(--surface);
  transition: background-color 0.15s ease;
}

tbody tr:nth-child(even) {
  background: var(--surface-hover);
}

tbody tr:hover {
  background: var(--primary-light);
}

tbody tr:hover td {
  background: transparent;
}

.trstyle-normal {
  background: var(--surface);
}

.trstyle-hover {
  background: var(--primary-light);
}

/* ==============================
   PAGINATION
   ============================== */
#pageNavDiv {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

#pageNavDiv a {
  color: var(--primary);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  font-weight: 500;
  min-width: 36px;
  text-align: center;
}

#pageNavDiv a:hover {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

#pageNavDiv .current-page {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  font-weight: 600;
}

/* ==============================
   FILTER / SEARCH BAR
   ============================== */

.filter-bar,
.filter-row,
.search-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.filter-bar > * {
  min-width: 0;
}

/* Label */
.filter-bar label,
.filter-row label,
.search-row label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  margin: 0;
}

/* Input fields - ukuran kompak */
.filter-bar .txtlstcmbstyle,
.filter-bar input[type="text"],
.filter-bar select,
.filter-row .txtlstcmbstyle,
.filter-row input[type="text"],
.filter-row select,
.search-row .txtlstcmbstyle,
.search-row input[type="text"],
.search-row select {
  flex: 1 1 180px;
  max-width: 300px;
  min-width: 120px;
}

/* Button dalam filter */
.filter-bar .btnstyle,
.filter-row .btnstyle,
.search-row .btnstyle {
  flex: 0 0 auto;
  padding: 8px 20px;
  min-height: 36px;
}

/* ==============================
   BADGES & STATUS
   ============================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.badge--ok {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}

.badge--warn {
  background: var(--warning-light);
  border-color: var(--warning);
  color: var(--warning);
}

.badge--danger {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

/* ==============================
   CARDS & CONTAINERS
   ============================== */

.card,
.form-container,
.content-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 16px;
  overflow: hidden;
}

/* ==============================
   RESPONSIVE DESIGN
   ============================== */

/* Tablet */
@media (max-width: 768px) {
  body {
    padding: 8px;
    font-size: 13px;
  }

  :root {
    --table-max-h: 60vh;
  }

  .filter-bar,
  .filter-row,
  .search-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .filter-bar .txtlstcmbstyle,
  .filter-bar input[type="text"],
  .filter-bar select,
  .filter-row .txtlstcmbstyle,
  .filter-row input[type="text"],
  .filter-row select,
  .search-row .txtlstcmbstyle,
  .search-row input[type="text"],
  .search-row select {
    max-width: 100%;
    flex: 1 1 100%;
  }

  .filter-bar .btnstyle,
  .filter-row .btnstyle,
  .search-row .btnstyle {
    width: 100%;
    max-width: none;
  }

  .thstyle,
  thead th,
  .tdstyle,
  tbody td {
    padding: 10px 12px;
    font-size: 12px;
  }

  .card,
  .form-container,
  .content-section {
    padding: 16px;
  }
}

/* Mobile */
@media (max-width: 480px) {
  body {
    padding: 6px;
    font-size: 13px;
  }

  :root {
    --table-max-h: 55vh;
    --radius: 8px;
    --radius-lg: 10px;
  }

  .msg {
    font-size: 13px;
    padding: 10px 12px;
  }

  .txtlstcmbstyle,
  input[type="text"],
  input[type="password"],
  select,
  textarea {
    padding: 8px 10px;
    font-size: 13px;
  }

  .btnstyle,
  button,
  input[type="button"],
  input[type="submit"],
  .btn {
    padding: 8px 12px;
    font-size: 13px;
    min-height: 40px;
  }

  .thstyle,
  thead th,
  .tdstyle,
  tbody td {
    padding: 8px 10px;
    font-size: 12px;
  }

  .card,
  .form-container,
  .content-section {
    padding: 12px;
    border-radius: var(--radius);
  }

  .filter-bar,
  .filter-row,
  .search-row {
    padding: 10px;
  }

  #pageNavDiv {
    justify-content: center;
  }

  #pageNavDiv a {
    padding: 6px 10px;
    font-size: 12px;
  }
}

/* Very small devices */
@media (max-width: 360px) {
  :root {
    --table-max-h: 50vh;
  }

  body {
    padding: 4px;
  }

  .thstyle,
  thead th,
  .tdstyle,
  tbody td {
    padding: 6px 8px;
    font-size: 11px;
  }
}

/* ==============================
   UTILITY CLASSES
   ============================== */

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

.fw-bold {
  font-weight: 600;
}

.mb-0 {
  margin-bottom: 0;
}

.mt-0 {
  margin-top: 0;
}

/* Loading State */
.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Smooth scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: var(--radius);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
/* ===== Mobile compact filter bar ===== */

/* Jadikan sel yang memuat txtFilter sebagai flex stack vertikal (tetap) */
td:has(#txtFilter){
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  white-space: normal !important;
}

/* --- Normal (desktop & tablet) --- */
#txtFilter{
  max-width: 100%;
  width: auto !important;  /* abaikan size="50" kalau sempit */
  min-width: 0;
  height: 38px;            /* kunci tinggi input */
  line-height: 38px;
  padding: 0 12px;
}
#btnFind.btnstyle{
  height: 38px;
  padding: 0 14px;
}
td:has(#txtFilter) select{
  height: 36px;
  padding: 0 8px;
  border-radius: 10px;
}

/* --- Khusus MOBILE: makin padat --- */
@media (max-width: 640px){
  td:has(#txtFilter){
    flex-direction: column;   /* stack vertikal */
    gap: 6px;
  }
  #txtFilter{
    height: 34px !important;  /* lebih rendah */
    line-height: 34px !important;
    padding: 0 10px !important;
  }
  td:has(#txtFilter) select{
    height: 34px !important;
    padding: 0 8px !important;
  }
  #btnFind.btnstyle{
    width: 100%;
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 10px;
  }

  /* Kurangi ruang kosong antar elemen/form di mobile */
  .msg{ padding: 8px 10px; }
  .card, .form-container, .content-section{ padding: 10px; }
}

/* Jika ada kemungkinan elemen berubah jadi textarea karena styling,
   pastikan textarea TIDAK dipakai untuk txtFilter di mobile */
textarea#txtFilter{
  height: 34px !important;
  max-height: 34px !important;
  resize: none !important;
  overflow: hidden !important;
}

/* === Mobile: tombol Find di bawah search bar === */
@media (max-width: 640px){
  /* Jadikan kolom filter bertumpuk vertikal */
  td:has(#txtFilter){
    display: flex;
    flex-direction: column;   /* urut vertikal */
    align-items: center;      /* center */
    gap: 8px;
    white-space: normal !important;
  }

  /* Urutan: (1) Select "Filter By", (2) Search, (3) Tombol Find */
  td:has(#txtFilter) select{ order: 1; width: 70%; max-width: 220px; height: 32px; }
  #txtFilter{ order: 2; width: 85% !important; max-width: 280px !important;
              height: 32px !important; line-height: 32px !important; padding: 0 10px !important; }
  #btnFind.btnstyle{
    order: 3; width: 70% !important; max-width: 200px !important;
    height: 34px !important; padding: 0 10px !important; font-size: 12px !important;
    border-radius: 10px;
  }
}

/* Extra kecil (≤360px): sedikit lebih kecil lagi */
@media (max-width: 360px){
  td:has(#txtFilter) select{ max-width: 200px; }
  #txtFilter{ max-width: 240px !important; }
  #btnFind.btnstyle{ max-width: 180px !important; }
}

/* ====== MOBILE MAIN EVENT CARD ====== */
.only-mobile { display: none; }

@media (max-width: 640px){
  .only-mobile { display: block; }
  .hide-on-mobile { display: none !important; }

  .me-card{
    background: #fff;
    border: 1px solid #E6E6E6;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,.06);
    margin-bottom: 12px;
  }

  .me-field{ display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
  .me-field label{
    font-size: 12px;
    color: #334155; /* ink-700 */
    font-weight: 600;
  }

  /* pakai styling input lama tapi rapikan ukuran mobile */
  .me-field .txtlstcmbstyle,
  .me-field textarea.txtlstcmbstyle,
  .me-field select.txtlstcmbstyle{
    width: 100% !important;
    max-width: 100%;
    min-height: 36px;
    padding: 6px 10px;
    border-radius: 10px;
    font-size: 13px;
  }
  .me-field textarea.txtlstcmbstyle{
    min-height: 70px;
    line-height: 1.35;
  }

  /* dua kolom jadi grid responsive */
  .me-row-2{
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* area autosuggest: pastikan dropdown selektor muat 100% */
  .me-suggest{ position: relative; display: block; }
  /* dropdown yang di-inject crtSugg(...) id-nya slcMyAc; isi lebar penuh + tampil di atas elemen lain */
  #slcMyAc{
    width: 100% !important;
    max-width: 100%;
    box-sizing: border-box;
    position: relative; /* biar tidak overflow */
    z-index: 20;
  }

  .me-actions{ display: flex; gap: 8px; }
  .me-actions .me-btn-primary{
    flex: 1 1 auto;
    height: 36px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    background-color: #B7E0FF;
    color: #333;
    border-left: 1px solid #E6E6E6;
    border-top: 1px solid #E6E6E6;
    border-right: 1px solid #666666;
    border-bottom: 1px solid #666666;
  }

  /* rapikan card grid bawaan agar tidak melebar di mobile */
  .regGridDiv{
    width: 100% !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .regGridDiv table{
    width: 100%;
    min-width: 640px; /* tabel tetap bisa discroll secara horizontal jika kolom banyak */
    border-collapse: separate;
    border-spacing: 1px;
  }

  /* paging tetap di bawah tabel */
  #pageNavDiv{ margin-top: 8px; }

  /* kompakkan banner msg */
  .msg{
    font-size: 12px;
    padding: 8px 10px;
    min-height: 0;
  }
}

/* Sedikit sentuhan tablet (biar 2 kolom muncul di >640px) */
@media (min-width: 641px) and (max-width: 900px){
  .me-row-2{
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
}
/* Tombol fallback untuk mobile */
.mobile-actions { display: none; margin: 8px 0 12px; }
.mobile-actions .btn-mobile{
  display: inline-block;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow);
  border:1px solid var(--border);
}

@media (max-width: 900px){
  .mobile-actions{ display: block; }
}

