/* Base Styles */
:root {
    --primary: #2c3e50;
    --secondary: #3498db;
    --success: #27ae60;
    --danger: #e74c3c;
    --text: #2c3e50;
    --background: #f8f9fa;
    --chart-hot: #FF6B6B;
    --chart-warm: #FFE66D;
    --chart-cool: #4ECDC4;
}

html {
    font-size: 16px;
    box-sizing: border-box;
}

*, *:before, *:after {
    box-sizing: inherit;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    padding: 2rem 1rem;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

h1, h2 {
    color: var(--primary);
    margin-bottom: 1.5rem;
}

h1 {
    font-size: 2.2rem;
    text-align: center;
}

h1 span {
    vertical-align: middle;
}

h2 {
    font-size: 1.5rem;
    margin-top: 2rem;
}

/* Training Section */
#training-section {
    background: #f1f5f9;
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    text-align: center;
}

#progress-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 1rem 0;
}

#progress-bar {
    width: 100%;
    height: 1rem;
    border-radius: 8px;
    overflow: hidden;
    background: #e2e8f0;
}

#progress-bar::-webkit-progress-value {
    background: var(--secondary);
    transition: width 0.3s ease;
}

#progress-bar::-moz-progress-bar {
    background: var(--secondary);
}

#training-controls {
    margin: 1rem;
    text-align: center;
}

#cancelTrainingBtn {
    background: var(--danger);
    padding: 0.5rem 1.5rem;
}

#cancelTrainingBtn:hover {
    background: #c0392b;
}

/* Input Groups */
.input-group {
    margin: 1.5rem 0;
    position: relative;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary);
}

input, select {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

input:focus, select:focus {
    border-color: var(--secondary);
    outline: none;
}

.tooltip {
    display: block;
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Buttons */
button {
    background: var(--secondary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

button:hover {
    filter: brightness(0.9);
}

button:disabled {
    background: #94a3b8 !important;
    cursor: not-allowed;
}

.chart-controls {
    display: flex;
    gap: 1rem;
    margin: 1rem 0;
}

/* Results & History */
#result {
    font-size: 1.4rem;
    margin: 1.5rem 0;
    font-weight: 600;
    color: var(--primary);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.clear-history {
    background: var(--danger);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.clear-history:hover {
    background: #c0392b;
}


#history {
    list-style: none;
    padding: 0;
}

#history li {
    background: white;
    padding: 1rem;
    margin: 0.5rem 0;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.disclaimer {
    color: #64748b;
    font-size: 0.9rem;
    margin-top: 1rem;
    line-height: 1.4;
}

/* Chart Section */
#chart-section {
    position: relative;
    margin: 3rem 0;
}

#chart-section::after {
    content: "Temperature Scale: 🔴 Warm → 🟢 Cool";
    display: block;
    text-align: center;
    margin-top: 1rem;
    color: #64748b;
    font-size: 0.9rem;
}

canvas {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Spinner Animation */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text);
}

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

/* Accessibility */
.tooltip {
    visibility: hidden;
    position: absolute;
    bottom: calc(50% + 10px);
    /* 10px above input */
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: 300px;
    background: #2c3e50;
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
    pointer-events: none;
}

.input-group:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.input-group:focus-within .tooltip,
input:focus+.tooltip,
select:focus+.tooltip {
    visibility: visible;
    opacity: 1;
}

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

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.4rem;
    }

    .chart-controls {
        flex-direction: column;
    }

    button {
        width: 100%;
        justify-content: center;
    }

    .tooltip {
        font-size: 0.75rem;
        transform: translateX(-30%);
        max-width: 250px;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .container {
        padding: 1rem;
    }

    input, select {
        padding: 0.75rem;
    }

    #result {
        font-size: 1.2rem;
    }

    .history-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .clear-history {
        align-self: flex-end;
    }

    .tooltip {
        font-size: 0.6rem;
        transform: translateX(-20%);
        max-width: 220px;
    }

}