/* ==========================================================
   Modern Mobile-First Staff Attendance Portal Theme
   Optimized for Android & iOS Touch Devices and Desktop
   ========================================================== */

:root {
    --primary-gradient: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    --accent-gradient: linear-gradient(135deg, #0d6efd 0%, #0043a8 100%);
    --success-gradient: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    --danger-gradient: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    --card-bg: #ffffff;
    --app-bg: #f8fafc;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 8px 20px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 15px 35px rgba(15, 23, 42, 0.1);
}

body {
    background-color: var(--app-bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding-bottom: 75px; /* Space for mobile bottom navigation */
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0;
    }
}

.main-content {
    flex: 1 0 auto;
}

/* App Header Card for Mobile */
.mobile-hero-header {
    background: var(--primary-gradient);
    border-radius: 0 0 1.75rem 1.75rem;
    padding: 1.75rem 1.25rem 2rem 1.25rem;
    color: #fff;
    box-shadow: 0 10px 25px rgba(30, 60, 114, 0.25);
    margin-bottom: -1.25rem;
    position: relative;
    z-index: 2;
}

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(5px);
    border: 2px solid rgba(255, 255, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: #fff;
}

.live-digital-clock {
    font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Roboto", monospace;
    font-size: 1.85rem;
    font-weight: 800;
    letter-spacing: 1px;
    line-height: 1.2;
}

.clock-subtext {
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Cards */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-md);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    overflow: hidden;
}

.card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
}

/* Big Central Punch Button */
.punch-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 0;
}

.punch-circle-btn {
    width: 175px;
    height: 175px;
    border-radius: 50%;
    border: none;
    outline: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.punch-circle-btn:active {
    transform: scale(0.94);
}

.punch-circle-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none !important;
}

.punch-in-btn {
    background: var(--success-gradient);
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.4);
}

.punch-in-btn:not(:disabled):hover {
    box-shadow: 0 15px 35px rgba(40, 167, 69, 0.6);
    transform: translateY(-2px);
}

.punch-out-btn {
    background: var(--danger-gradient);
    box-shadow: 0 10px 30px rgba(235, 51, 73, 0.4);
}

.punch-out-btn:not(:disabled):hover {
    box-shadow: 0 15px 35px rgba(235, 51, 73, 0.6);
    transform: translateY(-2px);
}

/* Pulsing Radar Ring */
.radar-pulse-green::before {
    content: '';
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border-radius: 50%;
    border: 2px solid #28a745;
    animation: radarPulse 2s infinite;
    opacity: 0;
}

.radar-pulse-red::before {
    content: '';
    position: absolute;
    top: -8px; left: -8px; right: -8px; bottom: -8px;
    border-radius: 50%;
    border: 2px solid #dc3545;
    animation: radarPulse 2s infinite;
    opacity: 0;
}

@keyframes radarPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    70% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1.15); opacity: 0; }
}

/* Status Chips and Indicators */
.chip-status {
    padding: 0.5rem 0.85rem;
    border-radius: 50rem;
    font-size: 0.825rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.chip-success {
    background: #dcfce7;
    color: #166534;
}

.chip-danger {
    background: #fee2e2;
    color: #991b1b;
}

.chip-warning {
    background: #fef3c7;
    color: #92400e;
}

/* Geofence Radar Card */
.geofence-card {
    border-radius: 1.25rem;
    border: 1px solid var(--border-color);
    background: #fff;
}

/* Mini Map Container */
#attendance-map {
    height: 220px;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    z-index: 1;
}

@media (min-width: 768px) {
    #attendance-map {
        height: 280px;
    }
}

/* Quick Metrics Row */
.mini-stat-box {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    padding: 0.85rem;
    text-align: center;
    transition: background 0.2s;
}

.mini-stat-box .title {
    font-size: 0.725rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.mini-stat-box .val {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-main);
}

