/* PITC Attendance PWA Custom Styles */

/* Root Variables */
:root {
    --primary-color: #1f2937;
    --secondary-color: #3b82f6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --background-gray: #f9fafb;
    --border-gray: #e5e7eb;
}

/* Global Styles */
* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--background-gray);
    margin: 0;
    padding: 0;
}

/* PWA Specific Styles */
@media (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .navbar {
        padding-top: calc(env(safe-area-inset-top) + 1rem);
    }
}

/* Mobile-First Responsive Design */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* QR Code Display Optimization */
    .qr-container {
        max-width: 280px;
        margin: 0 auto;
    }
    
    .qr-container img {
        width: 100%;
        height: auto;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    
    /* Scan Page Camera Optimization */
    .camera-container {
        position: relative;
        width: 100%;
        max-width: 400px;
        margin: 0 auto;
        border-radius: 12px;
        overflow: hidden;
        background: #000;
    }
    
    .camera-container video {
        width: 100%;
        height: auto;
        display: block;
    }
    
    /* Button Optimization for Touch */
    .btn-touch {
        min-height: 48px;
        min-width: 48px;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.2s ease;
        touch-action: manipulation;
    }
    
    .btn-touch:active {
        transform: scale(0.98);
    }
}

/* Scanner Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.scanner-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid var(--secondary-color);
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.1);
}

.scanner-box::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    border: 2px solid rgba(59, 130, 246, 0.3);
    border-radius: 12px;
    animation: scanner-pulse 2s infinite;
}

@keyframes scanner-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.05);
    }
}

/* Fullscreen QR Modal */
.qr-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 2rem;
}

.qr-fullscreen-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.qr-fullscreen img {
    max-width: 100%;
    max-height: 60vh;
    border-radius: 8px;
}

/* Status Indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-present {
    background-color: #dcfce7;
    color: #166534;
}

.status-late {
    background-color: #fef3c7;
    color: #92400e;
}

.status-absent {
    background-color: #fee2e2;
    color: #991b1b;
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: var(--warning-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slide-in-left 0.3s ease;
}

@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Sync Status */
.sync-status {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--success-color);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    animation: slide-in-right 0.3s ease, fade-out 0.3s ease 2.7s forwards;
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fade-out {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Dashboard Cards */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
}

.stat-icon.blue {
    background: #dbeafe;
    color: #2563eb;
}

.stat-icon.green {
    background: #dcfce7;
    color: #16a34a;
}

.stat-icon.yellow {
    background: #fef3c7;
    color: #d97706;
}

.stat-icon.red {
    background: #fee2e2;
    color: #dc2626;
}

/* Form Enhancements */
.form-input {
    appearance: none;
    border: 1px solid var(--border-gray);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input:invalid {
    border-color: var(--error-color);
}

/* File Upload Styling */
.file-upload {
    position: relative;
    display: inline-block;
    cursor: pointer;
    width: 100%;
}

.file-upload input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.file-upload-label {
    display: block;
    padding: 2rem;
    border: 2px dashed var(--border-gray);
    border-radius: 8px;
    text-align: center;
    background: white;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.file-upload:hover .file-upload-label {
    border-color: var(--secondary-color);
    background: #f8fafc;
}

.file-upload.active .file-upload-label {
    border-color: var(--secondary-color);
    background: #eff6ff;
}

/* Loading Animations */
.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    border-top-color: var(--secondary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn-touch {
        border: 2px solid currentColor;
    }
    
    .stat-card {
        border: 1px solid var(--border-gray);
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .stat-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* Tablet Styles */
@media (min-width: 768px) and (max-width: 1024px) {
    .camera-container {
        max-width: 500px;
    }
    
    .qr-container {
        max-width: 350px;
    }
}

/* Desktop Styles */
@media (min-width: 1025px) {
    .camera-container {
        max-width: 600px;
    }
    
    .qr-container {
        max-width: 400px;
    }
}
