/* Custom Modern Executive Styles for Big Data สพม.สมุทรปราการ */
:root {
    --surface-card: #ffffff;
    --surface-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -12px rgba(15, 23, 42, 0.09);
    --surface-shadow-hover: 0 4px 12px rgba(37, 99, 235, 0.08), 0 18px 34px -14px rgba(15, 23, 42, 0.14);
}

html {
    scroll-behavior: smooth;
}

/* Defensive image size bounds before Tailwind finishes initializing */
img {
    max-width: 100%;
    height: auto;
}
header img[alt*="Big Data"],
footer img[alt="Logo"],
.w-16.h-16 > img[alt="Logo"] {
    max-width: 64px;
    max-height: 64px;
    object-fit: contain;
}

body {
    font-family: 'Prompt', 'Sarabun', sans-serif;
    background-color: #f4f7fb !important;
    background-image:
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.07) 0px, transparent 42%),
        radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.07) 0px, transparent 40%),
        radial-gradient(at 80% 100%, rgba(16, 185, 129, 0.04) 0px, transparent 45%);
    background-attachment: fixed;
    font-feature-settings: "tnum" on;
}

/* Tabular numbers for crisp data alignment */
table, .kpi-number {
    font-variant-numeric: tabular-nums;
}

/* Modern Custom Scrollbar */
::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.45);
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.7);
}

/* Modern Elevated Cards */
main .bg-white.rounded-2xl {
    box-shadow: var(--surface-shadow);
    transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

.kpi-card {
    position: relative;
    overflow: hidden;
    transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.22s ease, border-color 0.22s ease;
}
.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--surface-shadow-hover) !important;
    border-color: rgba(59, 130, 246, 0.3) !important;
}

/* Modern Hero Decorative Glow */
.hero-modern {
    background: linear-gradient(125deg, #0b1224 0%, #172554 48%, #1e1b4b 100%);
    box-shadow: 0 20px 45px -20px rgba(15, 23, 42, 0.55);
}
.hero-modern::before {
    content: "";
    position: absolute;
    top: -65px;
    right: -45px;
    width: 260px;
    height: 260px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(56, 189, 248, 0.28) 0%, transparent 70%);
    pointer-events: none;
}
.hero-modern::after {
    content: "";
    position: absolute;
    bottom: -80px;
    left: 24%;
    width: 300px;
    height: 220px;
    border-radius: 9999px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.24) 0%, transparent 70%);
    pointer-events: none;
}

/* Modern Executive Left Sidebar (Public & Admin) */
#dmcSidebar,
#adminSidebar {
    background: linear-gradient(180deg, #0f172a 0%, #152036 52%, #111827 100%) !important;
    border-right: 1px solid rgba(148, 163, 184, 0.14) !important;
}
#dmcSidebar a,
#dmcSidebar button,
#adminSidebar a,
#adminSidebar button {
    transition: background-color 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
}

/* Quick Access Tile Hover */
.quick-dim-tile {
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}
.quick-dim-tile:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -10px rgba(37, 99, 235, 0.28);
}

/* Subtle Page Entry Animation */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
main > div,
main > section,
main > form {
    animation: fadeSlideUp 0.28s ease-out both;
}

/* Modern Inputs & Selects Focus Glow */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #3b82f6 !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}
.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Leaflet Custom Popup Styling (Light & Dark Mode High Contrast) */
.leaflet-popup-content-wrapper {
    border-radius: 14px;
    box-shadow: 0 12px 28px -5px rgba(15, 23, 42, 0.2);
    font-family: 'Prompt', 'Sarabun', sans-serif;
}

.leaflet-popup-content {
    margin: 12px 14px;
    color: #1e293b;
}