/* Mobile Bottom Navigation Bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 65px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid rgba(226, 232, 240, 0.8);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1040;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.725rem;
    font-weight: 600;
    flex: 1;
    padding: 0.4rem 0;
    transition: color 0.2s ease;
}

.mobile-nav-item i {
    font-size: 1.35rem;
    margin-bottom: 2px;
}

.mobile-nav-item.active {
    color: #0d6efd;
}

.mobile-nav-item:hover {
    color: #0d6efd;
}

@media (min-width: 992px) {
    .mobile-bottom-nav {
        display: none !important;
    }
}

/* Status Badges */
.badge-present { background-color: #d1e7dd; color: #0f5132; }
.badge-late { background-color: #fff3cd; color: #664d03; }
.badge-absent { background-color: #f8d7da; color: #842029; }
.badge-completed { background-color: #cff4fc; color: #055160; }
.badge-halfday-am { background-color: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.badge-halfday-pm { background-color: #e0e7ff; color: #3730a3; border: 1px solid #c7d2fe; }

/* ==========================================================
   Fast Low-Bandwidth Geofence Radar Mode & Offline Styling
   Enables 0-second attendance punch over slow 2G/3G/4G networks
   ========================================================== */
.radar-view-container {
    background: radial-gradient(circle at center, #1e3c72 0%, #0b1528 100%);
    border-radius: 1.25rem;
    padding: 1.75rem 1rem;
    color: #fff;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.3);
    min-height: 260px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.radar-scope {
    width: 170px;
    height: 170px;
    margin: 0 auto 0.75rem auto;
    position: relative;
    border-radius: 50%;
    border: 2px solid rgba(13, 110, 253, 0.4);
    background: radial-gradient(circle, rgba(13,110,253,0.12) 0%, rgba(11,21,40,0.9) 80%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.radar-ring {
    position: absolute;
    border-radius: 50%;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    pointer-events: none;
}
.radar-ring-1 { width: 50px; height: 50px; }
.radar-ring-2 { width: 105px; height: 105px; }
.radar-ring-3 { width: 160px; height: 160px; }

.radar-sweep {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, rgba(13, 110, 253, 0.4) 0deg, transparent 65deg, transparent 360deg);
    animation: radar-sweep-spin 2.8s linear infinite;
    pointer-events: none;
}

@keyframes radar-sweep-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.radar-center-blip {
    position: relative;
    z-index: 5;
    background: #ffffff;
    color: #1e3c72;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 0 16px rgba(255,255,255,0.7);
    transition: all 0.3s ease;
}

.radar-center-blip.inside-geofence {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.8);
}

.radar-center-blip.outside-geofence {
    background: #ef4444;
    color: #ffffff;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.7);
}

.radar-distance-badge {
    position: relative;
    z-index: 5;
    display: inline-block;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #ffffff;
    padding: 0.25rem 0.85rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.radar-status-caption {
    font-size: 0.8rem;
    opacity: 0.85;
    letter-spacing: 0.5px;
}

/* Offline Banner */
.offline-network-banner {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50px;
    padding: 6px 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ==========================================================
   Mobile Platform Flat Screen Optimizations (v3.0)
   Designed specifically for mobile smartphones (Android & iOS)
   ========================================================== */

/* 1. Global Touch & Font Ergonomics */
html, body {
    font-family: 'SN-Kh-Menghorn', 'Khmer Batambong', 'Kantumruy Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overscroll-behavior-y: contain;
}

/* Prevent iOS Safari 300ms tap delay and auto-zoom on inputs */
button, input, select, textarea, a {
    touch-action: manipulation;
}

input.form-control, select.form-select, textarea.form-control {
    font-size: 16px !important; /* Prevents iOS auto-zoom on focus */
    border-radius: 12px;
    padding: 0.75rem 1rem;
    border: 1px solid #e2e8f0;
}

input.form-control:focus, select.form-select:focus, textarea.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

/* 2. Flat Modern Mobile Cards */
.card {
    border-radius: 1.15rem !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04) !important;
}

.card-header {
    border-bottom: 1px solid #f1f5f9 !important;
    font-size: 0.95rem;
}

/* 3. Ergonomic Mobile Punch Container */
@media (max-width: 576px) {
    .punch-container {
        padding: 1.25rem 0;
    }
    .punch-circle-btn {
        width: 165px;
        height: 165px;
    }
    .live-digital-clock {
        font-size: 1.65rem;
    }
    .mobile-hero-header {
        padding: 1.25rem 1rem 1.75rem 1rem;
    }
}

/* 4. Enhanced Mobile Bottom Navigation Bar (iPhone Notch & Android Gestures) */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(65px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1040;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #64748b;
    text-decoration: none;
    font-size: 0.72rem;
    font-weight: 600;
    flex: 1;
    padding: 0.4rem 0;
    position: relative;
    transition: all 0.2s ease;
}

.mobile-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 2px;
    transition: transform 0.2s ease;
}

.mobile-nav-item:active i {
    transform: scale(0.88);
}

.mobile-nav-item.active {
    color: #0d6efd;
}

.mobile-nav-item.active::after {
    content: '';
    position: absolute;
    top: 0;
    width: 28px;
    height: 3px;
    background: #0d6efd;
    border-radius: 0 0 3px 3px;
}

/* 5. Mobile History Flat Cards Stream */
.mobile-history-card {
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #ffffff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-history-card:active {
    transform: scale(0.99);
    background-color: #f8fafc;
}

/* 6. High-Performance Instant Feedback */
.btn:active {
    transform: scale(0.97);
}
