/* MTG Card Recognition - Styles */

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --success-color: #22c55e;
    --error-color: #ef4444;
    --guide-color: rgba(99, 102, 241, 0.7);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header p {
    color: var(--text-muted);
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.mode-btn {
    padding: 0.75rem 2rem;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

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

.mode-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

/* Input Sections */
.input-section {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    margin-bottom: 2rem;
}

.input-section.hidden {
    display: none;
}

/* Video Container */
.video-container {
    position: relative;
    width: 100%;
    max-width: 640px;
    margin: 0 auto 1rem;
    border-radius: 0.5rem;
    overflow: hidden;
    background: #000;
}

#video {
    width: 100%;
    display: block;
}

#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.capture-hint {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
}

/* Controls */
.controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.primary-btn {
    padding: 1rem 2rem;
    background: var(--primary-color);
    border: none;
    color: white;
    font-size: 1.125rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-hover);
}

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

#cameraSelect {
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    color: var(--text-color);
    border-radius: 0.5rem;
    font-size: 1rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 0.5rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 1rem;
}

.upload-area:hover {
    border-color: var(--primary-color);
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-content p {
    color: var(--text-muted);
}

.preview-image {
    max-width: 100%;
    max-height: 400px;
    border-radius: 0.5rem;
}

.preview-image.hidden {
    display: none;
}

/* Results Section */
.results-section {
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
}

.results-section.hidden {
    display: none;
}

.results-section h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.timing-info {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
}

.result-card {
    background: var(--bg-color);
    border-radius: 0.5rem;
    overflow: hidden;
    transition: transform 0.2s;
}

.result-card:hover {
    transform: translateY(-4px);
}

.result-card img {
    width: 100%;
    aspect-ratio: 5/7;
    object-fit: cover;
}

.result-info {
    padding: 1rem;
}

.result-name {
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.3;
}

.result-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.confidence-bar {
    flex: 1;
    height: 4px;
    background: var(--border-color);
    border-radius: 2px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 2px;
    transition: width 0.3s;
}

.result-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Loading */
.loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

/* Footer */
footer {
    text-align: center;
    margin-top: 2rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }

    header h1 {
        font-size: 1.75rem;
    }

    .input-section {
        padding: 1rem;
    }

    .results-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
}

/* Camera error message */
.camera-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 300px;
    background: var(--card-bg);
    border-radius: 1rem;
    padding: 2rem;
    text-align: center;
    color: var(--text-muted);
}

.camera-error p {
    margin-bottom: 1rem;
}
