/* ============================================================
   PAYROLL GREEN — Tailwind-Based Green & White UI
   Primary: #16A34A  |  Dark: #15803D  |  Surface: #F8FAFC
   ============================================================ */

/* ============================================================
   CUSTOM SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #16A34A; }

/* ============================================================
   SIDEBAR MOBILE TRANSITION
   ============================================================ */
#sidebar {
  transition: transform 0.25s ease;
}

#sidebar-overlay {
  transition: opacity 0.25s ease;
}

/* ============================================================
   SIDEBAR NAV STYLES
   ============================================================ */
.nav-item-active {
  background-color: #16A34A;
  color: #fff;
  border-radius: 0.5rem;
}

.nav-item-active .nav-icon {
  color: #fff;
}

.nav-submenu {
  display: none;
  overflow: hidden;
}

.nav-submenu.open {
  display: block;
}

/* Sidebar search input */
#sidebar-search {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
}

#sidebar-search::placeholder {
  color: rgba(255,255,255,0.35);
}

#sidebar-search:focus {
  background: rgba(255,255,255,0.12);
  border-color: #16A34A;
  outline: none;
  box-shadow: 0 0 0 2px rgba(22,163,74,0.25);
}

/* ============================================================
   BADGE UTILITIES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-aktif      { background-color: #DCFCE7; color: #15803D; }
.badge-nonaktif   { background-color: #F1F5F9; color: #64748B; }
.badge-draft      { background-color: #F1F5F9; color: #64748B; }
.badge-diproses   { background-color: #DBEAFE; color: #1D4ED8; }
.badge-approved   { background-color: #DCFCE7; color: #15803D; }
.badge-locked     { background-color: #0F172A; color: #E2E8F0; }
.badge-gagal      { background-color: #FEE2E2; color: #B91C1C; }
.badge-tunjangan  { background-color: #DCFCE7; color: #15803D; }
.badge-potongan   { background-color: #FEE2E2; color: #B91C1C; }
.badge-nasional   { background-color: #DBEAFE; color: #1D4ED8; }
.badge-perusahaan { background-color: #EDE9FE; color: #6D28D9; }
.badge-warning    { background-color: #FEF9C3; color: #92400E; }
.badge-danger     { background-color: #FEE2E2; color: #B91C1C; }
.badge-success    { background-color: #DCFCE7; color: #15803D; }
.badge-info       { background-color: #DBEAFE; color: #1D4ED8; }
.badge-secondary  { background-color: #F1F5F9; color: #64748B; }

/* ============================================================
   DATATABLES OVERRIDE (Tailwind-Compatible)
   ============================================================ */

/* Wrapper */
.dataTables_wrapper {
  font-size: 0.8125rem;
  color: #334155;
}

/* Top controls (length + filter) */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dataTables_wrapper .dataTables_filter {
  justify-content: flex-end;
}

@media (max-width: 639px) {
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    justify-content: flex-start;
    width: 100%;
  }
}

/* Selects & inputs */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #CBD5E1;
  border-radius: 0.5rem;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  color: #334155;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.dataTables_wrapper .dataTables_length select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: #16A34A;
  outline: none;
  box-shadow: 0 0 0 2px rgba(22,163,74,0.2);
}

/* Info text */
.dataTables_wrapper .dataTables_info {
  font-size: 0.75rem;
  color: #64748B;
  padding-top: 0.625rem;
}

/* Pagination */
.dataTables_wrapper .dataTables_paginate {
  padding-top: 0.625rem;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #475569;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  margin: 0 1px;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: #F0FDF4;
  color: #16A34A;
  border-color: #86EFAC;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: #16A34A;
  color: #fff !important;
  border-color: #16A34A;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  color: #CBD5E1 !important;
  cursor: default;
  background: transparent;
}

/* Table base */
.dataTable {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
}

.dataTable thead th {
  background-color: #F8FAFC;
  color: #475569;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.625rem 1rem;
  border-bottom: 2px solid #E2E8F0;
  white-space: nowrap;
  cursor: pointer;
}

.dataTable thead th.sorting:after,
.dataTable thead th.sorting_asc:after,
.dataTable thead th.sorting_desc:after {
  opacity: 0.6;
}

