/* Global Styles */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --glass-bg: rgba(255, 255, 255, 0.95);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --accent-color: #764ba2;
    --canvas-bg: #000000;
    --success: #48bb78;
    --danger: #f56565;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: var(--primary-gradient);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-primary);
}

/* Main Container - Glassmorphism */
.app-container {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
    padding: 40px;
    width: 100%;
    max-width: 900px;
    display: grid;
    grid-template-columns: 1fr 1fr; /* layout: canvas | stats */
    gap: 40px;
}

/* Header */
.header {
    grid-column: 1 / -1;
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 2.5rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Left Column: Drawing Area */
.drawing-section {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    padding: 4px;
    background: linear-gradient(to right, #667eea, #764ba2);
    border-radius: 12px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    margin-bottom: 25px;
}

canvas {
    background-color: var(--canvas-bg);
    border-radius: 8px;
    cursor: crosshair;
    display: block;
}

.controls {
    display: flex;
    gap: 15px;
    width: 100%;
    justify-content: center;
}

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

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(118, 75, 162, 0.4);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(118, 75, 162, 0.6);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 2px solid var(--danger);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Right Column: Statistics & Info */
.info-section {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.status-card {
    background: white;
    padding: 15px 20px;
    border-radius: 12px;
    border-left: 5px solid var(--accent-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

#status {
    font-weight: 500;
}

/* Prediction Result */
.result-display {
    text-align: center;
    padding: 20px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.result-display h2 {
    color: var(--text-secondary);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
}

#prediction-text {
    font-size: 4rem;
    font-weight: 700;
    color: var(--accent-color);
    line-height: 1;
}

/* Confidence Chart */
.chart-container {
    background: white;
    padding: 20px;
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}

.chart-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-weight: 600;
}

.bar-wrapper {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.digit-label {
    width: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.bar-bg {
    flex-grow: 1;
    height: 8px;
    background: #edf2f7;
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.prob-label {
    width: 40px;
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.8rem;
}

/* History - Optional mini list */
.history-section {
    margin-top: auto;
}

.history-title {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.history-list {
    display: flex;
    gap: 10px;
}

.history-item {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        padding: 20px;
    }
}
