/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #003d82;
    --secondary-color: #ff6b35;
    --accent-color: #f7931e;
    --text-dark: #333;
    --text-light: #666;
    --background: #f5f5f5;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: url('assets/img/bg.jpg') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    position: relative;
    overflow: hidden;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 0;
}

.container {
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    z-index: 1;
    color: var(--white);
}

/* Screen Management */
.screen {
    display: none;
    padding: 40px;
    width: 100%;
    height: 100vh;
    min-height: 100vh;
    animation: fadeIn 0.5s ease-in;
    overflow-y: auto;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Welcome Screen */
.welcome-content {
    text-align: center;
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
}

.logo-container {
    margin-bottom: 30px;
    animation: fadeInDown 1s ease-out;
    position: relative;
}

.logo-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 500px;
    height: 500px;
    background: radial-gradient(
        circle,
        rgba(255, 255, 255, 0.4) 0%,
        rgba(255, 255, 255, 0.2) 30%,
        rgba(255, 255, 255, 0.05) 60%,
        transparent 80%
    );
    border-radius: 50%;
    z-index: -1;
    filter: blur(30px);
}

.aai-logo {
    max-width: 400px;
    width: 35%;
    height: auto;
    display: inline-block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    position: relative;
    z-index: 1;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-content h1 {
    font-size: 4em;
    color: var(--white);
    margin-bottom: 20px;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.welcome-content h2 {
    font-size: 3em;
    color: var(--white);
    margin-bottom: 30px;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.welcome-content p {
    font-size: 1.8em;
    color: var(--white);
    margin-bottom: 60px;
    line-height: 1.5;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Buttons */
.btn-primary, .btn-secondary {
    padding: 25px 80px;
    font-size: 1.8em;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    margin: 10px;
    min-width: 300px;
}

.btn-primary {
    background: var(--primary-color);
    color: var(--white);
}

.btn-primary:hover {
    background: #002a5c;
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.btn-secondary {
    background: var(--text-light);
    color: var(--white);
}

.btn-secondary:hover {
    background: #555;
}

/* Form Styles */
.form-content {
    width: 100%;
    max-width: 800px;
    padding: 0 40px;
}

.form-content h2 {
    color: var(--white);
    margin-bottom: 40px;
    text-align: center;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.form-content form {
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.form-content button {
    align-self: center;
    margin-top: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 12px;
    color: var(--white);
    font-weight: 600;
    font-size: 1.5em;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.form-group input {
    width: 100%;
    padding: 20px 25px;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-size: 1.5em;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Role Selection */
.role-content {
    width: 100%;
    padding: 0 40px;
}

.role-content h2 {
    color: var(--white);
    margin-bottom: 50px;
    text-align: center;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    max-width: 100%;
    margin: 0 auto;
}

.role-card {
    background: var(--white);
    border: 4px solid #e0e0e0;
    border-radius: 20px;
    padding: 40px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.role-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.role-card.selected {
    border-color: var(--secondary-color);
    background: #fff5f2;
}

.role-icon {
    font-size: 5em;
    margin-bottom: 20px;
}

.role-name {
    font-size: 1.6em;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.4;
}

/* Camera Screen */
.camera-content {
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
}

.camera-content h2 {
    color: var(--white);
    margin-bottom: 40px;
    text-align: center;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.camera-container {
    position: relative;
    width: 100%;
    max-width: 900px;
    margin: 0 auto 40px;
    border-radius: 20px;
    overflow: hidden;
    background: #000;
}

#video {
    width: 100%;
    display: block;
    border-radius: 15px;
    transform: scaleX(-1);
}

#canvas {
    display: none;
}

.countdown {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 10em;
    color: var(--white);
    font-weight: bold;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    display: none;
    animation: pulse 1s ease-in-out;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); }
    50% { transform: translate(-50%, -50%) scale(1.2); }
}

.camera-controls {
    text-align: center;
}

/* Preview Screen */
.preview-content {
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
}

.preview-content h2 {
    color: var(--white);
    margin-bottom: 40px;
    text-align: center;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.preview-container {
    position: relative;
    width: 100%;
    max-width: 700px;
    margin: 0 auto 40px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}

.preview-container img {
    width: 100%;
    height: auto;
    display: block;
}

.preview-controls {
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
}

/* Processing Screen */
.processing-content {
    text-align: center;
    max-width: 100%;
    width: 100%;
    padding: 0 40px;
}

.processing-content h2 {
    color: var(--white);
    margin-bottom: 50px;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.spinner-large {
    width: 120px;
    height: 120px;
    border: 12px solid #f3f3f3;
    border-top: 12px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#processingStatus {
    font-size: 1.8em;
    color: var(--white);
    margin: 30px 0;
    font-weight: 500;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.progress-steps {
    display: flex;
    justify-content: space-around;
    margin-top: 40px;
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0.3;
    transition: opacity 0.5s;
}

.step.active {
    opacity: 1;
}

.step-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--primary-color);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: bold;
    margin-bottom: 15px;
}

.step-label {
    font-size: 1.4em;
    color: var(--white);
    font-weight: 500;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

/* Result Screen */
.result-content {
    width: 100%;
    max-width: 100%;
    padding: 0 40px;
}

.result-content h2 {
    color: var(--white);
    margin-bottom: 50px;
    text-align: center;
    font-size: 3em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.result-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    margin-bottom: 40px;
    width: 100%;
}

.avatar-image {
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    max-width: 700px;
    width: 100%;
}

.avatar-image img {
    width: 100%;
    height: auto;
    display: block;
}

.qr-code {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 500px;
    width: 100%;
}

.qr-code h3 {
    color: var(--white);
    margin-bottom: 30px;
    font-size: 2em;
    font-weight: 700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.qr-code img {
    width: 300px;
    height: 300px;
    margin-bottom: 20px;
    border: 8px solid var(--white);
    border-radius: 15px;
}

.qr-code p {
    font-size: 1.3em;
    color: var(--white);
    line-height: 1.5;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5);
}

.result-actions {
    text-align: center;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid var(--white);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-overlay p {
    color: var(--white);
    font-size: 1.2em;
}

/* Error Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    color: var(--secondary-color);
    margin-bottom: 20px;
    font-size: 1.8em;
}

.modal-content p {
    color: var(--text-dark);
    margin-bottom: 30px;
    font-size: 1.1em;
}

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

    .container {
        border-radius: 0;
        min-height: 100vh;
    }

    .screen {
        padding: 20px;
    }

    .aai-logo {
        max-width: 180px;
    }

    .welcome-content h1 {
        font-size: 2em;
    }

    .welcome-content h2 {
        font-size: 1.5em;
    }

    .role-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 15px;
    }

    .result-display {
        flex-direction: column;
    }

    .avatar-image {
        max-width: 90%;
    }

    .qr-code {
        max-width: 90%;
    }

    .btn-primary, .btn-secondary {
        padding: 12px 30px;
        font-size: 1em;
    }

    .progress-steps {
        flex-direction: column;
        gap: 20px;
    }

    .step {
        flex-direction: row;
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .aai-logo {
        max-width: 150px;
    }

    .logo-container {
        margin-bottom: 20px;
    }

    .welcome-content h1 {
        font-size: 1.5em;
    }

    .welcome-content p {
        font-size: 1em;
    }

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

    .qr-code img {
        width: 150px;
        height: 150px;
    }
}

/* Touch-friendly enhancements */
@media (hover: none) and (pointer: coarse) {
    .btn-primary, .btn-secondary, .role-card {
        -webkit-tap-highlight-color: transparent;
    }

    .role-card {
        padding: 25px;
    }

    .btn-primary, .btn-secondary {
        padding: 18px 40px;
    }
}