.gis-popup-title {
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.gis-popup-cluster {
    display: inline-block;
    font-size: 10.5px;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 9999px;
    color: #ffffff;
    background: var(--cluster-color, #2563eb);
    margin-top: 2px;
}

.gis-popup-meta {
    font-size: 12px;
    color: #334155;
    line-height: 1.55;
    border-top: 1px solid #e2e8f0;
    padding-top: 6px;
}

.gis-popup-link {
    font-size: 11px;
    color: #2563eb;
    font-weight: 700;
    text-decoration: underline;
}

.gis-popup-btn-sec {
    padding: 5px 10px;
    background: #f1f5f9;
    color: #1e293b !important;
    border-radius: 6px;
    font-size: 11px;
    text-decoration: none !important;
    font-weight: 600;
}

/* Custom School Logo Map Marker Pin */
.school-logo-marker {
    background: transparent !important;
    border: none !important;
}

.school-pin-wrap {
    position: relative;
    width: 44px;
    height: 52px;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.18s ease;
}

.school-pin-wrap:hover {
    transform: scale(1.18) translateY(-3px);
    z-index: 999 !important;
}

.school-pin-badge {
    width: 40px;
    height: 40px;
    border-radius: 9999px;
    background: #ffffff;
    border: 3px solid var(--pin-color, #2563eb);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    z-index: 2;
}

.school-pin-badge img {
    width: 34px;
    height: 34px;
    object-fit: contain;
    border-radius: 9999px;
}

.school-pin-tip {
    width: 0;
    height: 0;
    border-left: 7px solid transparent;
    border-right: 7px solid transparent;
    border-top: 10px solid var(--pin-color, #2563eb);
    margin-top: -2px;
    z-index: 1;
}

.school-pin-label {
    position: absolute;
    top: 43px;
    background: rgba(15, 23, 42, 0.88);
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 600;
    padding: 1px 5px;
    border-radius: 4px;
    white-space: nowrap;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    pointer-events: none;
}

/* Infographic Card Printable Canvas */
#infographic-canvas {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #1d4ed8 100%);
}

/* =========================================================
 * โหมดขาว-ดำ (Grayscale / Monochrome Mode) สำหรับหน่วยงานภาครัฐ
 * ========================================================= */
html.grayscale-mode {
    filter: grayscale(100%);
    -webkit-filter: grayscale(100%);
}

/* =========================================================
 * โหมดมืด / โหมดกลางคืน (Dark Mode) ครอบคลุมทุกหน้าสาธารณะและหลังบ้าน
 * ========================================================= */
html.dark-mode body {
    background-color: #070d1a !important;
    background-image:
        radial-gradient(at 0% 0%, rgba(37, 99, 235, 0.14) 0px, transparent 45%),
        radial-gradient(at 100% 0%, rgba(99, 102, 241, 0.14) 0px, transparent 42%) !important;
    color: #e2e8f0 !important;
}

html.dark-mode header:not(.bg-gradient-to-r) {
    background-color: rgba(15, 23, 42, 0.88) !important;
    color: #f1f5f9 !important;
    border-color: #1e293b !important;
}

html.dark-mode .bg-white,
html.dark-mode .bg-white\/95,
html.dark-mode .bg-white\/90,
html.dark-mode .bg-white\/85,
html.dark-mode .bg-white\/80,
html.dark-mode .bg-white\/70,
html.dark-mode .bg-white\/60 {
    background-color: #111c32 !important;
    color: #e2e8f0 !important;
}

html.dark-mode .bg-slate-50,
html.dark-mode .bg-slate-50\/90,
html.dark-mode .bg-slate-50\/80,
html.dark-mode .bg-slate-50\/70,
html.dark-mode .bg-slate-50\/60,
html.dark-mode .bg-slate-50\/50,
html.dark-mode .bg-slate-50\/40,
html.dark-mode .bg-slate-100,
html.dark-mode .bg-slate-100\/90,
html.dark-mode .bg-slate-100\/80,
html.dark-mode .bg-slate-100\/70 {
    background-color: #17233b !important;
}

html.dark-mode .hover\:bg-white:hover,
html.dark-mode .hover\:bg-slate-50:hover,
html.dark-mode .hover\:bg-slate-100:hover {
    background-color: #1e2f4d !important;
}

html.dark-mode .bg-slate-200\/80 {
    background-color: #1e293b !important;
}

html.dark-mode .bg-blue-50,
html.dark-mode .bg-blue-50\/30,
html.dark-mode .bg-blue-50\/40,
html.dark-mode .bg-blue-50\/50,
html.dark-mode .bg-blue-50\/60,
html.dark-mode .bg-blue-50\/70,
html.dark-mode .bg-blue-50\/80,
html.dark-mode .bg-blue-100,
html.dark-mode .bg-indigo-50,
html.dark-mode .bg-indigo-50\/30,
html.dark-mode .bg-indigo-50\/40,
html.dark-mode .bg-indigo-50\/50,
html.dark-mode .bg-indigo-50\/60,
html.dark-mode .bg-indigo-50\/70,
html.dark-mode .bg-indigo-50\/80,
html.dark-mode .bg-indigo-50\/90,
html.dark-mode .bg-indigo-100,
html.dark-mode .bg-emerald-50,
html.dark-mode .bg-emerald-50\/30,
html.dark-mode .bg-emerald-50\/40,
html.dark-mode .bg-emerald-50\/50,
html.dark-mode .bg-emerald-50\/60,
html.dark-mode .bg-emerald-50\/70,
html.dark-mode .bg-emerald-50\/80,
html.dark-mode .bg-emerald-100,
html.dark-mode .bg-teal-50,
html.dark-mode .bg-teal-50\/50,
html.dark-mode .bg-teal-50\/60,
html.dark-mode .bg-teal-50\/70,
html.dark-mode .bg-teal-50\/80,
html.dark-mode .bg-teal-100,
html.dark-mode .bg-purple-50,
html.dark-mode .bg-purple-50\/50,
html.dark-mode .bg-purple-50\/60,
html.dark-mode .bg-purple-50\/70,
html.dark-mode .bg-purple-50\/80,
html.dark-mode .bg-purple-100,
html.dark-mode .bg-violet-50,
html.dark-mode .bg-violet-50\/70,
html.dark-mode .bg-violet-100,
html.dark-mode .bg-sky-50,
html.dark-mode .bg-sky-50\/50,
html.dark-mode .bg-sky-50\/60,
html.dark-mode .bg-sky-50\/70,
html.dark-mode .bg-sky-50\/80,
html.dark-mode .bg-sky-100,
html.dark-mode .bg-cyan-50,
html.dark-mode .bg-cyan-50\/50,
html.dark-mode .bg-cyan-50\/70,
html.dark-mode .bg-cyan-100,
html.dark-mode .bg-amber-50,
html.dark-mode .bg-amber-50\/40,
html.dark-mode .bg-amber-50\/50,
html.dark-mode .bg-amber-50\/60,
html.dark-mode .bg-amber-50\/70,
html.dark-mode .bg-amber-50\/80,
html.dark-mode .bg-amber-100,
html.dark-mode .bg-rose-50,
html.dark-mode .bg-rose-50\/50,
html.dark-mode .bg-rose-50\/70,
html.dark-mode .bg-rose-50\/80,
html.dark-mode .bg-rose-100,
html.dark-mode .bg-pink-50,
html.dark-mode .bg-pink-50\/70,
html.dark-mode .bg-pink-100,
html.dark-mode .bg-orange-50,
html.dark-mode .bg-orange-50\/70,
html.dark-mode .bg-orange-100,
html.dark-mode .bg-red-50,
html.dark-mode .bg-red-100 {
    background-color: #1a2942 !important;
}

html.dark-mode .bg-slate-200 {
    background-color: #24334d !important;
}

html.dark-mode .text-slate-900,
html.dark-mode .text-slate-800 {
    color: #f1f5f9 !important;
}

html.dark-mode .text-slate-700,
html.dark-mode .text-slate-600 {
    color: #cbd5e1 !important;
}

html.dark-mode .text-slate-500,
html.dark-mode .text-slate-400 {
    color: #94a3b8 !important;
}

html.dark-mode .text-blue-950,
html.dark-mode .text-blue-900,
html.dark-mode .text-blue-800,
html.dark-mode .text-blue-700,
html.dark-mode .text-sky-950,
html.dark-mode .text-sky-900,
html.dark-mode .text-sky-800,
html.dark-mode .text-sky-700,
html.dark-mode .text-cyan-800,
html.dark-mode .text-indigo-950,
html.dark-mode .text-indigo-900,
html.dark-mode .text-indigo-800,
html.dark-mode .text-indigo-700 {
    color: #93c5fd !important;
}

html.dark-mode .text-emerald-950,
html.dark-mode .text-emerald-900,
html.dark-mode .text-emerald-800,
html.dark-mode .text-emerald-700,
html.dark-mode .text-teal-900,
html.dark-mode .text-teal-700 {
    color: #6ee7b7 !important;
}

html.dark-mode .text-amber-950,
html.dark-mode .text-amber-900,
html.dark-mode .text-amber-800,
html.dark-mode .text-amber-700 {
    color: #fcd34d !important;
}

html.dark-mode .text-rose-900,
html.dark-mode .text-rose-800,
html.dark-mode .text-rose-700,
html.dark-mode .text-red-800 {
    color: #fda4af !important;
}

html.dark-mode .text-purple-900,
html.dark-mode .text-purple-700 {
    color: #d8b4fe !important;
}

html.dark-mode .text-pink-700,
html.dark-mode .text-pink-600 {
    color: #f9a8d4 !important;
}

html.dark-mode .border-slate-200,
html.dark-mode .border-slate-200\/80,
html.dark-mode .border-slate-200\/90,
html.dark-mode .border-slate-300,
html.dark-mode .border-slate-100,
html.dark-mode .border-blue-100,
html.dark-mode .border-blue-200,
html.dark-mode .border-blue-300,
html.dark-mode .border-indigo-100,
html.dark-mode .border-indigo-200,
html.dark-mode .border-purple-100,
html.dark-mode .border-purple-200,
html.dark-mode .border-emerald-100,
html.dark-mode .border-emerald-200,
html.dark-mode .border-teal-100,
html.dark-mode .border-sky-100,
html.dark-mode .border-sky-200,
html.dark-mode .border-amber-100,
html.dark-mode .border-amber-200 {
    border-color: #26354f !important;
}

html.dark-mode .divide-slate-200 > :not([hidden]) ~ :not([hidden]),
html.dark-mode .divide-slate-200\/70 > :not([hidden]) ~ :not([hidden]),
html.dark-mode .divide-slate-200\/80 > :not([hidden]) ~ :not([hidden]) {
    border-color: #24324a !important;
}

html.dark-mode input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
html.dark-mode select,
html.dark-mode textarea {
    background-color: #0f172a !important;
    color: #f1f5f9 !important;
    border-color: #334155 !important;
}

html.dark-mode tr:hover {
    background-color: rgba(59, 130, 246, 0.12) !important;
}

html.dark-mode .leaflet-popup-content-wrapper,
html.dark-mode .leaflet-popup-tip {
    background: #0f172a !important;
    color: #f8fafc !important;
    border: 1px solid rgba(148, 163, 184, 0.28);
}

html.dark-mode .leaflet-popup-content,
html.dark-mode .leaflet-popup-content div,
html.dark-mode .leaflet-popup-content span {
    color: #e2e8f0;
}

html.dark-mode .gis-popup-title,
html.dark-mode .leaflet-popup-content b {
    color: #ffffff !important;
}

html.dark-mode .gis-popup-cluster {
    color: #ffffff !important;
}

html.dark-mode .gis-popup-meta {
    color: #cbd5e1 !important;
    border-top-color: rgba(148, 163, 184, 0.25) !important;
}

html.dark-mode .gis-popup-link {
    color: #60a5fa !important;
}

html.dark-mode .gis-popup-btn-sec {
    background: #1e293b !important;
    color: #f1f5f9 !important;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

html.dark-mode .leaflet-container a.leaflet-popup-close-button {
    color: #cbd5e1 !important;
}
html.dark-mode .leaflet-container a.leaflet-popup-close-button:hover {
    color: #ffffff !important;
}

/* Smart Table Pagination Bar (Dark Mode Support) */
html.dark-mode .smart-pagination-bar {
    background-color: #0f172a !important;
    border-color: #26354f !important;
}
html.dark-mode .smart-pg-btn:not(.smart-pg-active) {
    background-color: #17233b !important;
    color: #cbd5e1 !important;
    border-color: #334155 !important;
}
html.dark-mode .smart-pg-btn:not(.smart-pg-active):not(:disabled):hover {
    background-color: #1e3a5f !important;
    color: #ffffff !important;
}

@media print {
    header, footer, .no-print, .smart-pagination-bar {
        display: none !important;
    }
    tbody tr[data-paginated-row="1"],
    tbody tr[data-group-header="1"] {
        display: table-row !important;
    }
    main {
        padding: 0 !important;
        max-width: 100% !important;
    }
}

/* =========================================================
 * Cross-Browser & All-Device Responsive Support
 * รองรับ Chrome, Safari/iOS, Firefox, Edge, LINE/Facebook WebView
 * ทุกขนาดหน้าจอ: มือถือ (320px+), แท็บเล็ต (768px+), คอมพิวเตอร์ (1024px+)
 * ========================================================= */
html, body {
    max-width: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.12);
}

/* Safari / iOS backdrop-filter vendor prefix */
.backdrop-blur-xs {
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}
.backdrop-blur-sm {
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
}
.backdrop-blur-md {
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
}

/* Smooth momentum touch scrolling for tables & drawers on iOS / Android */
.overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

/* Reduce 300ms tap delay on mobile touch devices */
button, a, select, input, label {
    touch-action: manipulation;
}

/* Safe dynamic viewport height for modals & mobile drawers (iOS Safari address bar) */
#spmPdpaOverlay > div,
#spmAnnouncementPopup > div,
#annDetailModal > div {
    max-height: 92vh;
    max-height: 92dvh;
}
#dmcSidebar.mobile-drawer-open,
#adminSidebar.mobile-drawer-open {
    height: 100vh;
    height: 100dvh;
    max-width: 85vw;
    -webkit-overflow-scrolling: touch;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Prevent horizontal clipping on narrow mobile screens (< 640px) */
@media (max-width: 639px) {
    main {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
    input.w-64,
    input.w-60,
    select.min-w-\[195px\] {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
    }
    .smart-pagination-bar {
        padding-left: 0.75rem !important;
        padding-right: 0.75rem !important;
    }
}

/* Prevent iOS Safari auto-zoom when tapping form controls on small phones */
@media (max-width: 480px) {
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    textarea {
        font-size: 16px;
    }
}

/* Ensure charts & images never overflow container on any browser */
img, svg, canvas, video, iframe {
    max-width: 100%;
}

