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

:root {
    --primary-color: #ffffff;
    --secondary-color: #e0e0e0;
    --success-color: #00ff88;
    --warning-color: #ffaa00;
    --danger-color: #ff3366;
    --dark-bg: #000000;
    --light-bg: #1a1a2e;
    --card-bg: #0f0f1e;
    --text-primary: #ffffff;
    --text-secondary: #b0b0c0;
    --border-color: #333344;
    --shadow: 0 0 30px rgba(255, 255, 255, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Orbitron', 'Space Mono', 'Courier New', monospace;
    background: #000000 url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><rect width="200" height="200" fill="%23000000"/><circle cx="10" cy="20" r="1" fill="%23ffffff" opacity="0.8"/><circle cx="50" cy="30" r="0.5" fill="%23ffffff" opacity="0.6"/><circle cx="80" cy="15" r="1.5" fill="%23ffffff" opacity="0.7"/><circle cx="30" cy="60" r="0.7" fill="%23ffffff" opacity="0.5"/><circle cx="70" cy="70" r="1" fill="%23ffffff" opacity="0.9"/><circle cx="20" cy="80" r="0.5" fill="%23ffffff" opacity="0.6"/><circle cx="90" cy="50" r="0.8" fill="%23ffffff" opacity="0.7"/><circle cx="40" cy="90" r="1.2" fill="%23ffffff" opacity="0.8"/><circle cx="150" cy="25" r="0.6" fill="%23ffffff" opacity="0.7"/><circle cx="120" cy="120" r="1" fill="%23ffffff" opacity="0.8"/><circle cx="170" cy="100" r="0.7" fill="%23ffffff" opacity="0.6"/><circle cx="60" cy="150" r="0.9" fill="%23ffffff" opacity="0.7"/></svg>');
    background-size: 200px 200px;
    animation: cosmicDrift 2s linear infinite;
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.03) 0%, transparent 50%),
                radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
    animation: starTwinkle 8s ease-in-out infinite;
}

body > * {
    position: relative;
    z-index: 1;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    border: 2px solid var(--primary-color);
    box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.2), 0 0 40px rgba(255, 255, 255, 0.25);
}

/* Header */
.app-header {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    padding: 2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.15);
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
}

.header-content {
    text-align: center;
    width: 100%;
}

.header-content h1 {
    font-size: 3.0rem;
    margin-bottom: 0.5rem;
    animation: slideDown 0.6s ease-out, titleGlow 3s ease-in-out infinite;
    color: #ffffff;
    text-shadow: 0 0 10px #ffffff, 0 0 20px rgba(255, 255, 255, 0.6);
}

.header-content .subtitle {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    animation: slideDown 0.8s ease-out;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Mode Selection */
.mode-selection {
    text-align: center;
    animation: fadeIn 0.6s ease-out;
}

.mode-selection h2 {
    font-size: 2.4rem;
    margin-bottom: 2rem;
    color: #ffffff;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.5);
}

.mode-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.mode-btn {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    border: 2px solid var(--border-color);
    padding: 4rem 3.5rem;
    border-radius: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    color: var(--text-primary);
}

.mode-btn:hover {
    transform: translateY(-12px);
    border-color: var(--primary-color);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
    box-shadow: 0 20px 40px rgba(255, 255, 255, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.mode-icon {
    font-size: 6.5rem;
    animation: bounce 2s infinite;
}

.mode-title {
    font-size: 2rem;
    font-weight: bold;
}

.mode-desc {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Learning Interface */
.learning-interface {
    display: flex;
    gap: 2rem;
    animation: slideUp 0.6s ease-out;
}

.learning-interface.hidden {
    display: none;
}

.mode-selection.hidden {
    display: none;
}

.lesson-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    width: 100%;
}

/* Video Section */
.video-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.video-wrapper {
    position: relative;
    border-radius: 1rem;
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow);
    aspect-ratio: 4 / 3;
}

.video-feed {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.hand-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1.3);
}

.video-overlay {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.status {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: bold;
    backdrop-filter: blur(10px);
}

.status.listening {
    border-left: 3px solid var(--warning-color);
    animation: pulse 1.5s infinite;
}

.status.success {
    border-left: 3px solid var(--success-color);
    background: rgba(16, 185, 129, 0.2);
}

.status.error {
    border-left: 3px solid var(--danger-color);
    background: rgba(239, 68, 68, 0.2);
}

.camera-controls {
    display: flex;
    gap: 1rem;
}

.control-btn {
    flex: 1;
    padding: 0.75rem 1.5rem;
    background: linear-gradient(135deg, #ffffff 0%, #e0e0e0 100%);
    color: #000000;
    border: none;
    border-radius: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.control-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #e0e0e0 0%, #ffffff 100%);
    transform: scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 255, 255, 0.4);
}

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

.control-btn.record-btn {
    animation: none;
}

.control-btn.record-btn:not(:disabled) {
    background: var(--danger-color);
    animation: pulse 1s infinite;
}

/* Troubleshooting Tips */
.troubleshooting-tips {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid var(--warning-color);
    border-radius: 0.5rem;
    margin-top: 0.5rem;
}

.troubleshooting-tips details {
    cursor: pointer;
    padding: 0.75rem;
}

.troubleshooting-tips summary {
    font-weight: bold;
    color: var(--warning-color);
    user-select: none;
}

.troubleshooting-tips summary:hover {
    color: #fbbf24;
}

.troubleshooting-tips ul {
    list-style: none;
    margin-top: 0.75rem;
    padding-left: 0;
}

.troubleshooting-tips li {
    padding: 0.3rem 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Lesson Content */
.lesson-content {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.02) 100%);
    padding: 2rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: fit-content;
    max-height: 600px;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.1);
}