.dataTable thead th.sorting_asc:after { content: " ↑"; color: #16A34A; opacity: 1; }
.dataTable thead th.sorting_desc:after { content: " ↓"; color: #16A34A; opacity: 1; }

.dataTable tbody tr {
  transition: background-color 0.1s;
}

.dataTable tbody tr:hover td {
  background-color: #F0FDF4;
}

.dataTable tbody td {
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
  color: #334155;
  font-size: 0.8125rem;
}

/* DataTables Responsive plugin override */
.dtr-details {
  width: 100%;
}

.dtr-details td {
  padding: 0.25rem 0;
}

.dtr-details .dtr-title {
  font-weight: 600;
  color: #64748B;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-right: 0.75rem;
  white-space: nowrap;
}

.dtr-details .dtr-data {
  color: #334155;
  font-size: 0.8125rem;
}

.dataTable tbody td.dtr-control::before {
  background-color: #16A34A !important;
  box-shadow: 0 0 0 2px #fff, 0 0 0 3px #16A34A;
}

/* ============================================================
   TABLE MOBILE CARD STACK
   ============================================================ */
.mobile-card-stack {
  display: none;
}

@media (max-width: 639px) {
  .mobile-card-stack {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .mobile-card-stack .m-card {
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 0.75rem;
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  }

  .mobile-card-stack .m-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.625rem;
  }

  .mobile-card-stack .m-card-title {
    font-weight: 600;
    color: #0F172A;
    font-size: 0.875rem;
  }

  .mobile-card-stack .m-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 0.5rem;
    font-size: 0.8rem;
  }

  .mobile-card-stack .m-card-label {
    color: #94A3B8;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .mobile-card-stack .m-card-value {
    color: #334155;
  }

  .mobile-card-stack .m-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #F1F5F9;
    flex-wrap: wrap;
  }
}

/* Table scroll wrapper */
.table-responsive-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  /* Shadow on right to indicate scrollability */
  background:
    linear-gradient(to right, white 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
    radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.07), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.07), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-color: white;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-position: 0 0, 100%, 0 0, 100%;
  background-attachment: local, local, scroll, scroll;
}

/* ============================================================
   IMPORT TABLE ROWS
   ============================================================ */
