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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    background: #000;
    color: #fff;
    height: 100vh;
    width: 100vw;
}

/* Full-screen Camera Container */
.camera-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 1;
    overflow: hidden;
}

#camera-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror the camera feed */
}

#detection-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Main Overlay */
.main-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10;
    pointer-events: none;
}

.main-overlay > * {
    pointer-events: auto;
}

/* Status Bar */
.status-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(180deg, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.2) 50%, transparent 100%);
    backdrop-filter: blur(15px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 20;
}

.status-left, .status-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sparc-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 18px;
    color: #4488ff;
}

.sparc-logo i {
    font-size: 20px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #ccc;
}

.connection-status i {
    font-size: 8px;
    color: #ff4444;
    animation: pulse 2s infinite;
}

.connection-status.connected i {
    color: #4488ff;
}

.mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(68, 136, 255, 0.1);
    border: 1px solid rgba(68, 136, 255, 0.3);
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 14px;
    color: #4488ff;
}

.gesture-mode-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(68, 136, 255, 0.2);
    border: 1px solid rgba(68, 136, 255, 0.4);
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: #4488ff;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.settings-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.settings-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* OLED Display Simulation */
.oled-display {
    position: absolute;
    top: 80px;
    right: 20px;
    width: 280px;
    background: linear-gradient(145deg, rgba(26, 26, 26, 0.8), rgba(42, 42, 42, 0.8));
    border-radius: 12px;
    border: 2px solid rgba(68, 136, 255, 0.3);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(15px);
    overflow: hidden;
    z-index: 15;
}

