/* ===========================
   Global Styles
=========================== */
:root {
    --color-bg: #fdfdfd;
    --color-text: #333;
    --color-primary: #6a5acd;
    --color-accent: #ff6b6b;
    --color-border: #ddd;
    --color-success: #4ecdc4;
    --color-info: #45b7d1;
    --color-error: #e63946;

    --font-body: "Segoe UI", Roboto, Arial, sans-serif;
    --transition-fast: 0.2s ease-in-out;
}

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

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* ===========================
   Container
=========================== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

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

.logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: .5rem;
}

.logo h1 {
    font-size: 2rem;
    color: var(--color-primary);
}

.subtitle {
    font-size: 1rem;
    margin: .5rem 0 1.5rem;
    color: #555;
}

.species-preview {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.species-card {
    background: #fff;
    border: 1px solid var(--color-border);
    padding: .5rem 1rem;
    border-radius: .5rem;
    font-size: .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

/* ===========================
   Form
=========================== */
.prediction-form {
    background: #fff;
    border-radius: .75rem;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.form-header {
    margin-bottom: 1.5rem;
    text-align: center;
}

.form-header h2 {
    color: var(--color-primary);
    margin-bottom: .25rem;
}

.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.input-group {
    display: flex;
    flex-direction: column;
}

.input-label {
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: .25rem;
}

.label-hint {
    font-weight: 400;
    color: #777;
    font-size: .8rem;
    margin-left: .25rem;
}

.input-wrapper {
    display: flex;
    align-items: center;
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    padding: .5rem .75rem;
    background: #fafafa;
}

.input-wrapper input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    background: transparent;
}

.input-wrapper input.error {
    border-color: var(--color-error);
    background: #ffe6e6;
}

.input-unit {
    font-size: .85rem;
    color: #777;
}

.error-message {
    display: none;
    color: var(--color-error);
    font-size: .8rem;
    margin-top: .25rem;
}

/* ===========================
   Buttons
=========================== */
.submit-section {
    text-align: center;
    margin-bottom: 1.5rem;
}

.submit-btn {
    background: var(--color-primary);
    color: #fff;
    border: none;
    padding: .75rem 1.5rem;
    font-size: 1rem;
    border-radius: .5rem;
    cursor: pointer;
    transition: background var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}

.submit-btn:disabled {
    background: #aaa;
    cursor: not-allowed;
}

.submit-btn:hover:not(:disabled) {
    background: #5946c5;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.btn-loading.hidden {
    display: none;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Sample Data */
.sample-data {
    text-align: center;
    margin-top: 1rem;
}

.sample-label {
    font-size: .9rem;
    margin-bottom: .5rem;
}

.sample-buttons {
    display: flex;
    justify-content: center;
    gap: .5rem;
    flex-wrap: wrap;
}

.sample-btn {
    background: #eee;
    border: 1px solid var(--color-border);
    padding: .5rem .75rem;
    border-radius: .5rem;
    cursor: pointer;
    font-size: .9rem;
    transition: background var(--transition-fast);
}

.sample-btn:hover {
    background: #ddd;
}

/* ===========================
   Results
=========================== */
.result-section {
    margin-top: 2rem;
}

.result-card {
    background: #fff;
    border-radius: .75rem;
    padding: 1.5rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clear-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.predicted-species {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.5rem 0;
}

.species-emoji-large {
    font-size: 2.5rem;
}

.species-name {
    font-size: 1.25rem;
    font-weight: bold;
}

.species-latin {
    font-size: .9rem;
    color: #777;
}

/* Confidence */
.confidence-section {
    margin: 1rem 0;
}

.confidence-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: .25rem;
}

.confidence-bar {
    width: 100%;
    height: 10px;
    background: #eee;
    border-radius: .5rem;
    overflow: hidden;
}

.confidence-progress {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
}

/* Probability bars */
.probabilities-section h5 {
    margin: .75rem 0;
}

.probability-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-bottom: .5rem;
}

.prob-bar {
    flex: 1;
    height: 10px;
    background: #eee;
    border-radius: .5rem;
    overflow: hidden;
}

.prob-fill {
    height: 100%;
    width: 0%;
    transition: width 0.5s ease;
}

.prob-fill.setosa { background: var(--color-accent); }
.prob-fill.versicolor { background: var(--color-success); }
.prob-fill.virginica { background: var(--color-info); }

.prob-value {
    font-size: .85rem;
    min-width: 40px;
    text-align: right;
}

/* Processing time */
.processing-time {
    margin-top: .75rem;
    font-size: .8rem;
    color: #555;
    text-align: right;
}

/* ===========================
   Error Section
=========================== */
.error-section {
    margin-top: 2rem;
    text-align: center;
}

.error-card {
    background: #fff;
    border: 1px solid var(--color-error);
    color: var(--color-error);
    padding: 1.5rem;
    border-radius: .75rem;
}

.error-icon {
    font-size: 2rem;
    margin-bottom: .5rem;
}

.retry-btn {
    margin-top: 1rem;
    background: var(--color-error);
    color: #fff;
    border: none;
    padding: .5rem 1rem;
    border-radius: .5rem;
    cursor: pointer;
}

.retry-btn:hover {
    background: #c53030;
}

/* ===========================
   Loading Overlay
=========================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 5px solid #ddd;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto 1rem;
    animation: spin 1s linear infinite;
}

/* ===========================
   Footer
=========================== */
.footer {
    margin-top: 3rem;
    text-align: center;
    font-size: .85rem;
    color: #777;
}

.footer-links {
    margin-top: .5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.footer-links a {
    color: var(--color-primary);
    text-decoration: none;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* ===========================
   Utility
=========================== */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    .input-grid {
        grid-template-columns: 1fr;
    }
}
