/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: #000;
    color: #fff;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Main Screen Container */
#screen-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Face Container (Old 2D - Hidden) */
#face-container {
    display: none !important; /* Hide old 2D face */
    /* Original styles kept for reference if needed later */
    /*
    position: relative;
    width: 400px;
    height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    */
}

/* New 3D Face Canvas Container */
#3d-face-canvas-container {
    position: relative; /* Or absolute if it needs to overlay other things */
    width: 400px; /* Match old face-container size for now */
    height: 300px; /* Match old face-container size for now */
    display: flex;
    align-items: center;
    justify-content: center;
    /* background: #1a1a1a; */ /* Optional: for debugging canvas area */
}

#3d-face-canvas {
    display: block; /* Remove extra space below canvas */
    width: 100%;
    height: 100%;
}

/* Eyes Container */
#eyes-container {
    display: flex;
    gap: 80px;
    margin-bottom: 60px;
}

/* Eye Styles */
.eye {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: #fff;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    border: 3px solid #333;
}

.eye.sleeping {
    height: 8px;
    border-radius: 40px;
    background: #333;
    border: none;
}

.eye.sleeping .eyeball {
    display: none;
}

.eyeball {
    width: 100%;
    height: 100%;
    background: #fff;
    border-radius: 50%;
    position: relative;
    transition: transform 0.1s ease;
}

.pupil {
    width: 30px;
    height: 30px;
    background: #000;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: all 0.1s ease;
}

/* Eye Animations */
.eye.blinking {
    animation: blink 0.3s ease;
}

@keyframes blink {
    0%, 100% { height: 80px; }
    50% { height: 8px; }
}

.eye.surprised {
    width: 100px;
    height: 100px;
}

.eye.happy {
    border-bottom: 8px solid #333;
    height: 60px;
}

/* Mouth Container */
#mouth-container {
    position: relative;
}

/* Mouth Styles */
#mouth {
    width: 120px;
    height: 60px;
    border-radius: 0 0 60px 60px;
    background: #333;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.mouth-closed {
    height: 8px;
    border-radius: 60px;
    background: #333;
}

.mouth-open {
    height: 60px;
    border-radius: 0 0 60px 60px;
    background: #222;
}

.mouth-talking {
    animation: talking 0.5s ease infinite alternate;
}

.mouth-inner {
    width: 80%;
    height: 80%;
    background: #111;
    border-radius: 0 0 40px 40px;
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
}

@keyframes talking {
    0% { height: 20px; }
    100% { height: 50px; }
}

/* Mouth Expressions */
.mouth-smile {
    border-radius: 60px 60px 0 0;
    background: #333;
    height: 30px;
}

.mouth-surprised {
    width: 40px;
    height: 60px;
    border-radius: 50%;
    background: #222;
}

/* Hide ALL UI Elements - Clean Interface */
#conversation-interface,
#status-container,
#send-button,
#voice-button,
#user-input,
#input-container,
#conversation-display,
#ai-response {
    display: none !important;
}

/* Verification Tools Styles */
#verification-tools {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.verification-tool {
    background: rgba(34, 34, 34, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    min-width: 220px;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.verification-tool:hover {
    background: rgba(34, 34, 34, 1);
    border-color: rgba(255, 255, 255, 0.2);
}

.tool-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.tool-title {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tool-toggle {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    transition: all 0.2s ease;
}

.tool-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Camera Preview Styles */
.preview-window {
    position: relative;
    width: 200px;
    height: 150px;
    border-radius: 8px;
    overflow: hidden;
    background: #111;
}

#camera-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transform: scaleX(-1); /* Mirror the video preview */
}

.preview-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    padding: 8px;
    text-align: center;
}

