/* 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, #0f172a 0%, #1e293b 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}
.version-badge {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}
header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    flex: 1;
    align-items: start;
}

/* Drawing Section */
.drawing-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-container {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
    margin-bottom: 25px;
    background: #fafafa;
}

#drawingCanvas {
    display: block;
    background: white;
    cursor: crosshair;
    transition: transform 0.2s ease;
}

#drawingCanvas:hover {
    transform: scale(1.02);
}

.canvas-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    backdrop-filter: blur(5px);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.control-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
}

.clear-btn {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
}

.clear-btn:hover {
    background: linear-gradient(135deg, #ee5a24, #ff6b6b);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(238, 90, 36, 0.4);
}

.undo-btn {
    background: linear-gradient(135deg, #4ecdc4, #44a08d);
    color: white;
}

.undo-btn:hover {
    background: linear-gradient(135deg, #44a08d, #4ecdc4);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(68, 160, 141, 0.4);
}

.btn-icon {
    font-size: 1.2rem;
}

/* Drawing Tips */
.drawing-tips {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    width: 100%;
}

.drawing-tips h4 {
    margin-bottom: 12px;
    color: #333;
    font-size: 1.1rem;
}

.drawing-tips ul {
    list-style: none;
    padding: 0;
}

.drawing-tips li {
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
    color: #666;
    font-size: 0.95rem;
}

.drawing-tips li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: #4ecdc4;
    font-weight: bold;
}

/* Predictions Section */
.predictions-section {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    height: fit-content;
}

.predictions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f1f3f4;
}

.predictions-header h3 {
    color: #333;
    font-size: 1.4rem;
}

.model-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.loading {
    background: #ffa500;
    animation: pulse 1.5s infinite;
}

.status-indicator.ready {
    background: #4caf50;
}

.status-indicator.error {
    background: #f44336;
}

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

/* Predictions Container */
.predictions-container {
    min-height: 300px;
}

.prediction-item {
    display: flex;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #f1f3f4;
    transition: all 0.3s ease;
}

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

.prediction-item:hover {
    background: #f8f9fa;
    border-radius: 8px;
    padding-left: 10px;
    padding-right: 10px;
}

.prediction-item.top-prediction {
    background: linear-gradient(135deg, #667eea20, #764ba220);
    border-radius: 10px;
    padding: 18px 15px;
    border: 2px solid #667eea30;
    margin-bottom: 10px;
}

.prediction-item.placeholder {
    justify-content: center;
    color: #999;
    font-style: italic;
    border: none;
    min-height: 60px;
}

.rank {
    font-weight: bold;
    color: #667eea;
    min-width: 30px;
    font-size: 1.1rem;
}

.label {
    flex: 1;
    margin: 0 15px;
    font-weight: 500;
    text-transform: capitalize;
    color: #333;
}

.confidence-bar {
    width: 80px;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-right: 15px;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.percentage {
    min-width: 45px;
    text-align: right;
    font-weight: 600;
    color: #667eea;
}

/* Prediction Stats */
.prediction-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #f1f3f4;
}

.stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 4px;
}

.stat-value {
    display: block;
    font-weight: bold;
    color: #333;
    font-size: 1rem;
}

/* Footer */
footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.2);
    color: white;
}

footer p {
    margin-bottom: 15px;
    opacity: 0.8;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0.8;
    transition: opacity 0.3s ease;
}

.footer-links a:hover {
    opacity: 1;
}

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

    .main-content {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    header h1 {
        font-size: 2rem;
    }

    .drawing-section,
    .predictions-section {
        padding: 20px;
    }

    #drawingCanvas {
        width: 100%;
        height: auto;
    }

    .controls {
        flex-direction: column;
        width: 100%;
    }

    .control-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .predictions-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .prediction-item {
        flex-wrap: wrap;
        gap: 10px;
    }

    .confidence-bar {
        order: 3;
        width: 100%;
        margin: 0;
    }

    .percentage {
        order: 4;
        width: 100%;
        text-align: left;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .prediction-item:hover {
        background: #000;
        color: #fff;
    }
    
    .confidence-fill {
        background: #000;
    }
}