html, body {
    height: 100%;
    min-height: 100vh;
}

body {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    font-size: clamp(14px, 1.2vw, 16px);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

h1 { font-size: clamp(1.5rem, 4vw, 2.25rem) !important; }
h2 { font-size: clamp(1.25rem, 3.5vw, 1.875rem) !important; }
h3 { font-size: clamp(0.875rem, 2vw, 1.125rem) !important; }

:root {
    --brand-primary: #2563eb;
    --brand-secondary: #4f46e5;
    --app-bg: #f8faff;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --card-border: rgba(255, 255, 255, 0.4);
}

.bg-app {
    background-color: var(--app-bg);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(79, 70, 229, 0.05) 0%, transparent 40%),
        linear-gradient(135deg, #f8faff 0%, #eef2ff 100%);
    background-attachment: fixed;
}
  
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--card-border);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.1);
}

.auth-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.6;
    animation: float 25s infinite alternate ease-in-out;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 40px) scale(1.1); }
}
  
.modern-input {
    background: rgba(255, 255, 255, 0.9);
    border: 1.5px solid #e5e7eb;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: normal; /* Fix Thai tone mark clipping */
    padding-top: 1rem;
    padding-bottom: 1rem;
}
.modern-input:focus {
    background: #ffffff;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}
.modern-input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}
.captcha-container {
    position: relative;
    overflow: hidden;
    background: #fdfdfd;
}
.captcha-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    opacity: 0.2;
    background-image: 
        repeating-linear-gradient(45deg, transparent, transparent 4px, #000 4px, #000 6px),
        repeating-linear-gradient(-45deg, transparent, transparent 8px, #000 8px, #000 9px);
    z-index: 5;
}
.captcha-overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    opacity: 0.1;
    mix-blend-mode: multiply;
}
.captcha-text {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-weight: 900;
    font-style: italic;
    letter-spacing: 0.6em;
    transform: skewX(-5deg);
    filter: blur(0.3px) contrast(1.2);
    text-shadow: 2px 2px 0px rgba(0,0,0,0.05);
}
.verification-tile {
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05);
}
.verification-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    border-color: #bfdbfe;
}
.modern-input:disabled {
    background: #f1f5f9;
    cursor: not-allowed;
    color: #94a3b8;
    border-color: #e2e8f0;
}
.input-error {
    border-color: #f43f5e !important;
    background-color: #fff1f2 !important;
}
.input-error:focus {
    box-shadow: 0 0 0 4px rgba(244, 63, 94, 0.2) !important;
}

.fade-in {
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
  
.modal-backdrop {
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(10px);
}
  
.aspect-portrait {
    aspect-ratio: 3/4;
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: #3b82f6;
    box-shadow: 0 0 10px #3b82f6, 0 0 20px #3b82f6, 0 0 30px #60a5fa;
    animation: scan 2s ease-in-out infinite alternate;
    z-index: 25;
    border-radius: 4px;
}
@keyframes scan {
    0% { top: 5%; opacity: 0.5; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { top: 95%; opacity: 0.5; }
}

#mapContainer {
    min-height: 220px;
    height: auto;
    width: 100%;
    overflow: hidden;
    z-index: 1;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent; 
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

/* เพิ่มการตกแต่งในส่วน Work Report */
.work-item-row:hover button {
    visibility: visible;
}
  
@media (max-width: 640px) {
    #loginPage, #attendancePage {
        padding: 1rem !important;
    }
    .glass-card {
        padding: 1.5rem !important;
        border-radius: 2rem !important;
    }
    h1 { font-size: 1.15rem !important; }
    h2 { font-size: 1rem !important; }
    input, select, button { min-height: 54px; }
    .work-item-row button { visibility: visible; }
}

.bg-light-blue-header {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(37, 99, 235, 0.1);
}

/* Custom Sidebar Styles */
.sidebar-item-active {
    background: linear-gradient(135deg, var(--brand-primary) 0%, var(--brand-secondary) 100%);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.sidebar-glass {
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.nav-item:hover:not(.sidebar-item-active) {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(6px);
    color: #fff !important;
}

.nav-item:hover:not(.sidebar-item-active) svg {
    opacity: 1;
    transform: scale(1.1);
}

/* Dashboard Tiles - Monochromatic Blue Theme */
.dashboard-tile {
    background: white;
    padding: 1.75rem;
    border-radius: 2.5rem;
    border: 1px solid rgba(37, 99, 235, 0.1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    min-height: 6rem;
}

.dashboard-tile:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 25px 50px -12px rgba(37, 99, 235, 0.15);
    border-color: rgba(37, 99, 235, 0.3);
}

.tile-icon-bg {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.5s ease;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
    color: var(--brand-primary);
    box-shadow: inset 0 2px 4px rgba(37, 99, 235, 0.05);
}

.dashboard-tile:hover .tile-icon-bg {
    background: var(--brand-primary);
    color: white;
    transform: rotate(-5deg);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.tile-text {
    font-size: 1.25rem;
    font-weight: 900;
    color: #1e293b;
    letter-spacing: -0.025em;
    transition: color 0.3s ease;
}

.dashboard-tile:hover .tile-text {
    color: var(--brand-primary);
}

/* Collapsible headers smooth transition */
#adminMobileHeader, #empHeader {
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                padding-top 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                padding-bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.3s ease-in-out,
                border-bottom-width 0.4s ease;
    overflow: hidden;
}

.header-hidden {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    border-bottom-width: 0 !important;
}

/* Safe-area offsets for notched mobile displays (iOS & Android) */
@media (max-width: 1024px) {
    #adminMobileHeader {
        padding-top: calc(1rem + env(safe-area-inset-top)) !important;
    }
    #empHeader {
        padding-top: calc(1.5rem + env(safe-area-inset-top)) !important;
    }
    #sysSidebar, #dashboardSidebar {
        padding-top: calc(2rem + env(safe-area-inset-top)) !important;
        padding-bottom: calc(2rem + env(safe-area-inset-bottom)) !important;
    }
    /* Add safe area bottom padding to main scrolling areas and modals */
    #empContent, #dashContent, #leaveForm, #resignForm, .user-tab-content {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)) !important;
    }
}