/* Face Check-in App Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

nav a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 6px;
    transition: background 0.3s;
    font-weight: 500;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.2);
}

nav a.active {
    background: rgba(255, 255, 255, 0.3);
}

main {
    padding: 40px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-card h3 {
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 10px;
    font-weight: 500;
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
}

/* Content Sections */
.content-section {
    margin-bottom: 40px;
}

.content-section h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.8em;
}

/* Tables */
.table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

thead {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
}

td {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

tbody tr:hover {
    background: #f8f9fa;
}

.text-center {
    text-align: center;
    padding: 30px;
    color: #999;
}

/* Forms */
.form-section {
    max-width: 600px;
    margin: 0 auto;
}

.form-section h2 {
    margin-bottom: 30px;
    color: #333;
    font-size: 2em;
    text-align: center;
}

.form-group {
    margin-bottom: 25px;
}

/* Reduce margin for photo form group */
.form-group:has(.photo-options) {
    margin-bottom: 0 !important;
}

.photo-options {
    margin-top: 10px;
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="tel"],
.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 0.85em;
}

/* Buttons */
.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Button Loader */
.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

/* Messages */
.message {
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-weight: 500;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Photo Preview */
.photo-preview {
    margin-top: 10px;
    margin-bottom: 0;
    text-align: center;
}

/* Reduce gap before submit button */
.register-form button[type="submit"],
.register-form #submitBtn {
    margin-top: 0 !important;
    margin-bottom: 0;
}

/* Reduce margin for photo form group - more specific selector */
.form-group:last-of-type {
    margin-bottom: 0 !important;
}

/* Remove any extra spacing from photo options */
.photo-options {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

.tab-content {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

/* Remove gap above cropper when it's shown */
.photo-options .cropper-section {
    margin-top: 5px !important;
}

/* Ensure camera section doesn't add extra space when hidden */
.camera-section:empty,
.camera-section[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Collapse empty or hidden video containers */
.video-container-register:empty,
.video-container-register[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
}

.photo-preview img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Camera Section */
.camera-section {
    margin-bottom: 0;
    margin-top: 0;
    width: 100%;
    min-height: 0;
    padding: 0;
}

.camera-section[style*="display: none"] {
    display: none !important;
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden;
}

/* Ensure camera section can be shown when needed */
.camera-section[style*="display: block"] {
    display: block !important;
}

.camera-section:empty {
    display: none;
}

.video-container-register {
    position: relative;
    display: block;
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    min-height: 0;
}

.video-container-register {
    position: relative;
    display: block !important;
    visibility: visible !important;
    width: 100%;
    min-height: 300px; /* Ensure container has minimum height */
    margin: 10px 0;
}

.video-container-register #video {
    position: relative !important;
    width: 100%;
    max-width: 640px;
    height: auto;
    border-radius: 8px;
}

.video-container-register #outputCanvas {
    position: relative;
    width: 100%;
    max-width: 640px;
    height: auto;
    min-height: 300px; /* Ensure canvas has minimum height */
    border-radius: 8px;
    pointer-events: none;
    z-index: 10;
    background: #000;
    display: block;
    margin: 0 auto;
    visibility: visible;
    opacity: 1;
    object-fit: contain; /* Maintain aspect ratio */
    /* Mirroring is now handled in JavaScript based on camera type */
    top: auto !important;
    left: auto !important;
}

.video-container {
    position: relative;
    display: inline-block;
    width: 640px;
    height: 480px;
    margin: 0 auto 20px;
}

#video, #outputCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 640px;
    height: 480px;
    border-radius: 8px;
}

#video {
    background: #000;
    transform: scaleX(-1);      /* mirror video */
}

#outputCanvas {
    transform: scaleX(-1);      /* mirror overlay to match */
    pointer-events: none;
    z-index: 10;
}

.scanning-status {
    text-align: center;
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanning-status p {
    margin: 0;
    font-size: 1.1em;
    font-weight: 600;
}

.checkin-success {
    position: absolute;
    top: 0;
    left: 0;
    width: 640px;
    height: 480px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 255, 0, 0.3);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: slideIn 0.3s ease-out;
    border: 3px solid #00ff00;
    padding: 20px;
    box-sizing: border-box;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.checkin-success .success-content {
    width: 100%;
    max-width: 550px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.checkin-success h3 {
    font-size: 2.5em;
    margin: 0 0 25px 0;
    color: #00ff00;
    text-shadow: 0 2px 8px rgba(0, 255, 0, 0.5);
    font-weight: bold;
    text-align: center;
    width: 100%;
}

.checkin-success .attendee-info {
    background: white;
    padding: 35px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.checkin-success .attendee-info img {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 25px;
    display: block;
    border: 5px solid #00ff00;
    box-shadow: 0 4px 15px rgba(0, 255, 0, 0.4);
}

.checkin-success h4 {
    font-size: 1.8em;
    color: #333;
    margin: 0 0 15px 0;
    font-weight: 600;
    text-align: center;
    width: 100%;
}

.checkin-success #checkinTime {
    font-size: 1em;
    margin: 0;
    color: #999;
    text-align: center;
    width: 100%;
}

.checkin-success .btn-next {
    margin-top: 25px;
    padding: 15px 40px;
    font-size: 1.3em;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.checkin-success .btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.checkin-success .btn-next:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
    margin-bottom: 20px;
}

.camera-controls .btn {
    width: auto;
}

.camera-hint {
    text-align: center;
    color: #666;
    font-style: italic;
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
}

/* Captured Preview */
.captured-preview {
    margin-top: 20px;
    text-align: center;
}

.captured-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin-bottom: 15px;
}

.capture-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.capture-actions .btn {
    width: auto;
    min-width: 150px;
}

/* Upload Section */
.upload-section {
    text-align: center;
    padding: 20px 0;
}

.upload-section .btn {
    width: auto;
    min-width: 200px;
}

.file-name {
    margin-top: 10px;
    padding: 10px;
    background: #e9ecef;
    border-radius: 6px;
    color: #495057;
    font-weight: 500;
}

/* Check-in Result */
.checkin-result {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
    border-left: 4px solid #667eea;
}

.checkin-result h3 {
    margin-bottom: 15px;
    color: #333;
}

.result-info p {
    margin-bottom: 10px;
    font-size: 1.05em;
}

.result-info strong {
    color: #667eea;
}

/* Photo Options Tabs */
.photo-options {
    margin-top: 10px;
    margin-bottom: 0;
}

.option-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 10px 20px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    color: #666;
}

