/* ==========================================================
   DSK Global Backoffice Clean Theme R1
   Scope: visual presentation only when html/body has .dsk-clean
   ========================================================== */

html.dsk-clean body,
body.dsk-clean {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", "Leelawadee UI", Tahoma, sans-serif !important;
    background: #f6f8fb !important;
    color: #253241;
    font-weight: 400;
    letter-spacing: 0;
}

/* Calm navigation */
html.dsk-clean .navbar-admin,
body.dsk-clean .navbar-admin {
    background: #15385f !important;
    box-shadow: 0 1px 0 rgba(255,255,255,.08) !important;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
html.dsk-clean .navbar-admin .navbar-brand,
body.dsk-clean .navbar-admin .navbar-brand {
    font-weight: 650 !important;
    letter-spacing: -.01em;
}

/* Page rhythm */
html.dsk-clean .container.py-4,
html.dsk-clean .container.my-4,
html.dsk-clean .container-fluid.py-4,
body.dsk-clean .container.py-4,
body.dsk-clean .container.my-4,
body.dsk-clean .container-fluid.py-4 {
    padding-top: 1.15rem !important;
    padding-bottom: 1.5rem !important;
}

/* Cards / panels */
html.dsk-clean .card,
html.dsk-clean .card-custom,
html.dsk-clean .doc-card,
html.dsk-clean .document-card,
html.dsk-clean .summary-card,
body.dsk-clean .card,
body.dsk-clean .card-custom,
body.dsk-clean .doc-card,
body.dsk-clean .document-card,
body.dsk-clean .summary-card {
    border: 1px solid #e4eaf0 !important;
    border-radius: 12px !important;
    box-shadow: 0 2px 9px rgba(15,23,42,.035) !important;
}
html.dsk-clean .card-header,
body.dsk-clean .card-header {
    background: #fff !important;
    border-bottom: 1px solid #edf1f5 !important;
    padding-top: .82rem !important;
    padding-bottom: .82rem !important;
}
html.dsk-clean .card-header h1,
html.dsk-clean .card-header h2,
html.dsk-clean .card-header h3,
html.dsk-clean .card-header h4,
html.dsk-clean .card-header h5,
html.dsk-clean .card-header h6,
body.dsk-clean .card-header h1,
body.dsk-clean .card-header h2,
body.dsk-clean .card-header h3,
body.dsk-clean .card-header h4,
body.dsk-clean .card-header h5,
body.dsk-clean .card-header h6 {
    font-weight: 650 !important;
    letter-spacing: -.01em;
}
html.dsk-clean .card-body,
body.dsk-clean .card-body {
    color: #334155;
}

/* Tables: cleaner accounting/backoffice density */
html.dsk-clean .table,
body.dsk-clean .table {
    --bs-table-bg: #fff;
    --bs-table-striped-bg: #fafbfd;
    --bs-table-hover-bg: #f8fafc;
    color: #263442;
    font-size: 13.25px;
    margin-bottom: 0;
}
html.dsk-clean .table > thead > tr > th,
body.dsk-clean .table > thead > tr > th {
    background: #f8fafc !important;
    color: #647383 !important;
    font-size: 11.75px !important;
    font-weight: 650 !important;
    line-height: 1.25;
    padding: 10px 12px !important;
    border-bottom: 1px solid #dfe6ed !important;
    vertical-align: middle;
}
html.dsk-clean .table > tbody > tr > td,
body.dsk-clean .table > tbody > tr > td {
    padding: 11px 12px !important;
    border-color: #edf1f4 !important;
    vertical-align: middle;
    font-weight: 400;
}
html.dsk-clean .table-hover > tbody > tr:hover > *,
body.dsk-clean .table-hover > tbody > tr:hover > * {
    background-color: #fbfcfe !important;
}
html.dsk-clean .table-responsive,
body.dsk-clean .table-responsive {
    scrollbar-color: #c8d1db transparent;
    scrollbar-width: thin;
}

/* Forms */
html.dsk-clean .form-control,
html.dsk-clean .form-select,
body.dsk-clean .form-control,
body.dsk-clean .form-select {
    border-color: #dbe3eb;
    border-radius: 7px;
    box-shadow: none !important;
    color: #283747;
}
html.dsk-clean .form-control:focus,
html.dsk-clean .form-select:focus,
body.dsk-clean .form-control:focus,
body.dsk-clean .form-select:focus {
    border-color: #8faeca;
    box-shadow: 0 0 0 3px rgba(48,93,137,.08) !important;
}
html.dsk-clean label,
body.dsk-clean label {
    color: #526170;
}

/* Buttons */
html.dsk-clean .btn,
body.dsk-clean .btn {
    border-radius: 7px;
    font-weight: 550;
    box-shadow: none !important;
}
html.dsk-clean .btn-outline-secondary,
body.dsk-clean .btn-outline-secondary {
    color: #5f6e7d;
    border-color: #d7dfe7;
}
html.dsk-clean .btn-outline-secondary:hover,
body.dsk-clean .btn-outline-secondary:hover {
    color: #263b50;
    background: #f6f8fa;
    border-color: #cbd5df;
}

/* Semantic badges: keep meaning, reduce visual noise */
html.dsk-clean .badge,
body.dsk-clean .badge {
    font-size: 10.8px;
    font-weight: 600;
    border-radius: 999px;
    padding: .34rem .52rem;
    box-shadow: none;
}
html.dsk-clean .badge.bg-success,
body.dsk-clean .badge.bg-success { background:#e9f7ef !important; color:#167247 !important; border:1px solid #c9ead8; }
html.dsk-clean .badge.bg-warning,
body.dsk-clean .badge.bg-warning { background:#fff5dd !important; color:#856008 !important; border:1px solid #f1ddaa; }
html.dsk-clean .badge.bg-danger,
body.dsk-clean .badge.bg-danger  { background:#fdecec !important; color:#ad3939 !important; border:1px solid #f0c8c8; }
html.dsk-clean .badge.bg-primary,
body.dsk-clean .badge.bg-primary { background:#edf3fb !important; color:#2c5d91 !important; border:1px solid #ccdcf0; }
html.dsk-clean .badge.bg-info,
body.dsk-clean .badge.bg-info    { background:#eaf7f8 !important; color:#257078 !important; border:1px solid #cae9eb; }
html.dsk-clean .badge.bg-secondary,
body.dsk-clean .badge.bg-secondary { background:#f1f3f5 !important; color:#68737e !important; border:1px solid #e0e5e9; }
html.dsk-clean .badge.bg-light,
body.dsk-clean .badge.bg-light { background:#f8fafc !important; color:#66727e !important; border:1px solid #e4e9ee !important; }

/* Alerts / guides */
html.dsk-clean .alert,
html.dsk-clean .guide,
body.dsk-clean .alert,
body.dsk-clean .guide {
    border-radius: 10px !important;
    box-shadow: none !important;
}

/* Modal / popup */
html.dsk-clean .modal-content,
body.dsk-clean .modal-content {
    border: 1px solid #e1e8ef !important;
    border-radius: 14px !important;
    box-shadow: 0 18px 45px rgba(15,23,42,.16) !important;
    overflow: hidden;
}
html.dsk-clean .modal-header,
body.dsk-clean .modal-header {
    border-bottom-color: #edf1f5 !important;
}
html.dsk-clean .modal-footer,
body.dsk-clean .modal-footer {
    border-top-color: #edf1f5 !important;
}

/* Typography hierarchy */
html.dsk-clean h1,
html.dsk-clean h2,
html.dsk-clean h3,
html.dsk-clean h4,
html.dsk-clean h5,
html.dsk-clean h6,
body.dsk-clean h1,
body.dsk-clean h2,
body.dsk-clean h3,
body.dsk-clean h4,
body.dsk-clean h5,
body.dsk-clean h6 {
    letter-spacing: -.012em;
}
html.dsk-clean .text-muted,
body.dsk-clean .text-muted { color:#7b8794 !important; }
html.dsk-clean .fw-bold,
body.dsk-clean .fw-bold { font-weight:650 !important; }
html.dsk-clean .fw-semibold,
body.dsk-clean .fw-semibold { font-weight:600 !important; }

/* Tabs / pills */
html.dsk-clean .nav-tabs,
body.dsk-clean .nav-tabs { border-bottom-color:#e3e9ef; }
html.dsk-clean .nav-tabs .nav-link,
body.dsk-clean .nav-tabs .nav-link {
    border-radius: 7px 7px 0 0;
    color:#627181;
    font-weight:550;
}
html.dsk-clean .nav-tabs .nav-link.active,
body.dsk-clean .nav-tabs .nav-link.active {
    color:#173a5e;
    background:#fff;
    border-color:#dfe6ed #dfe6ed #fff;
}

/* Global view switch */
.dsk-theme-toggle {
    white-space: nowrap;
    border-radius: 7px !important;
}
.dsk-theme-toggle.dsk-floating {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 1085;
    background: #15385f !important;
    color: #fff !important;
    border: 1px solid rgba(255,255,255,.22) !important;
    box-shadow: 0 8px 24px rgba(15,23,42,.18) !important;
    padding: .48rem .72rem;
}

/* Keep maps / Leaflet controls functional */
html.dsk-clean .leaflet-container,
body.dsk-clean .leaflet-container { font-family: inherit; }

/* Smaller screens: retain content; do not hide columns globally */
@media (max-width: 991.98px) {
    html.dsk-clean .table,
    body.dsk-clean .table { font-size: 12.75px; }
    html.dsk-clean .card-header,
    body.dsk-clean .card-header { padding-left: .85rem !important; padding-right: .85rem !important; }
}

/* R1.1: robust global mode switch for every Backoffice page */
.dsk-theme-toggle-global {
    display:inline-flex !important;
    align-items:center;
    justify-content:center;
    gap:.38rem;
    min-height:31px;
    padding:.34rem .62rem;
    border:1px solid #cfd8e3;
    border-radius:7px !important;
    background:#fff;
    color:#425466;
    font:600 12.5px/1.2 inherit;
    white-space:nowrap;
    cursor:pointer;
    box-shadow:none;
    transition:background .15s ease,border-color .15s ease,color .15s ease,box-shadow .15s ease;
}
.dsk-theme-toggle-global:hover { background:#f5f8fb; border-color:#9fb0c2; color:#173a5e; }
.dsk-theme-toggle-global:focus { outline:0; box-shadow:0 0 0 3px rgba(37,99,235,.14); }
.dsk-theme-icon { font-size:14px; line-height:1; }
.navbar-admin .dsk-theme-toggle-global,
nav.navbar-dark .dsk-theme-toggle-global,
.admin-header.bg-dark .dsk-theme-toggle-global {
    background:rgba(255,255,255,.08);
    color:#fff;
    border-color:rgba(255,255,255,.55);
}
.navbar-admin .dsk-theme-toggle-global:hover,
nav.navbar-dark .dsk-theme-toggle-global:hover,
.admin-header.bg-dark .dsk-theme-toggle-global:hover {
    background:rgba(255,255,255,.18);
    border-color:#fff;
    color:#fff;
}
.dsk-theme-toggle.dsk-floating {
    position:fixed;
    right:18px;
    bottom:18px;
    z-index:2147483000;
    background:#15385f !important;
    color:#fff !important;
    border:1px solid rgba(255,255,255,.28) !important;
    box-shadow:0 8px 24px rgba(15,23,42,.22) !important;
}


/* R1.2 guaranteed floating switch */
#dskGlobalThemeToggleFallback.dsk-theme-toggle-fallback,
#dskGlobalThemeToggle.dsk-floating {
    position: fixed !important;
    right: 18px !important;
    bottom: 18px !important;
    z-index: 2147483640 !important;
    display: inline-flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    align-items: center !important;
    gap: 6px !important;
    min-width: 112px;
}


/* R1.4: guaranteed visible toggle on every admin HTML page */
#dskGlobalThemeToggle.dsk-theme-toggle-guaranteed,
#dskGlobalThemeToggleFallback.dsk-theme-toggle-fallback {
  position: fixed !important; right: 18px !important; bottom: 18px !important;
  z-index: 2147483646 !important; display: inline-flex !important; visibility: visible !important;
  opacity: 1 !important; pointer-events: auto !important; align-items:center !important; justify-content:center !important;
}

/* R1.5 — place the global Clean/Normal switch inside the page header, not at screen bottom. */
#dskGlobalThemeToggle.dsk-theme-toggle-header,
#dskGlobalThemeToggleFallback.dsk-theme-toggle-header {
  position: static !important;
  right: auto !important;
  bottom: auto !important;
  top: auto !important;
  left: auto !important;
  transform: none !important;
  z-index: auto !important;
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  flex: 0 0 auto !important;
  margin: 0 !important;
  min-width: auto !important;
}
.navbar-admin #dskGlobalThemeToggle.dsk-theme-toggle-header,
nav.navbar #dskGlobalThemeToggle.dsk-theme-toggle-header,
.admin-header #dskGlobalThemeToggle.dsk-theme-toggle-header,
.topbar #dskGlobalThemeToggle.dsk-theme-toggle-header,
.top-bar #dskGlobalThemeToggle.dsk-theme-toggle-header,
.header-bar #dskGlobalThemeToggle.dsk-theme-toggle-header,
header #dskGlobalThemeToggle.dsk-theme-toggle-header {
  background: rgba(255,255,255,.08) !important;
  color: #fff !important;
  border-color: rgba(255,255,255,.60) !important;
  box-shadow: none !important;
}
.navbar-admin #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
nav.navbar #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
.admin-header #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
.topbar #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
.top-bar #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
.header-bar #dskGlobalThemeToggle.dsk-theme-toggle-header:hover,
header #dskGlobalThemeToggle.dsk-theme-toggle-header:hover {
  background: rgba(255,255,255,.18) !important;
  border-color: #fff !important;
  color: #fff !important;
}