.lesson-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.back-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.back-btn:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.lesson-header h2 {
    flex: 1;
    text-align: center;
    font-size: 1.75rem;
}

.lesson-counter {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    font-size: 0.875rem;
    font-weight: bold;
    border: 1px solid var(--primary-color);
}

/* Target Section */
.target-section {
    text-align: center;
}

.target-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.target-display {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    padding: 2rem;
    border-radius: 1.5rem;
    border: 1px dashed var(--primary-color);
}

.sign-image {
    font-size: 5rem;
    margin-bottom: 1rem;
    animation: float 3s ease-in-out infinite;
}

.sign-description p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

/* Feedback Section */
.feedback-section {
    padding: 1rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0.75rem;
}

.feedback-box {
    background: var(--dark-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback-placeholder {
    color: var(--text-secondary);
    font-size: 0.875rem;
    text-align: center;
}

.feedback-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border-left: 3px solid var(--success-color);
    padding: 1rem;
    border-radius: 0.5rem;
    animation: slideIn 0.4s ease-out;
}

.feedback-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
    border-left: 3px solid var(--danger-color);
    padding: 1rem;
    border-radius: 0.5rem;
    animation: slideIn 0.4s ease-out;
}

.feedback-warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border-left: 3px solid var(--warning-color);
    padding: 1rem;
    border-radius: 0.5rem;
    animation: slideIn 0.4s ease-out;
}

.confidence-meter {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.confidence-meter label {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.confidence-bar {
    height: 8px;
    background: var(--dark-bg);
    border-radius: 4px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--warning-color), var(--success-color));
    width: 0%;
    transition: width 0.3s ease;
}

#confidenceValue {
    font-size: 0.875rem;
    text-align: right;
    color: var(--text-secondary);
}

/* Action Buttons */
.lesson-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: #000;
    font-weight: 600;
}

.action-btn.primary:hover:not(:disabled) {
    transform: translateY(-4px);
    box-shadow: 0 15px 30px rgba(0, 217, 255, 0.4);
}

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

.action-btn.secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.action-btn.secondary:hover {
    background: var(--border-color);
}

/* Progress Bar */
.progress-bar-section {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.progress-bar {
    height: 8px;
    background: var(--dark-bg);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    width: 0%;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 20px rgba(0, 217, 255, 0.5);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease-out;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: rgba(0, 0, 0, 0.6);
    padding: 2rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    animation: slideUp 0.4s ease-out;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 2rem;
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--primary-color);
}

.modal-content h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Progress Stats */
.progress-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.progress-card {
    text-align: center;
    padding: 1.5rem;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.progress-card h4 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

.progress-circle {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: conic-gradient(var(--primary-color) 0deg, var(--primary-color) var(--progress-angle, 0deg), transparent var(--progress-angle, 0deg));
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 1rem auto;
}

.circle-text {
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-primary);
}

.progress-card p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Achievements */
.achievements {
    background: rgba(139, 92, 246, 0.05);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
}

.achievements h4 {
    margin-bottom: 1rem;
}

.achievements-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.achievement {
    text-align: center;
    padding: 1rem;
    background: var(--dark-bg);
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
}

.achievement.unlocked {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-color);
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.achievement-name {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Celebration */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 999;
}

.celebration.hidden {
    display: none;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--primary-color);
    animation: confetti-fall 3s ease-in forwards;
}

/* Animations */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

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

@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotateZ(360deg);
        opacity: 0;
    }
}

@keyframes titleGlow {
    0%, 100% {
        color: #ffffff;
        text-shadow: 0 0 10px #ffffff, 0 0 20px rgba(255, 255, 255, 0.6);
    }
    50% {
        color: #e0e0e0;
        text-shadow: 0 0 25px #ffffff, 0 0 50px rgba(255, 255, 255, 0.8);
    }
}

@keyframes cosmicDrift {
    0% {
        background-position: 0 0;
    }
    50% {
        background-position: 100px 100px;
    }
    100% {
        background-position: 200px 200px;
    }
}

@keyframes starTwinkle {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.7;
    }
}

/* Scrollbar Styling */
.lesson-content::-webkit-scrollbar,
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.lesson-content::-webkit-scrollbar-track,
.modal-content::-webkit-scrollbar-track {
    background: var(--dark-bg);
    border-radius: 4px;
}

.lesson-content::-webkit-scrollbar-thumb,
.modal-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.lesson-content::-webkit-scrollbar-thumb:hover,
.modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .lesson-container {
        grid-template-columns: 1fr;
    }

    .lesson-content {
        max-height: none;
    }

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

@media (max-width: 768px) {
    .app-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .header-content h1 {
        font-size: 2rem;
    }

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

    .main-content {
        padding: 1rem;
    }

    .modal-content {
        margin: 1rem;
    }
}

@media (max-width: 480px) {
    .app-header {
        padding: 1rem;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .header-stats {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .stat {
        width: 100%;
    }

    .lesson-actions {
        grid-template-columns: 1fr;
    }

    .video-wrapper {
        aspect-ratio: 16 / 9;
    }
}