.tab-btn:hover {
    border-color: #667eea;
    color: #667eea;
}

.tab-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Cropper Section */
.cropper-section {
    margin-top: 0 !important;
    margin-bottom: 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

.cropper-section h4 {
    margin-top: 0;
    margin-bottom: 15px;
    color: #333;
}

.cropper-container {
    max-width: 100%;
    margin-bottom: 15px;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f0f0f0;
    border-radius: 8px;
    min-height: 300px;
    position: relative;
}

.cropper-container img {
    max-width: 100%;
    max-height: 500px;
    display: block;
    width: auto;
    height: auto;
}

.cropper-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.cropper-controls .btn {
    width: auto;
    min-width: 120px;
}

/* Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        border-radius: 8px;
        margin: 0;
    }

    header {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.8em;
        margin-bottom: 15px;
    }

    nav {
        gap: 10px;
        flex-wrap: wrap;
    }

    nav a {
        padding: 8px 15px;
        font-size: 0.9em;
    }

    main {
        padding: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table-container {
        font-size: 0.9em;
    }

    th, td {
        padding: 10px;
    }

    .option-tabs {
        flex-direction: column;
    }

    .cropper-controls {
        flex-direction: column;
    }

    .cropper-controls .btn {
        width: 100%;
    }

    .video-container {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 300px !important;
        aspect-ratio: 4/3;
        position: relative;
        margin: 0 auto 15px;
    }

    #video, #outputCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        position: absolute;
        top: 0;
        left: 0;
        object-fit: cover;
    }

    .video-container-register {
        display: block !important;
        visibility: visible !important;
        min-height: 400px !important; /* Increased height for mobile */
        width: 100% !important;
        margin: 15px 0 !important;
    }

    .video-container-register #outputCanvas {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        width: 100% !important;
        max-width: 100% !important;
        min-height: 400px !important; /* Increased height for mobile */
        height: auto !important;
        aspect-ratio: 4/3; /* Maintain 4:3 aspect ratio */
        object-fit: contain !important;
    }

    .camera-section {
        display: block !important;
        visibility: visible !important;
        min-height: 450px !important; /* Ensure section has enough height */
    }

    .video-container-register #video {
        min-height: 400px !important;
        aspect-ratio: 4/3;
        object-fit: contain;
    }

    /* Check-in Page Mobile Styles */
    .form-section h2 {
        font-size: 1.5em;
        margin-bottom: 20px;
    }

    .video-container {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 300px !important;
        aspect-ratio: 4/3;
        position: relative;
        margin: 0 auto;
    }

    #video, #outputCanvas {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        object-fit: cover;
    }

    .checkin-success {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        min-height: 300px !important;
        position: absolute;
        top: 0;
        left: 0;
        padding: 15px !important;
        border-radius: 8px;
    }

    .checkin-success h3 {
        font-size: 1.5em !important;
        margin: 0 0 15px 0 !important;
        line-height: 1.2;
    }

    .checkin-success .success-content {
        padding: 15px !important;
        max-width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: space-between !important;
        min-height: 100% !important;
        box-sizing: border-box !important;
    }

    .checkin-success .attendee-info {
        padding: 20px 15px !important;
        margin: 10px 0;
        flex: 1;
    }

    .checkin-success .attendee-info img {
        width: 120px !important;
        height: 120px !important;
        margin-bottom: 15px !important;
        border-width: 4px !important;
    }

    .checkin-success h4 {
        font-size: 1.3em !important;
        margin: 0 0 10px 0 !important;
    }

    .checkin-success #checkinTime {
        font-size: 0.9em !important;
        margin: 0 !important;
    }

    .checkin-success .btn-next {
        padding: 12px 25px !important;
        font-size: 1em !important;
        margin-top: 15px !important;
        margin-bottom: 10px !important;
        width: auto !important;
        min-width: 120px !important;
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        z-index: 10 !important;
        flex-shrink: 0 !important;
    }

    .scanning-status {
        padding: 10px !important;
        font-size: 0.9em !important;
    }

    .scanning-status p {
        font-size: 0.95em !important;
    }

    .camera-section {
        width: 100%;
        margin: 0 auto;
    }

    /* Ensure container doesn't overflow on mobile */
    .container {
        padding: 10px;
    }

    main {
        padding: 15px;
    }

    .form-section {
        padding: 15px;
    }
}