.preview-status {
    font-size: 10px;
    color: #28a745;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Microphone Meter Styles */
.meter-window {
    width: 200px;
    padding: 8px;
}

.meter-display {
    margin-bottom: 8px;
}

.meter-bar {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.meter-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #28a745 0%, #ffc107 70%, #dc3545 100%);
    border-radius: 10px;
    transition: width 0.1s ease;
    position: relative;
}

.meter-fill::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 2px;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

.meter-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.meter-label {
    font-size: 9px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.meter-status {
    text-align: center;
    margin-top: 8px;
}

#meter-status-text {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

/* Verification Controls */
#verification-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.control-btn {
    background: rgba(0, 123, 255, 0.8);
    border: 1px solid rgba(0, 123, 255, 0.5);
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    padding: 8px 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
}

.control-btn:hover {
    background: rgba(0, 123, 255, 1);
    border-color: rgba(0, 123, 255, 0.8);
    transform: translateY(-1px);
}

.control-btn:active {
    transform: translateY(0);
}

/* Hidden state for verification tools */
#verification-tools.hidden-tools .verification-tool {
    display: none;
}

#verification-tools.hidden-tools #verification-controls {
    display: flex;
}

/* Modal Styles - Keep for camera permission */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(5px);
    cursor: pointer;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #222;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 500px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    cursor: default;
    position: relative;
}

/* Modal close button */
.modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    line-height: 1;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: rgba(255, 255, 255, 0.9);
}

/* Hide verification tools when modal is open */
body.modal-open #verification-tools {
    display: none !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #fff;
    font-size: 24px;
}

.modal-content p {
    margin-bottom: 30px;
    color: rgba(255, 255, 255, 0.8);
    line-height: 1.5;
}

.modal-content button {
    margin: 8px 5px;
    padding: 15px 20px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.3s ease;
    min-height: 50px;
    min-width: 140px;
    display: inline-block;
    text-align: center;
}

/* Permission Button Styles */
.permission-btn.primary {
    background: #28a745;
    color: #fff;
    border: 2px solid #28a745;
}

.permission-btn.primary:hover {
    background: #1e7e34;
    border-color: #1e7e34;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.permission-btn.primary:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.permission-btn.secondary {
    background: #007bff;
    color: #fff;
    border: 2px solid #007bff;
}

.permission-btn.secondary:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.permission-btn.secondary:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.permission-btn.tertiary {
    background: transparent;
    color: #fff;
    border: 2px solid #6c757d;
}

.permission-btn.tertiary:hover {
    background: #6c757d;
    border-color: #6c757d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.permission-btn.tertiary:disabled {
    background: transparent;
    color: #6c757d;
    border-color: #495057;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Legacy button support */
#grant-permission {
    background: #28a745;
    color: #fff;
}

#grant-permission:hover {
    background: #1e7e34;
}

#deny-permission {
    background: #6c757d;
    color: #fff;
}

#deny-permission:hover {
    background: #545b62;
}

/* Permission info styling */
.permission-info {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

/* Loading Screen */
#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

#loading-screen.hidden {
    display: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading-screen p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.8);
}

/* Device Selection Modal Styles */
#device-selection-modal .modal-content {
    max-width: 600px;
    width: 95%;
}

.device-selection-section {
    margin: 20px 0;
    text-align: left;
}

.device-selection-section h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-list {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 15px;
    min-height: 80px;
}

.device-loading {
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    text-align: center;
    padding: 20px;
}

