/**
 * PDA I68 Optimized Styles - Modern Premium Edition
 * Screen: 480x800 (4 inch)
 * Employee Time Tracking System
 * Fast, responsive with modern effects
 */

:root {
    /* Modern Color Palette */
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;

    /* Background & Cards */
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-color: #f0f4ff;
    --card-bg: rgba(255, 255, 255, 0.95);
    --card-shadow: 0 8px 32px rgba(102, 126, 234, 0.15);

    /* Text Colors */
    --text-color: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.3);

    /* OUT = ออก (Red), IN = เข้า (Green) */
    --out-color: #ef4444;
    --out-bg: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    --in-color: #10b981;
    --in-bg: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    /* Safe area for iOS notch */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

body {
    font-family: 'Sarabun', 'Segoe UI', sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-color);
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    /* Dynamic viewport height for mobile */
    -webkit-text-size-adjust: 100%;
    position: relative;
    overflow-x: hidden;
}

/* Animated background pattern */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background:
        radial-gradient(circle at 20% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.08) 0%, transparent 40%);
    pointer-events: none;
    z-index: 0;
}

/* Header - Glass morphism */
.header {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.95) 0%, rgba(79, 70, 229, 0.95) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 16px 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header h1 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    letter-spacing: 0.5px;
}

.header .guard-post-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: shimmer 3s infinite;
}

@keyframes shimmer {

    0%,
    100% {
        background: rgba(255, 255, 255, 0.25);
    }

    50% {
        background: rgba(255, 255, 255, 0.35);
    }
}

/* Main Container */
.container {
    padding: 16px;
    position: relative;
    z-index: 1;
}

/* Card - Glass morphism with premium feel */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.5);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: slideUp 0.4s ease-out;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(102, 126, 234, 0.2);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-header {
    padding: 14px 20px;
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.08) 0%, transparent 100%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.1);
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
}

.card-body {
    padding: 20px;
}

/* Input Group - Modern styling */
.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    font-weight: 600;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 16px 20px;
    font-size: 1.2rem;
    border: 2px solid rgba(99, 102, 241, 0.15);
    border-radius: 14px;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 4px 15px rgba(0, 0, 0, 0.05);
    transform: scale(1.01);
}

.input-group input::placeholder {
    color: #94a3b8;
}

/* Scan Input - Premium barcode input */
.scan-input {
    font-size: 1.5rem !important;
    font-weight: 700;
    text-align: center;
    letter-spacing: 3px;
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%) !important;
    animation: glowPulse 2s infinite;
}

@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 4px 15px rgba(99, 102, 241, 0.1);
    }

    50% {
        box-shadow: 0 4px 25px rgba(99, 102, 241, 0.25);
    }
}

/* Buttons - Modern gradient buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    font-size: 1rem;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    position: relative;
    overflow: hidden;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.35);
}

.btn-primary:active {
    transform: scale(0.98);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-out {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    font-size: 1.4rem;
    padding: 24px;
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.4);
}

.btn-out:active {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    transform: scale(0.98);
}

.btn-in {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    font-size: 1.4rem;
    padding: 24px;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
}

.btn-in:active {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    transform: scale(0.98);
}

.btn-secondary {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    color: var(--text-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Status Display - Premium glass effect */
.status-display {
    text-align: center;
    padding: 24px;
    border-radius: 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.status-display::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    animation: rotateGlow 10s linear infinite;
    pointer-events: none;
}

@keyframes rotateGlow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.status-out {
    background: var(--out-bg);
    border: 3px solid var(--out-color);
    box-shadow: 0 8px 30px rgba(239, 68, 68, 0.2);
}

.status-in {
    background: var(--in-bg);
    border: 3px solid var(--in-color);
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.2);
}

