/* CSS Variables for Dark Theme */
:root {
    --bg-primary: #0f0f0f;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #252525;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --accent-primary: #3b82f6;
    --accent-hover: #2563eb;
    --border-color: #333333;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.app-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
}

.app-header h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* Main Content Area */
.app-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    padding: 2rem;
    position: relative;
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.upload-zone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.upload-zone:hover,
.upload-zone.drag-over {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
    transform: scale(1.01);
}

.upload-icon {
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.upload-zone h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.upload-zone p {
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.file-types {
    font-size: 0.875rem;
    margin-top: 1rem;
    opacity: 0.7;
}

/* Image Preview */
.image-preview {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.image-preview img {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    border-radius: var(--radius-md);
}

.preview-info {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Viewer Section */
.viewer-section {
    width: 100%;
}

.viewer-container {
    position: relative;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

#skyboxCanvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none; /* Disable default touch gestures for custom controls */
}

.viewer-controls {
    position: absolute;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 0.75rem;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    padding: 0.75rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: inherit;
    min-height: 44px;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--bg-primary);
    border-color: var(--text-secondary);
}

.btn-icon {
    padding: 0.625rem;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    min-width: 44px;
    justify-content: center;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-icon.active {
    background: var(--accent-primary);
}

.btn-icon.active:hover {
    background: var(--accent-hover);
}

.btn:active {
    transform: translateY(0);
}

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

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(59, 130, 246, 0.2);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    color: var(--text-primary);
    font-size: 1rem;
}

/* Responsive Design */
@media (min-width: 768px) {
    .app-main {
        grid-template-columns: 400px 1fr;
    }

    .upload-section {
        position: sticky;
        top: 2rem;
        align-self: start;
    }
}

@media (max-width: 767px) {
    .app-header h1 {
        font-size: 1.5rem;
    }

    .app-main {
        padding: 1rem;
        gap: 1rem;
    }

    .upload-zone {
        padding: 2rem 1rem;
    }

    .viewer-controls {
        bottom: 1rem;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .btn {
        padding: 0.5rem 1rem;
        font-size: 0.8125rem;
    }

    .btn-icon {
        padding: 0.5rem;
        min-width: 40px;
    }
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Smooth Transitions */
.fade-in {
    animation: fadeIn 0.3s ease;
}

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

/* Fullscreen Styles */
.viewer-container:fullscreen {
    background: var(--bg-primary);
}

.viewer-container:-webkit-full-screen {
    background: var(--bg-primary);
}

.viewer-container:-moz-full-screen {
    background: var(--bg-primary);
}

/* Instructions Overlay */
.instructions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.instructions-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

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

.instructions-header h2 {
    font-size: 1.5rem;
    margin: 0;
    background: linear-gradient(135deg, var(--accent-primary), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.instructions-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.instruction-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: var(--accent-primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
}

.step-content h3 {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.step-content p {
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 0;
}

.step-content strong {
    color: var(--accent-primary);
    font-weight: 600;
}

.instructions-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
}

/* Error Modal */
.error-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.error-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.error-icon {
    color: #ef4444;
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

.error-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.error-content p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Mobile Responsiveness for Modals */
@media (max-width: 767px) {
    .instructions-content {
        max-height: 95vh;
    }

    .instructions-header h2 {
        font-size: 1.25rem;
    }

    .instructions-body {
        padding: 1rem;
        gap: 1rem;
    }

    .instruction-step {
        flex-direction: column;
        gap: 0.75rem;
    }

    .step-icon {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }

    .step-content h3 {
        font-size: 1rem;
    }

    .instructions-footer {
        flex-direction: column;
        gap: 1rem;
    }

    .instructions-footer button {
        width: 100%;
    }
}
