/* Veriglobe Face Verification System - Mobile-First Responsive Design */

/* Reset and base styles */
* {
    box-sizing: border-box;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mobile-first responsive design */
@media screen and (max-width: 768px) {
    .mobile-device .camera-container {
        height: 280px !important;
        border-radius: 16px;
        overflow: hidden;
    }
    
    .mobile-device .face-oval-overlay {
        width: 180px !important;
        height: 220px !important;
        border-width: 2px;
    }
    
    .mobile-device .capture-btn {
        position: fixed;
        bottom: 20px;
        left: 16px;
        right: 16px;
        z-index: 50;
        margin: 0;
        border-radius: 50px;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25);
        min-height: 56px;
        font-size: 16px;
        font-weight: 600;
        backdrop-filter: blur(10px);
    }
    
    .mobile-device .mobile-header {
        position: sticky;
        top: 0;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        z-index: 40;
        border-bottom: 1px solid #e5e7eb;
        padding: 16px;
        margin: -16px -16px 16px -16px;
    }
    
    /* Optimize touch targets */
    .mobile-device button {
        min-height: 44px;
        touch-action: manipulation;
    }
    
    /* Prevent zoom on input focus */
    .mobile-device input[type="text"],
    .mobile-device input[type="email"],
    .mobile-device input[type="password"],
    .mobile-device textarea {
        font-size: 16px;
    }
    
    /* Improve scrolling performance */
    .mobile-device {
        -webkit-overflow-scrolling: touch;
    }
}

/* Camera and video styles */
.camera-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    background: #1f2937;
}

.camera-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror front camera */
}

.camera-container video[data-facing="environment"] {
    transform: none; /* Don't mirror rear camera */
}

/* Face oval guide */
.face-oval-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;
    height: 280px;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    z-index: 10;
    pointer-events: none;
    animation: pulse-border 2s infinite;
}

@keyframes pulse-border {
    0%, 100% {
        border-color: rgba(255, 255, 255, 0.8);
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        border-color: rgba(59, 130, 246, 0.8);
        transform: translate(-50%, -50%) scale(1.02);
    }
}

/* ID frame guide */
.id-frame-guide {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    border: 2px dashed rgba(255, 255, 255, 0.7);
    border-radius: 12px;
    pointer-events: none;
}

