/* ============================================================
   PAYROLL JIG — Flat Modern Red UI
   Primary: #E53935  |  Dark: #C62828  |  Surface: #F4F6F9
   ============================================================ */
:root {
  --red:        #E53935;
  --red-dark:   #C62828;
  --red-deeper: #B71C1C;
  --red-soft:   #FFEBEE;
  --red-border: #EF9A9A;
  --sidebar-bg: #1C1C2E;
  --sidebar-hover: rgba(229, 57, 53, 0.15);
  --sidebar-active: rgba(229, 57, 53, 0.25);
  --surface:    #F4F6F9;
  --card-bg:    #FFFFFF;
  --border:     #E8ECF0;
  --text:       #1A1A2E;
  --text-muted: #6B7280;
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.10);
}

/* ============================================================
   BASE
   ============================================================ */
body {
  font-family: 'Source Sans 3', 'Source Sans Pro', sans-serif;
  background: var(--surface);
  color: var(--text);
}
a { color: var(--red); }
a:hover { color: var(--red-dark); text-decoration: none; }

/* ============================================================
   TOPBAR / NAVBAR
   ============================================================ */
.main-header.navbar {
  background: #fff !important;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  min-height: 56px;
}
.main-header .nav-link { color: var(--text) !important; font-size: 13.5px; }
.main-header .nav-link:hover { color: var(--red) !important; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.main-sidebar {
  background: var(--sidebar-bg) !important;
  box-shadow: 2px 0 12px rgba(0,0,0,0.15);
}
.brand-link {
  background: var(--red) !important;
  border-bottom: none !important;
  padding: 14px 16px;
}
.brand-link .brand-text {
  color: #fff !important;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.brand-link:hover { background: var(--red-dark) !important; }

.sidebar .form-control-sidebar {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  border-radius: 6px;
  font-size: 12.5px;
}
.sidebar .form-control-sidebar::placeholder { color: rgba(255,255,255,0.4); }
.sidebar .form-control-sidebar:focus {
  background: rgba(255,255,255,0.12);
  border-color: var(--red);
  outline: none;
  box-shadow: none;
}
.sidebar .btn-sidebar {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-left: none;
  color: rgba(255,255,255,0.5);
  border-radius: 0 6px 6px 0;
}
.nav-sidebar .nav-header {
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  padding: 18px 16px 8px;
  text-align: center;
  display: block;
}
.nav-sidebar .nav-item > .nav-link {
  color: rgba(255,255,255,0.7) !important;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 0;
  margin: 0;
  transition: all 0.15s ease;
  position: relative;
}
/* Non-parent link hover */
.nav-sidebar .nav-item:not(.has-treeview) > .nav-link:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
  padding-left: 18px;
  margin-left: 8px;
  border-radius: 4px;
}
/* Parent menu - regular (not expanded) */
.nav-sidebar .nav-item.has-treeview > .nav-link {
  margin: 2px 0;
  padding: 8px 16px;
  border-radius: 0;
}
/* Parent menu - active/expanded */
.nav-sidebar .nav-item.has-treeview.menu-open > .nav-link,
.nav-sidebar .nav-item.has-treeview > .nav-link.active {
  background: var(--red) !important;
  color: #fff !important;
  margin: 0;
  padding: 8px 16px;
  border-radius: 0;
  font-weight: 600;
  width: 100%;
  box-sizing: border-box;
}
/* Regular link active (not parent) */
.nav-sidebar .nav-item:not(.has-treeview) > .nav-link.active {
  background: transparent !important;
  color: #fff !important;
  border-left: 3px solid var(--red);
  padding-left: 13px;
  margin: 2px 8px;
  border-radius: 4px;
}
.nav-sidebar .nav-item > .nav-link .nav-icon {
  color: rgba(255,255,255,0.5);
  width: 18px;
  font-size: 13px;
  margin-right: 8px;
}
.nav-sidebar .nav-item > .nav-link.active .nav-icon { color: #fff; }
.nav-sidebar .nav-item > .nav-link:hover .nav-icon {
  color: rgba(255,255,255,0.8);
}
/* Arrow toggle for parent menu */
.nav-sidebar .nav-item.has-treeview > .nav-link > p > .right.fa-angle-left {
  float: right;
  color: rgba(255,255,255,0.7);
  transition: transform 0.3s ease;
}
.nav-sidebar .nav-item.has-treeview.menu-open > .nav-link > p > .right.fa-angle-left {
  transform: rotate(-90deg);
  color: #fff;
}

.nav-treeview {
  background: transparent;
  border-radius: 0;
  padding-left: 0;
  display: none;
}
.nav-item.menu-open > .nav-treeview {
  display: block;
}
.nav-treeview .nav-link {
  padding: 5px 16px 5px 38px !important;
  font-size: 12.5px;
  color: rgba(255,255,255,0.55) !important;
  margin: 0 !important;
  border-radius: 0;
  font-weight: 400;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.nav-treeview .nav-link:hover {
  background: transparent !important;
  color: rgba(255,255,255,0.85) !important;
  border-left-color: var(--red);
}
.nav-treeview .nav-link.active {
  background: transparent !important;
  color: #fff !important;
  border-left: 3px solid var(--red);
  font-weight: 500;
}

/* ============================================================
   SIDEBAR COLLAPSE (AdminLTE 3 behavior)
   ============================================================ */
.sidebar-mini.sidebar-collapse .sidebar-form,
.sidebar-mini.sidebar-collapse .sidebar .form-inline,
.sidebar-mini.sidebar-collapse .nav-sidebar .nav-header {
  display: none !important;
}

.sidebar-mini.sidebar-collapse .brand-link {
  text-align: center;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.sidebar-mini.sidebar-collapse .brand-link .brand-text {
  display: none !important;
}

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-link {
  margin: 0 !important;
  border-radius: 0 !important;
  padding: 0.78rem 0.5rem !important;
  text-align: center;
}

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-link p,
.sidebar-mini.sidebar-collapse .nav-sidebar .nav-link .right {
  display: none !important;
}

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-link .nav-icon {
  margin: 0 !important;
  width: 1.6rem;
  font-size: 1rem;
}

.sidebar-mini.sidebar-collapse .nav-sidebar .nav-item:not(.has-treeview) > .nav-link.active,
.sidebar-mini.sidebar-collapse .nav-sidebar .nav-item.has-treeview.menu-open > .nav-link,
.sidebar-mini.sidebar-collapse .nav-sidebar .nav-item.has-treeview > .nav-link.active {
  border-left: none !important;
  margin: 0 !important;
  padding-left: 0.5rem !important;
}

.sidebar-mini.sidebar-collapse .nav-treeview,
.sidebar-mini.sidebar-collapse .nav-item.menu-open > .nav-treeview {
  display: none !important;
}

/* ============================================================
   CONTENT WRAPPER
   ============================================================ */
.content-wrapper { background: var(--surface) !important; }
.content-header { padding: 16px 20px 0; }
.content-header h1 { font-size: 1.25rem; font-weight: 700; color: var(--text); }

.breadcrumb { background: transparent; padding: 0; margin: 0; }
.breadcrumb-item a { color: var(--red); font-size: 12.5px; }
.breadcrumb-item.active { color: var(--text-muted); font-size: 12.5px; }
.breadcrumb-item + .breadcrumb-item::before { color: #CBD5E0; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  border-radius: 10px 10px 0 0 !important;
  padding: 12px 16px;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin: 0; }
.card-body { padding: 16px; }
.card-footer {
  background: #FAFBFC;
  border-top: 1px solid var(--border);
  border-radius: 0 0 10px 10px !important;
}

.card-danger.card-outline {
  border-top: 3px solid var(--red) !important;
  border-left: 1px solid var(--border) !important;
  border-right: 1px solid var(--border) !important;
  border-bottom: 1px solid var(--border) !important;
}
.card-info.card-outline    { border-top: 3px solid #3B82F6 !important; }
.card-success.card-outline { border-top: 3px solid #10B981 !important; }
.card-warning.card-outline { border-top: 3px solid #F59E0B !important; }

/* ============================================================
   SMALL BOXES (DASHBOARD STATS)
   ============================================================ */
.small-box { border-radius: 10px; border: none; box-shadow: var(--shadow-sm); }
.small-box h3 { font-size: 2rem; font-weight: 700; }
.small-box p  { font-size: 13px; font-weight: 600; opacity: 0.9; }
.small-box .icon { opacity: 0.25; }
.small-box.bg-maroon         { background-color: var(--red) !important; }
.small-box.bg-secondary-red  { background-color: #EF5350 !important; }
.small-box.bg-info           { background-color: #3B82F6 !important; }
.small-box.bg-success        { background-color: #10B981 !important; }
.small-box.bg-warning        { background-color: #F59E0B !important; }

/* DataTables length control sizing (global for all datatables)
   Ensures the "Show N entries" control doesn't appear cramped or overlap
   with neighboring controls across different page layouts. */
.dataTables_wrapper .dataTables_length {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_length input {
  /* min-width: 96px !important; */
  box-sizing: border-box !important;
  display: inline-block !important;
  padding: 6px 10px !important;
  margin: 0 !important;
  border: 1px solid #D1D5DB !important;
  border-radius: 6px !important;
  background: #fff !important;
  font-size: 13px !important;
}


/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  transition: all 0.15s;
}
.btn-danger, .btn-payroll-red {
  background-color: var(--red) !important;
  border-color: var(--red) !important;
  color: #fff !important;
}
.btn-danger:hover, .btn-payroll-red:hover {
  background-color: var(--red-dark) !important;
  border-color: var(--red-dark) !important;
  box-shadow: 0 2px 8px rgba(229,57,53,0.3);
}
.btn-outline-danger { color: var(--red) !important; border-color: var(--red) !important; }
.btn-outline-danger:hover { background-color: var(--red) !important; color: #fff !important; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-xs { padding: 2px 8px; font-size: 11px; }

/* ============================================================
   FORMS
   ============================================================ */
.form-control {
  border-radius: 6px;
  border: 1px solid #D1D5DB;
  font-size: 13.5px;
  color: var(--text);
  padding: 7px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229,57,53,0.12);
  outline: none;
}
label, .form-label, .col-form-label {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}
.custom-file-input:focus ~ .custom-file-label {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(229,57,53,0.12);
}
.custom-file-label { border-color: #D1D5DB; border-radius: 6px; font-size: 13.5px; }
.custom-file-label::after {
  border-radius: 0 6px 6px 0;
  background: var(--red);
  color: #fff;
  content: "Browse";
}

/* ============================================================
   TABLES & DATATABLES
   ============================================================ */
.table { font-size: 13px; color: var(--text); }
.table thead th {
  background-color: #F8FAFC;
  color: #374151;
  border-bottom: 2px solid var(--border);
  border-top: none;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  padding: 10px 12px;
  white-space: nowrap;
}
.table tbody td { padding: 9px 12px; border-top: 1px solid #F1F3F5; vertical-align: middle; }
.table-hover tbody tr:hover td { background-color: #FFF8F8; }
.table-bordered { border-color: var(--border); }
.table-bordered th, .table-bordered td { border-color: var(--border); }

.dataTables_wrapper .dataTables_filter input {
  border: 1px solid #D1D5DB; border-radius: 6px; padding: 5px 10px; font-size: 13px;
}
.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--red); box-shadow: 0 0 0 3px rgba(229,57,53,0.12); outline: none;
}
.dataTables_wrapper .dataTables_length select { 
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate { font-size: 12.5px; padding-top: 10px; }
.page-item.active .page-link { background-color: var(--red); border-color: var(--red); }
.page-link { color: var(--red); }
.page-link:hover { color: var(--red-dark); }
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  font-size: 11px; font-weight: 600;
  padding: 4px 8px; border-radius: 4px; letter-spacing: 0.2px;
}
.badge-aktif      { background-color: #D1FAE5; color: #065F46; }
.badge-nonaktif   { background-color: #F1F5F9; color: #64748B; }
.badge-draft      { background-color: #F1F5F9; color: #64748B; }
.badge-diproses   { background-color: #DBEAFE; color: #1E40AF; }
.badge-approved   { background-color: #D1FAE5; color: #065F46; }
.badge-locked     { background-color: #1C1C2E; color: #E2E8F0; }
.badge-gagal      { background-color: #FEE2E2; color: #991B1B; }
.badge-tunjangan  { background-color: #D1FAE5; color: #065F46; }
.badge-potongan   { background-color: #FEE2E2; color: #991B1B; }
.badge-nasional   { background-color: #DBEAFE; color: #1E40AF; }
.badge-perusahaan { background-color: #EDE9FE; color: #5B21B6; }
.badge-warning    { background-color: #FEF3C7; color: #92400E; }
.badge-danger     { background-color: var(--red); color: #fff; }
.badge-success    { background-color: #10B981; color: #fff; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert { border-radius: 8px; border: none; font-size: 13.5px; padding: 12px 16px; }
.alert-success { background: #D1FAE5; color: #065F46; }
.alert-danger  { background: #FEE2E2; color: #991B1B; }
.alert-warning { background: #FEF3C7; color: #92400E; }
.alert-info    { background: #DBEAFE; color: #1E40AF; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state { padding: 48px 16px; text-align: center; }
.empty-state i { font-size: 3rem; color: #CBD5E0; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 13.5px; color: var(--text-muted); margin: 0; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.payroll-login-page {
  min-height: 100vh;
  background: linear-gradient(145deg, #B71C1C 0%, #E53935 50%, #EF5350 100%);
}
.login-box { width: 420px; max-width: calc(100vw - 32px); }
.login-logo a { color: #fff; font-weight: 700; letter-spacing: 0.5px; }
.login-logo .subtitle {
  color: rgba(255,255,255,0.8);
  text-align: center; margin-top: 6px; font-size: 13.5px;
}
.login-card-body {
  border-radius: 12px; border: none;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  background: #fff;
}
.login-input-wrap { position: relative; }
.login-input-wrap .left-icon {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); color: #9CA3AF; z-index: 3;
}
.login-input-wrap .field-icon {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%); color: #9CA3AF; cursor: pointer;
}
.login-input-wrap .form-control { padding-left: 36px; }
#password { padding-right: 36px; }
.btn-login { border-radius: 8px; font-weight: 700; letter-spacing: 0.2px; }
.alert-login { border-radius: 8px; }
.demo-credential { margin-top: 12px; font-size: 12px; color: #9CA3AF; text-align: center; }

/* ============================================================
   MISC
   ============================================================ */
.hide { display: none !important; }
.text-red { color: var(--red) !important; }
.bg-red   { background-color: var(--red) !important; }

tr.import-error { background-color: #FFF5F5 !important; }
tr.import-error td { color: #7F1D1D; }
tr.import-ok { background-color: #F0FDF4 !important; }

.info-box { border-radius: 10px; border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.info-box-icon { border-radius: 10px 0 0 10px; width: 64px; font-size: 1.6rem; }

.main-footer {
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-muted);
  background: #fff; padding: 10px 20px;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--red); }

p.nav-header {
    margin-bottom: 2px !important;
}

select.form-control.form-control-sm.field-jenis {
    font-size: 10px !important;
}

/* ============================================================
   AI ASSISTANT (MVP UI)
   ============================================================ */
.ai-assistant-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 22px;
  box-shadow: var(--shadow-md);
  z-index: 2030;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.ai-assistant-fab:hover,
.ai-assistant-fab:focus {
  background: var(--red-dark);
  color: #fff;
  transform: translateY(-2px);
}

.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 var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  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 12px;
  background: var(--red);
  color: #fff;
}

.ai-chatbox-title {
  margin: 0;
  font-size: 14px;
  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;
}

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

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

.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-chat-messages {
  flex: 1;
  min-height: 140px;
  overflow-y: auto;
  background: #f9fafb;
}

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

.ai-history-toolbar .btn {
  font-size: 12px;
  font-weight: 600;
}

.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 108px;
  overflow-y: auto;
}

.ai-quick-actions .ai-quick-btn {
  font-size: 12px;
  font-weight: 600;
  line-height: 1.1;
  padding: 5px 8px;
  margin: 0;
  border-width: 1px;
}

.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 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: var(--shadow-sm);
}

.ai-msg-user .ai-msg-bubble {
  background: var(--red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ai-msg-bot .ai-msg-bubble {
  background: #fff;
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

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

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

.ai-image-card {
  border: 1px solid var(--border);
  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: var(--shadow-sm);
  border-color: var(--red-border);
  outline: none;
}

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

.ai-image-label {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

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

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

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

  .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 !important;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
  }

  .ai-quick-actions .ai-quick-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: top;
    flex: 0 0 auto;
    font-size: 11px;
    padding: 4px 7px;
    margin-right: 6px;
  }

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