.status-display .status-icon {
    font-size: 3.5rem;
    margin-bottom: 12px;
    display: block;
    animation: bounce 1s ease-in-out;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.status-display .status-text {
    font-size: 2rem;
    font-weight: 800;
    position: relative;
    z-index: 1;
}

.status-out .status-text {
    color: var(--out-color);
    text-shadow: 0 2px 10px rgba(239, 68, 68, 0.3);
}

.status-in .status-text {
    color: var(--in-color);
    text-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.status-display .status-time {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

/* Employee Info - Premium card */
.employee-info {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(99, 102, 241, 0.1);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.03);
}

.employee-info .emp-name {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-color);
    margin-bottom: 6px;
}

.employee-info .emp-id {
    font-size: 1rem;
    color: var(--primary-color);
    font-weight: 700;
    display: inline-block;
    background: var(--primary-light);
    padding: 4px 12px;
    border-radius: 20px;
}

.employee-info .emp-dept {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Record List */
.record-list {
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) transparent;
}

.record-list::-webkit-scrollbar {
    width: 4px;
}

.record-list::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.record-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    gap: 12px;
    transition: background 0.2s ease;
}

.record-item:hover {
    background: rgba(99, 102, 241, 0.03);
}

.record-item:last-child {
    border-bottom: none;
}

.record-badge {
    padding: 6px 14px;
    border-radius: 10px;
    font-size: 0.8rem;
    font-weight: 700;
    min-width: 45px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-out {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: var(--out-color);
}

.badge-in {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: var(--in-color);
}

.record-time {
    font-size: 1.05rem;
    font-weight: 700;
    flex: 1;
    color: var(--text-color);
}

.record-duration {
    font-size: 0.85rem;
    color: var(--primary-color);
    background: var(--primary-light);
    padding: 5px 10px;
    border-radius: 8px;
    font-weight: 600;
}

.record-post {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Alert Messages - Modern style */
.alert {
    padding: 14px 18px;
    border-radius: 14px;
    margin-bottom: 16px;
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-success {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
    border: 1px solid #10b981;
}

.alert-error {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
    border: 1px solid #ef4444;
}

.alert-warning {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* Navigation Tabs */
.nav-tabs {
    display: flex;
    background: var(--card-bg);
    border-radius: 16px;
    padding: 6px;
    margin-bottom: 16px;
    box-shadow: var(--card-shadow);
}

.nav-tab {
    flex: 1;
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-muted);
    border: none;
    background: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-tab.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Guard Post Selector - Modern buttons */
.guard-post-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
}

.guard-post-btn {
    flex: 1;
    padding: 14px 10px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 14px;
    background: white;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.guard-post-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
}

.guard-post-btn:active::after {
    width: 200px;
    height: 200px;
}

.guard-post-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
}

/* Status Button Group */
.status-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.status-btn {
    padding: 10px 16px;
    border: 2px solid rgba(99, 102, 241, 0.2);
    border-radius: 12px;
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-color);
}

.status-btn:active {
    transform: scale(0.95);
}

.status-btn.active {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

/* Loading - Modern spinner */
.loading {
    display: none;
    text-align: center;
    padding: 30px;
}

.loading.show {
    display: block;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 15px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    padding: 16px 10px;
    border-radius: 16px;
    text-align: center;
    border: 1px solid rgba(99, 102, 241, 0.1);
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 6px;
    font-weight: 600;
}

/* Date Picker */
.date-picker {
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid rgba(99, 102, 241, 0.15);
    border-radius: 14px;
    width: 100%;
    transition: all 0.3s ease;
}

.date-picker:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

/* Pair List */
.pair-item {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    border: 1px solid rgba(99, 102, 241, 0.08);
}

.pair-times {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.pair-arrow {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.pair-duration {
    font-weight: 700;
    color: var(--primary-color);
}

.pair-post {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Responsive adjustments */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 10px;
    }

    .card {
        border-radius: 16px;
    }

    .btn-out,
    .btn-in {
        font-size: 1.2rem;
        padding: 20px;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-15px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Pulse animation for action buttons */
.pulse {
    animation: pulseGlow 2s infinite;
}

@keyframes pulseGlow {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    }

    50% {
        transform: scale(1.02);
        box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Summary Table */
.summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.summary-table th,
.summary-table td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.summary-table th {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.05) 0%, transparent 100%);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-table tr:last-child td {
    border-bottom: none;
}