.id-frame-guide::before {
    content: "Position your ID here";
    position: absolute;
    top: -30px;
    left: 0;
    color: white;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Enhanced button styles */
.capture-btn {
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.capture-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;
}

.capture-btn:hover:before {
    left: 100%;
}

.capture-btn:active {
    transform: scale(0.98);
}

/* Pulse animation for active capture state */
.pulse-animation {
    animation: pulse-glow 1.5s ease-in-out infinite alternate;
}

@keyframes pulse-glow {
    from {
        box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    }
    to {
        box-shadow: 0 8px 30px rgba(59, 130, 246, 0.8);
    }
}

/* Success checkmark animation */
.success-checkmark {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: block;
    stroke-width: 2;
    stroke: #10b981;
    stroke-miterlimit: 10;
    box-shadow: inset 0px 0px 0px #10b981;
    animation: fill 0.4s ease-in-out 0.4s forwards, scale 0.3s ease-in-out 0.9s both;
    margin: 0 auto;
}

.success-checkmark circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: #10b981;
    fill: none;
    animation: stroke 0.6s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.success-checkmark path {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    animation: stroke 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

@keyframes stroke {
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes scale {
    0%, 100% {
        transform: none;
    }
    50% {
        transform: scale3d(1.1, 1.1, 1);
    }
}

@keyframes fill {
    100% {
        box-shadow: inset 0px 0px 0px 30px #10b981;
    }
}

/* Loading dots animation */
.loading-dots {
    display: inline-block;
}

.loading-dots:after {
    overflow: hidden;
    display: inline-block;
    vertical-align: bottom;
    animation: ellipsis 2s infinite;
    content: "\2026";
    width: 0px;
}

@keyframes ellipsis {
    from {
        width: 2px;
    }
    to {
        width: 15px;
    }
}

/* Enhanced focus styles for accessibility */
button:focus,
a:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Smooth transitions */
.transition-all {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .face-oval-overlay {
        border-width: 4px;
        border-color: #ffffff;
    }
    
    .id-frame-guide {
        border-width: 3px;
        border-color: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .pulse-animation,
    .pulse-border,
    .loading-dots:after {
        animation: none;
    }
    
    .transition-all,
    .capture-btn {
        transition: none;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #0f172a;
        color: #f8fafc;
    }
    
    .bg-white {
        background-color: #1e293b !important;
        color: #f8fafc !important;
    }
    
    .text-gray-900 {
        color: #f8fafc !important;
    }
    
    .text-gray-600 {
        color: #94a3b8 !important;
    }
    
    .border {
        border-color: #334155 !important;
    }
}

/* Performance optimizations */
.camera-container,
.camera-container video {
    will-change: transform;
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Prevent text selection on UI elements */
.capture-btn,
.face-oval-overlay,
.id-frame-guide {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Enhanced error and success notifications */
.notification-enter {
    transform: translateY(-100%) scale(0.95);
    opacity: 0;
}

.notification-enter-active {
    transform: translateY(0) scale(1);
    opacity: 1;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification-exit {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.notification-exit-active {
    transform: translateY(-100%) scale(0.95);
    opacity: 0;
    transition: all 0.3s ease-in;
}

/* Address verification specific mobile styles */
@media screen and (max-width: 768px) {
    .address-verification-form textarea {
        font-size: 16px !important; /* Prevent iOS zoom on focus */
        line-height: 1.5;
        min-height: 120px;
    }
    
    .address-verification-form .file-upload-area {
        padding: 1.5rem 1rem !important;
    }
    
    .address-verification-form .file-info {
        font-size: 14px;
        padding: 0.75rem;
    }
    
    .address-verification-form .action-buttons {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        margin: 0 -1rem -1rem -1rem;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    }
    
    .address-verification-form .mobile-header {
        position: sticky;
        top: 0;
        z-index: 10;
        background: white;
        backdrop-filter: blur(10px);
    }
}

/* Utility bill upload area enhancements */
.file-upload-area {
    transition: all 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.file-upload-area.drag-over {
    border-color: #2563eb;
    background-color: #eff6ff;
    transform: scale(1.01);
}

/* Form input focus states for mobile */
input:focus, textarea:focus, select:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Mobile touch target improvements */
@media (pointer: coarse) {
    button, 
    a[role="button"],
    label[for] {
        min-height: 44px;
        min-width: 44px;
    }
    
    input[type="checkbox"],
    input[type="radio"] {
        width: 24px;
        height: 24px;
    }
}

/* Loading state for file upload */
.file-upload-loading {
    position: relative;
    overflow: hidden;
}

.file-upload-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Success state animation */
.upload-success {
    animation: success-pulse 0.6s ease-in-out;
}

@keyframes success-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Step wizard animations */
.step-enter {
    opacity: 0;
    transform: translateX(20px);
}

.step-enter-active {
    opacity: 1;
    transform: translateX(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.step-exit {
    opacity: 1;
    transform: translateX(0);
}

.step-exit-active {
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Step indicator animations */
.step-indicator.active {
    animation: step-pulse 2s infinite;
}

@keyframes step-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(59, 130, 246, 0);
    }
}

/* Progress bar animation */
.progress-bar-fill {
    transition: width 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Mobile step wizard optimizations */
@media screen and (max-width: 768px) {
    .step-wizard .step-content {
        padding: 1rem;
    }
    
    .step-wizard .action-buttons {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        margin: 0 -1rem -1rem -1rem;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
    }
    
    .step-wizard .step-indicators {
        padding: 0.5rem;
    }
}

/* File upload success state */
.file-upload-success {
    border-color: #10b981 !important;
    background-color: #ecfdf5 !important;
    animation: file-success 0.6s ease;
}

@keyframes file-success {
    0% {
        transform: scale(0.95);
    }
    50% {
        transform: scale(1.02);
    }
    100% {
        transform: scale(1);
    }
}

/* Review card styling */
.review-card {
    border-left: 4px solid #3b82f6;
    background: linear-gradient(to right, #f8fafc, #ffffff);
}

.review-card h3 {
    position: relative;
    padding-left: 1rem;
}

.review-card h3::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 16px;
    background: #3b82f6;
    border-radius: 2px;
}

/* Mobile-specific improvements for index.php verification steps */
@media screen and (max-width: 768px) {
    /* Verification steps card mobile optimization */
    .verification-step-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .verification-step-card:active {
        transform: scale(0.99);
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }
    
    /* Improve tap targets for verification steps */
    a[href] .flex.items-center.justify-between {
        min-height: 72px; /* Ensure large tap area */
    }
    
    /* Optimize text for small screens */
    .text-gray-600.text-sm {
        font-size: 0.8125rem;
        line-height: 1.25rem;
    }
    
    /* Adjust spacing for mobile */
    .space-y-4 > * + * {
        margin-top: 0.75rem;
    }
    
    /* Improve button appearance on mobile */
    button[name="complete_verification"] {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
        font-weight: 600;
        letter-spacing: 0.025em;
    }
    
    /* Ensure images don't overflow on mobile */
    img.mx-auto {
        max-width: 100%;
        height: auto;
    }
    
    /* Improve readability on small screens */
    .text-center p.text-gray-500 {
        font-size: 0.75rem;
    }
    
    /* Add bottom padding for devices with home indicators */
    .pb-safe {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    }
    
    /* Prevent text from being too close to screen edges */
    .container.mx-auto.px-4 {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* Tablet optimizations */
@media screen and (min-width: 769px) and (max-width: 1024px) {
    .container.mx-auto.px-4 {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .max-w-3xl {
        max-width: 90%;
    }
}

/* Improve hover states for non-touch devices */
@media (hover: hover) and (pointer: fine) {
    a[href]:hover .bg-white {
        background-color: #f9fafb !important;
    }
}

/* Animation for completed verification success message */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bg-green-50.border-green-200.rounded-lg {
    animation: slideUp 0.3s ease-out;
}

/* Loading state for buttons */
button.loading {
    position: relative;
    color: transparent;
}

button.loading::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
    transform: translate(-50%, -50%);
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Focus states for accessibility */
:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Improve contrast for better readability */
@media (prefers-contrast: high) {
    .text-gray-600 {
        color: #374151 !important;
    }
    
    .text-gray-900 {
        color: #111827 !important;
    }
}