tr.import-error { background-color: #FFF5F5 !important; }
tr.import-error td { color: #7F1D1D !important; }
tr.import-ok { background-color: #F0FDF4 !important; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page-bg {
  min-height: 100vh;
  background: linear-gradient(145deg, #14532D 0%, #16A34A 50%, #22C55E 100%);
}

/* ============================================================
   SWEETALERT2 OVERRIDE
   ============================================================ */
.swal2-confirm {
  background-color: #16A34A !important;
  border-color: #16A34A !important;
}

.swal2-confirm:focus {
  box-shadow: 0 0 0 3px rgba(22,163,74,0.35) !important;
}

/* ============================================================
   AI ASSISTANT CHATBOX (Green Theme)
   ============================================================ */
.ai-assistant-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: #16A34A;
  color: #fff;
  font-size: 22px;
  box-shadow: 0 4px 16px rgba(22,163,74,0.35);
  z-index: 2030;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-assistant-fab:hover,
.ai-assistant-fab:focus {
  background: #15803D;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(22,163,74,0.4);
}

.ai-chatbox-panel {
  position: fixed;
  right: 22px;
  bottom: 90px;
  width: 380px;
  max-width: calc(100vw - 24px);
  max-height: calc(100vh - 120px);
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
  z-index: 2029;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.ai-chatbox-panel.is-hidden {
  display: none;
}

.ai-chatbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: linear-gradient(135deg, #16A34A, #15803D);
  color: #fff;
}

.ai-chatbox-title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
}

.ai-chatbox-actions {
  display: inline-flex;
  gap: 6px;
}

.ai-chatbox-btn {
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.15s;
}

.ai-chatbox-btn:hover,
.ai-chatbox-btn:focus {
  background: rgba(255, 255, 255, 0.32);
}

.ai-chatbox-body {
  min-height: 180px;
  overflow: hidden;
  max-height: inherit;
}

.ai-chat-shell {
  background: #fff;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 168px);
  max-height: 600px;
}

.ai-session-toolbar {
  background: #fff;
}

.ai-session-toolbar select {
  border: 1px solid #E2E8F0;
  border-radius: 0.5rem;
  font-size: 0.8125rem;
  color: #334155;
  padding: 0.3rem 0.5rem;
}

.ai-session-toolbar select:focus {
  border-color: #16A34A;
  outline: none;
  box-shadow: 0 0 0 2px rgba(22,163,74,0.2);
}

.ai-session-toolbar .btn-outline-secondary {
  border: 1px solid #E2E8F0;
  background: #fff;
  color: #475569;
  border-radius: 0.375rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-session-toolbar .btn-outline-secondary:hover {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #16A34A;
}

.ai-chat-messages {
  flex: 1;
  min-height: 140px;
  overflow-y: auto;
  background: #F8FAFC;
  padding: 0.75rem;
}

.ai-history-toolbar {
  background: #fff;
}

.ai-history-toolbar .btn {
  width: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.375rem;
  border: 1px solid #E2E8F0;
  background: #fff;
  color: #475569;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ai-history-toolbar .btn:hover {
  background: #F0FDF4;
  border-color: #86EFAC;
  color: #16A34A;
}

.ai-chat-input {
  padding: 0.75rem;
  border-top: 1px solid #F1F5F9;
  background: #fff;
}

.ai-chat-input .input-group {
  display: flex;
  gap: 0.5rem;
}

.ai-chat-input input {
  flex: 1;
  border: 1px solid #CBD5E1;
  border-radius: 0.5rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: #334155;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-chat-input input:focus {
  border-color: #16A34A;
  outline: none;
  box-shadow: 0 0 0 2px rgba(22,163,74,0.2);
}

.ai-chat-input .btn-send {
  background: #16A34A;
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.5rem 0.875rem;
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.ai-chat-input .btn-send:hover {
  background: #15803D;
}

.ai-chat-input .btn-send:disabled {
  background: #86EFAC;
  cursor: not-allowed;
}

.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 108px;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid #F1F5F9;
  background: #fff;
}

.ai-quick-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 9999px;
  border: 1px solid #86EFAC;
  background: #F0FDF4;
  color: #15803D;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.ai-quick-btn:hover {
  background: #16A34A;
  color: #fff;
  border-color: #16A34A;
}

.ai-msg {
  margin-bottom: 10px;
  display: flex;
}

.ai-msg-user {
  justify-content: flex-end;
}

.ai-msg-bot {
  justify-content: flex-start;
}

.ai-msg-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
}

.ai-msg-user .ai-msg-bubble {
  background: linear-gradient(135deg, #16A34A, #15803D);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg-bot .ai-msg-bubble {
  background: #fff;
  border: 1px solid #E2E8F0;
  color: #334155;
  border-bottom-left-radius: 4px;
}

.ai-msg-text {
  white-space: normal;
}

.ai-msg-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.ai-image-card {
  border: 1px solid #E2E8F0;
  background: #fff;
  border-radius: 10px;
  padding: 6px;
  text-align: left;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.ai-image-card:hover,
.ai-image-card:focus {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-color: #86EFAC;
  outline: none;
}

.ai-image-thumb {
  width: 100%;
  height: 88px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: #F1F5F9;
}

.ai-image-label {
  display: block;
  margin-top: 5px;
  font-size: 11px;
  font-weight: 600;
  color: #334155;
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.hide { display: none !important; }
.text-green { color: #16A34A !important; }
.bg-green   { background-color: #16A34A !important; }

/* Content header breadcrumb */
.breadcrumb-green a { color: #16A34A; font-size: 12.5px; }
.breadcrumb-green .active { color: #64748B; font-size: 12.5px; }

/* Empty state */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
}

.empty-state .icon {
  font-size: 3rem;
  color: #CBD5E1;
  margin-bottom: 0.75rem;
  display: block;
}

.empty-state p {
  font-size: 0.875rem;
  color: #64748B;
  margin: 0;
}

/* Form field with icon */
.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .left-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94A3B8;
  z-index: 3;
  pointer-events: none;
}

.input-icon-wrap .right-icon {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94A3B8;
  cursor: pointer;
  z-index: 3;
}

.input-icon-wrap input {
  padding-left: 2.25rem;
}

.input-icon-wrap input.has-right-icon {
  padding-right: 2.25rem;
}

/* ============================================================
   PRINT STYLES (Slip Gaji)
   ============================================================ */
@media print {
  #sidebar, nav, footer, .ai-assistant-fab, .ai-chatbox-panel,
  .no-print, button, .btn { display: none !important; }

  body { background: #fff !important; color: #000 !important; }

  .print-container {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 0;
  }
}

/* ============================================================
   MOBILE AI PANEL
   ============================================================ */
@media (max-width: 767.98px) {
  .ai-assistant-fab {
    right: 14px;
    bottom: 14px;
    width: 50px;
    height: 50px;
    font-size: 19px;
  }

  .ai-chatbox-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: 72px;
    max-height: calc(100vh - 88px);
    border-radius: 12px;
  }

  .ai-chat-shell {
    height: calc(100vh - 148px);
    max-height: none;
  }

  .ai-chatbox-header {
    padding: 8px 10px;
  }

  .ai-chatbox-title {
    font-size: 13px;
  }

  .ai-quick-actions {
    display: block;
    white-space: nowrap;
    max-height: none;
    padding: 8px 10px !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .ai-quick-btn {
    display: inline-flex;
    align-items: center;
    vertical-align: top;
    margin-right: 6px;
  }

  .ai-quick-btn:last-child {
    margin-right: 0;
  }

  .ai-chat-messages {
    min-height: 120px;
  }
}