.oled-header {
    background: linear-gradient(90deg, #333, #444);
    padding: 12px 16px;
    border-bottom: 1px solid #555;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.oled-title {
    font-size: 14px;
    font-weight: 600;
    color: #4488ff;
}

.oled-status {
    font-size: 12px;
    color: #888;
}

.oled-content {
    padding: 16px;
    min-height: 120px;
    background: #000;
    border-radius: 0 0 10px 10px;
}

.oled-line {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.4;
    color: #4488ff;
    margin-bottom: 4px;
    text-shadow: 0 0 5px rgba(68, 136, 255, 0.3);
}

.oled-line:last-child {
    margin-bottom: 0;
}

/* Control Panel */
.control-panel {
    position: absolute;
    top: 80px;
    left: 20px;
    width: 350px;
    max-height: calc(100vh - 100px);
    background: linear-gradient(145deg, rgba(20, 20, 20, 0.7), rgba(30, 30, 30, 0.7));
    backdrop-filter: blur(25px);
    border-radius: 16px;
    border: 1px solid rgba(68, 136, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 25;
    overflow: hidden;
}

.control-panel.active {
    transform: translateX(0);
}

.control-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.control-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.control-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.control-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.control-content {
    padding: 20px;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.control-section {
    margin-bottom: 24px;
}

.control-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}

.mode-buttons {
    display: flex;
    gap: 12px;
}

.mode-btn {
    flex: 1;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.mode-btn.active {
    background: linear-gradient(135deg, rgba(68, 136, 255, 0.2), rgba(68, 136, 255, 0.1));
    border-color: #4488ff;
    color: #4488ff;
}

/* Gesture Mode Buttons */
.gesture-mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.gesture-mode-btn {
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    text-align: left;
}

.gesture-mode-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.gesture-mode-btn.active {
    background: linear-gradient(135deg, rgba(68, 136, 255, 0.2), rgba(68, 136, 255, 0.1));
    border-color: #4488ff;
    color: #4488ff;
}

.voice-controls {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.voice-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #4488ff, #3366cc);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.voice-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(68, 136, 255, 0.3);
}

.voice-btn.listening {
    background: linear-gradient(135deg, #ff4444, #cc3333);
    color: #fff;
    animation: pulse 1s infinite;
}

.voice-status {
    font-size: 14px;
    color: #888;
    text-align: center;
}

.settings-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.setting-item label {
    font-size: 14px;
    color: #ccc;
    font-weight: 500;
}

.setting-item input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
    -webkit-appearance: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4488ff;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(68, 136, 255, 0.3);
}

.setting-item select {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
}

.toggle-btn {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.toggle-btn.active {
    background: rgba(68, 136, 255, 0.2);
    border-color: #4488ff;
    color: #4488ff;
}

/* Detection Results */
.detection-results {
    position: absolute;
    bottom: 20px;
    left: 20px;
    width: 350px;
    max-height: 300px;
    background: linear-gradient(145deg, rgba(20, 20, 20, 0.7), rgba(30, 30, 30, 0.7));
    backdrop-filter: blur(25px);
    border-radius: 16px;
    border: 1px solid rgba(68, 136, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 25;
    overflow: hidden;
}

.detection-results.active {
    transform: translateY(0);
}

.results-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.results-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.results-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.results-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.results-content {
    padding: 20px;
    max-height: 200px;
    overflow-y: auto;
}

.no-results {
    text-align: center;
    color: #888;
    font-style: italic;
}

.object-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.object-item:last-child {
    border-bottom: none;
}

.object-name {
    font-weight: 500;
    color: #fff;
}

.object-confidence {
    font-size: 12px;
    color: #4488ff;
    background: rgba(68, 136, 255, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
}

/* Gesture Recognition Panel */
.gesture-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    width: 350px;
    background: linear-gradient(145deg, rgba(20, 20, 20, 0.7), rgba(30, 30, 30, 0.7));
    backdrop-filter: blur(25px);
    border-radius: 16px;
    border: 1px solid rgba(68, 136, 255, 0.2);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 25;
    overflow: hidden;
}

.gesture-panel.active {
    transform: translateY(0);
}

.gesture-header {
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gesture-header h4 {
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.gesture-mode {
    font-size: 12px;
    color: #4488ff;
    background: rgba(68, 136, 255, 0.1);
    padding: 4px 8px;
    border-radius: 12px;
}

.gesture-content {
    padding: 20px;
}

.sentence-display {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
    min-height: 80px;
}

.current-sentence {
    font-size: 16px;
    color: #fff;
    margin-bottom: 8px;
    min-height: 24px;
}

.current-gesture {
    font-size: 14px;
    color: #4488ff;
    font-weight: 500;
}

.gesture-controls {
    display: flex;
    gap: 12px;
}

.gesture-btn {
    flex: 1;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
}

.gesture-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Floating Action Buttons */
.fab-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 30;
}

.fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.main-fab {
    background: linear-gradient(135deg, #4488ff, #3366cc);
    color: #fff;
    transform: scale(1);
}

.main-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 30px rgba(68, 136, 255, 0.4);
}

.main-fab.active {
    background: linear-gradient(135deg, #ff4444, #cc3333);
    color: #fff;
}

.secondary-fab {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: scale(0);
    opacity: 0;
}

.fab-container.active .secondary-fab {
    transform: scale(1);
    opacity: 1;
}

.secondary-fab:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0a0a0a, #1a1a1a);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    text-align: center;
    max-width: 400px;
    padding: 40px;
}

.sparc-logo-large {
    margin-bottom: 40px;
}

.sparc-logo-large i {
    font-size: 80px;
    color: #4488ff;
    margin-bottom: 20px;
    animation: float 3s ease-in-out infinite;
}

.sparc-logo-large h1 {
    font-size: 48px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
    text-shadow: 0 0 20px rgba(68, 136, 255, 0.3);
}

.sparc-logo-large p {
    font-size: 18px;
    color: #888;
    font-weight: 300;
}

.loading-progress {
    margin-top: 40px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 16px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4488ff, #3366cc);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.loading-text {
    font-size: 14px;
    color: #888;
}

/* Toast Notifications */
.toast {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: linear-gradient(145deg, rgba(20, 20, 20, 0.95), rgba(30, 30, 30, 0.95));
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
}

.toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast.success .toast-icon {
    background: #4488ff;
}

.toast.error .toast-icon {
    background: #ff4444;
}

.toast.info .toast-icon {
    background: #4488ff;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .status-bar {
        padding: 0 15px;
        height: 50px;
    }
    
    .sparc-logo {
        font-size: 16px;
    }
    
    .mode-indicator {
        font-size: 12px;
        padding: 6px 12px;
    }
    
    .oled-display {
        width: 250px;
        right: 15px;
        top: 70px;
    }
    
    .control-panel {
        width: calc(100vw - 30px);
        left: 15px;
        right: 15px;
    }
    
    .detection-results {
        width: calc(100vw - 30px);
        left: 15px;
        right: 15px;
    }
    
    .gesture-panel {
        width: calc(100vw - 30px);
        left: 15px;
        right: 15px;
    }
    
    .fab-container {
        bottom: 20px;
        right: 20px;
    }
    
    .fab {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }
}

@media (max-width: 480px) {
    .oled-display {
        width: calc(100vw - 30px);
        right: 15px;
        left: 15px;
    }
    
    .sparc-logo-large h1 {
        font-size: 36px;
    }
    
    .sparc-logo-large i {
        font-size: 60px;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Audio Input Display */
.audio-input-display {
    position: fixed;
    top: 80px;
    left: 20px;
    width: 320px;
    background: rgba(68, 136, 255, 0.15);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(68, 136, 255, 0.3);
    border-radius: 15px;
    padding: 15px;
    z-index: 999;
    font-family: 'Inter', sans-serif;
    display: block;
    opacity: 1;
    transition: all 0.3s ease;
}

.audio-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: #4488ff;
    font-weight: 600;
    font-size: 14px;
}

.audio-header i {
    font-size: 16px;
}

.audio-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.current-input {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.current-input .label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    font-weight: 500;
}

.current-input .text {
    font-size: 14px;
    color: #ffffff;
    font-weight: 600;
    min-height: 20px;
    padding: 8px;
    background: rgba(68, 136, 255, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(68, 136, 255, 0.2);
    transition: all 0.3s ease;
}

.current-input .text.recognized {
    background: rgba(76, 175, 80, 0.2);
    border-color: rgba(76, 175, 80, 0.4);
    color: #4ade80;
}

.current-input .text.error {
    background: rgba(244, 67, 54, 0.2);
    border-color: rgba(244, 67, 54, 0.4);
    color: #f87171;
}

.input-history {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    padding: 6px 8px;
    background: rgba(68, 136, 255, 0.05);
    border-radius: 6px;
    border-left: 3px solid #4488ff;
    transition: all 0.2s ease;
}

.history-item.recognized {
    border-left-color: #4CAF50;
    background: rgba(76, 175, 80, 0.1);
    color: #4ade80;
}

.history-item.error {
    border-left-color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    color: #f87171;
}

.history-item:hover {
    background: rgba(68, 136, 255, 0.1);
    transform: translateX(2px);
}