.device-option {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.device-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.device-option.selected {
    background: rgba(40, 167, 69, 0.2);
    border-color: #28a745;
}

.device-option input[type="radio"] {
    margin-right: 12px;
    transform: scale(1.2);
}

.device-info {
    flex: 1;
}

.device-name {
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.device-details {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.device-test-section {
    margin: 20px 0;
    text-align: center;
}

.test-result {
    margin-top: 10px;
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
}

.test-result.success {
    background: rgba(40, 167, 69, 0.2);
    color: #28a745;
    border: 1px solid #28a745;
}

.test-result.error {
    background: rgba(220, 53, 69, 0.2);
    color: #dc3545;
    border: 1px solid #dc3545;
}

.device-btn {
    background: #007bff;
    color: #fff;
    border: 2px solid #007bff;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px;
    min-width: 140px;
}

.device-btn.primary {
    background: #28a745;
    border-color: #28a745;
}

.device-btn.primary:hover {
    background: #1e7e34;
    border-color: #1e7e34;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.device-btn.secondary {
    background: #007bff;
    border-color: #007bff;
}

.device-btn.secondary:hover {
    background: #0056b3;
    border-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.device-btn.tertiary {
    background: transparent;
    border-color: #6c757d;
}

.device-btn.tertiary:hover {
    background: #6c757d;
    border-color: #6c757d;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.3);
}

.device-btn:disabled {
    background: #6c757d;
    border-color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.device-info {
    margin-top: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border-left: 4px solid #007bff;
}

.selected-devices-summary {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    text-align: left;
}

.selected-device {
    display: flex;
    align-items: center;
    margin: 8px 0;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
}

.device-icon {
    margin-right: 12px;
    font-size: 18px;
}

/* Responsive Design */
@media (max-width: 768px) {
    #face-container {
        width: 300px;
        height: 250px;
    }
    
    #eyes-container {
        gap: 60px;
        margin-bottom: 40px;
    }
    
    .eye {
        width: 60px;
        height: 60px;
    }
    
    .pupil {
        width: 24px;
        height: 24px;
    }
    
    #mouth {
        width: 100px;
        height: 50px;
    }
    
    /* Mobile Verification Tools */
    #verification-tools {
        top: 10px;
        right: 10px;
        left: 10px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
    }
    
    .verification-tool {
        min-width: 160px;
        flex: 1;
        margin: 0 5px;
    }
    
    .preview-window {
        width: 140px;
        height: 105px;
    }
    
    .meter-window {
        width: 140px;
    }
    
    /* Mobile Permission Modal */
    .modal-content {
        padding: 30px 20px;
        max-width: 90%;
        margin: 20px;
    }
    
    .modal-content h2 {
        font-size: 20px;
        margin-bottom: 15px;
    }
    
    .modal-content button {
        display: block;
        width: 100%;
        margin: 10px 0;
        min-height: 55px;
        font-size: 18px;
    }
    
    .permission-info {
        margin-top: 15px;
        padding: 12px;
    }
    
    /* Mobile Device Selection */
    #device-selection-modal .modal-content {
        max-width: 95%;
        padding: 20px 15px;
    }
    
    .device-btn {
        display: block;
        width: 100%;
        margin: 8px 0;
        min-width: auto;
    }
}

/* Tablet Landscape */
@media (orientation: landscape) and (max-height: 768px) {
    #face-container {
        width: 350px;
        height: 200px;
    }
    
    #eyes-container {
        margin-bottom: 30px;
    }
    
    /* Landscape Verification Tools */
    #verification-tools {
        top: 15px;
        right: 15px;
    }
    
    .verification-tool {
        min-width: 180px;
    }
    
    .preview-window {
        width: 160px;
        height: 120px;
    }
    
    .meter-window {
        width: 160px;
    }
    
    /* Landscape Permission Modal */
    .modal-content {
        max-width: 600px;
        padding: 25px;
    }
    
    .modal-content button {
        display: inline-block;
        width: auto;
        margin: 5px 8px;
        min-width: 160px;
        min-height: 55px;
        font-size: 16px;
    }
}

/* Tablet Portrait */
@media (orientation: portrait) and (min-width: 768px) and (max-width: 1024px) {
    .modal-content {
        max-width: 500px;
        padding: 35px;
    }
    
    .modal-content button {
        min-height: 60px;
        min-width: 150px;
        font-size: 17px;
        margin: 8px 6px;
    }
    
    .modal-content h2 {
        font-size: 26px;
    }
}

/* Touch device optimizations */
@media (pointer: coarse) {
    .modal-content button {
        min-height: 55px;
        min-width: 150px;
        font-size: 17px;
        padding: 18px 25px;
    }
    
    .permission-btn.primary:active,
    .permission-btn.secondary:active,
    .permission-btn.tertiary:active {
        transform: translateY(0);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    }
    
    .tool-toggle,
    .control-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .device-option {
        min-height: 60px;
        padding: 15px;
    }
    
    .device-btn {
        min-height: 55px;
        padding: 15px 20px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-out {
    animation: fadeOut 0.5s ease;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
