/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    overflow-x: hidden;
    min-height: 100vh;
}

/* Three.js Background */
#three-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* Container */
.container {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    text-align: center;
    animation: slideDown 0.6s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.title {
    font-size: 3rem;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.butterfly-icon {
    display: inline-block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    50% {
        transform: translateY(-10px) rotate(5deg);
    }
}

.subtitle {
    font-size: 1.2rem;
    color: #666;
    margin-bottom: 20px;
}

.species-chips {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.chip {
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.chip-orange {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.chip-cloak {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

.chip-atala {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
}

/* Main Vertical Layout */
.main-vertical {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 20px;
}

/* Panel Styles */
.panel {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 25px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.panel-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: #667eea;
    border-bottom: 3px solid #667eea;
    padding-bottom: 10px;
}

/* Tab System */
.tab-navigation {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 10px;
}

.tab-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    font-size: 1rem;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    position: relative;
    bottom: -12px;
}

.tab-btn:hover {
    color: #667eea;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

.tab-content {
    min-height: 300px;
}

.tab-pane {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-pane.active {
    display: block;
}

.tab-description {
    text-align: center;
    color: #666;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

/* Input Sections */
.draw-section,
.random-section {
    padding: 20px;
}

.gallery-section {
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 12px;
}

.gallery-section h4 {
    font-size: 1.1rem;
    margin-bottom: 15px;
    color: #444;
}

.gallery-controls {
    margin-bottom: 15px;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #667eea;
    border-radius: 15px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area:hover {
    border-color: #764ba2;
    background: rgba(118, 75, 162, 0.1);
    transform: scale(1.02);
}

.upload-area.dragover {
    background: rgba(102, 126, 234, 0.2);
    border-color: #764ba2;
}

.upload-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 10px;
}

.upload-hint {
    font-size: 0.85rem;
    color: #999;
}

/* Canvas */
#drawCanvas {
    border: 3px solid #667eea;
    border-radius: 15px;
    cursor: crosshair;
    display: block;
    margin: 20px auto;
    background: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.2);
}

.canvas-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px;
}

/* Random Controls */
.random-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: stretch;
    max-width: 500px;
    margin: 0 auto;
}

.select-box {
    flex: 1;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.select-box:focus {
    outline: none;
    border-color: #667eea;
}

/* Gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
}

.gallery-item {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.gallery-item:hover {
    border-color: #667eea;
    transform: scale(1.05);
}

.gallery-item img {
    width: 100%;
    height: 100px;
    object-fit: cover;
}

/* Image Preview */
.image-preview {
    width: 100%;
    height: 400px;
    border: 3px solid #667eea;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #f5f5f5;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    position: relative;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.placeholder {
    text-align: center;
    color: #999;
}

.placeholder-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
}

/* Model Selection */
.model-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

@media (max-width: 900px) {
    .model-selection {
        grid-template-columns: repeat(2, 1fr);
    }
}

.model-card {
    padding: 15px;
    border: 2px solid #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.model-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.model-card.selected {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

.model-name {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.model-accuracy {
    font-size: 1.5rem;
    font-weight: 700;
    color: #667eea;
    margin-bottom: 5px;
}

.model-arch {
    font-size: 0.85rem;
    color: #999;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: #f5f5f5;
    color: #333;
}

.btn-success {
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
}

.btn-large {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    margin-bottom: 10px;
}

.action-buttons {
    margin-top: 20px;
}

/* Results */
.results-container {
    min-height: 200px;
}

.results-placeholder {
    text-align: center;
    padding: 50px 20px;
    color: #999;
}

.results-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: 10px;
}

.result-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 15px;
    animation: slideIn 0.5s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.result-model {
    font-size: 1.1rem;
    font-weight: 600;
}

.result-accuracy {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.result-prediction {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
    text-align: center;
}

.result-confidence {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.probabilities {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
}

.prob-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.prob-bar {
    flex: 1;
    height: 8px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.prob-fill {
    height: 100%;
    background: white;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Comparison Section */
.comparison-section {
    margin-top: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.05);
    border-radius: 15px;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    color: #666;
}

.footer p {
    margin: 8px 0;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.footer-link {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    padding: 8px 16px;
    border-radius: 20px;
    background: rgba(102, 126, 234, 0.1);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.footer-link:hover {
    background: rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.footer-divider {
    color: #999;
    font-weight: 300;
}

.footer-credit {
    font-size: 0.9rem;
    color: #888;
    font-weight: 500;
    margin-top: 10px;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    text-align: center;
    color: white;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Label Selection Styles */
.label-selection {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    backdrop-filter: blur(10px);
}

.label-selection label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
    font-size: 0.9rem;
}

.label-hint {
    margin-top: 6px;
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Actual Label Badge */
.actual-label-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

/* Gallery Label */
.gallery-label {
    position: absolute;
    bottom: 5px;
    left: 5px;
    right: 5px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px;
    border-radius: 4px;
    font-size: 0.7rem;
    text-align: center;
    font-weight: 600;
}

.gallery-item {
    position: relative;
}

/* Match Badge */
.match-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
}

.match-badge.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
}

.match-badge.incorrect {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%);
    color: white;
}

/* Actual Label Info */
.actual-label-info {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    margin-bottom: 12px;
    border-left: 4px solid #667eea;
}

.actual-label-info strong {
    color: #667eea;
}

/* Actual Label Summary */
.actual-label-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
    text-align: center;
}

.actual-label-summary h3 {
    margin: 0 0 8px 0;
    font-size: 1.3rem;
}

.actual-label-summary p {
    margin: 0;
    font-size: 1rem;
    opacity: 0.95;
}

/* Highlight Actual Species in Probabilities */
.prob-item.actual-species {
    background: rgba(102, 126, 234, 0.2);
    border-left: 3px solid #667eea;
    padding-left: 8px;
}

.prob-item.actual-species span:first-child {
    font-weight: 700;
    color: #667eea;
}

/* Responsive */
@media (max-width: 768px) {
    .title {
        font-size: 2rem;
    }
    
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-btn {
        bottom: 0;
        border-bottom: none;
        border-left: 3px solid transparent;
    }
    
    .tab-btn.active {
        border-left-color: #667eea;
    }
    
    .model-selection {
        grid-template-columns: 1fr;
    }
    
    #drawCanvas {
        width: 100%;
        height: auto;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}
