/* ===== CSS Variables – refreshed palette ===== */
:root {
    --green-deep: #0f3b1e;        /* deeper, richer green */
    --green-forest: #1b5e2a;
    --green-vibrant: #2e7d32;     /* more saturated primary */
    --green-lime: #81c784;         /* bright accent */
    --green-neon: #a5d6a7;         /* light highlight */
    --gold: #ffb74d;               /* warm accent for warnings/hover */
    --glass-bg: rgba(255, 255, 255, 0.2);   /* slightly more opaque */
    --glass-border: rgba(255, 255, 255, 0.25);
    --shadow-soft: 0 20px 40px -10px rgba(0, 30, 0, 0.5);
    --shadow-strong: 0 30px 50px -15px rgba(0, 20, 0, 0.6);
    --font-main: 'Inter', sans-serif;
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at 10% 20%, #1b4a2b, #0f3b1e 90%);
    min-height: 100vh;
    color: #1e2e1e;
    line-height: 1.5;
    position: relative;
    overflow-x: hidden;
}

/* ===== Animated Leaves ===== */
.leaves {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.leaf {
    position: absolute;
    font-size: 3rem;
    opacity: 0.25;
    color: #c8e6c9;
    filter: drop-shadow(0 0 8px rgba(129, 199, 132, 0.3));
    animation: float 18s infinite ease-in-out;
}

.leaf-1 { top: 10%; left: 5%; animation-delay: 0s; }
.leaf-2 { top: 30%; right: 10%; animation-delay: 5s; }
.leaf-3 { bottom: 20%; left: 15%; animation-delay: 9s; }
.leaf-4 { bottom: 40%; right: 20%; animation-delay: 3s; }
.leaf-5 { top: 70%; left: 50%; animation-delay: 12s; }

@keyframes float {
    0% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-40px) rotate(8deg); }
    100% { transform: translateY(0) rotate(0deg); }
}

/* ===== App Wrapper ===== */
.app-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ===== Glassmorphism ===== */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 36px;
    box-shadow: var(--shadow-soft);
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.glass:hover {
    box-shadow: var(--shadow-strong);
}

/* ===== Header ===== */
.header {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 2rem 2rem 1.5rem;
    margin-bottom: 2.5rem;
    text-align: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 2.2rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 4px 12px rgba(0, 80, 0, 0.6);
}

.logo i {
    font-size: 2.8rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2));
}

.logo span {
    color: var(--green-neon);
    font-weight: 600;
}

.tagline {
    font-size: 1.1rem;
    color: #ecf9ec;
    margin: 0.5rem 0 1rem;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.badge {
    background: rgba(255,255,255,0.35);
    padding: 0.5rem 1.2rem;
    border-radius: 40px;
    font-size: 0.9rem;
    color: #fff;
    font-weight: 600;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.4);
}

.badge i {
    margin-right: 6px;
}

/* ===== Main Content ===== */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ===== Cards ===== */
.card {
    width: 100%;
    max-width: 700px;
    padding: 2.5rem;
    margin: 1rem 0;
    transition: transform 0.25s ease, opacity 0.3s ease;
}

/* Upload Card */
.upload-area {
    text-align: center;
    border: 2px dashed rgba(255,255,255,0.7);
    border-radius: 28px;
    padding: 2.5rem 1.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.upload-area:hover {
    border-color: var(--green-lime);
    background: rgba(129, 199, 132, 0.15);
    transform: scale(1.02);
}

.upload-icon i {
    font-size: 4rem;
    color: var(--green-lime);
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 12px rgba(0, 200, 0, 0.5));
    animation: float-icon 3s infinite ease-in-out;
}

@keyframes float-icon {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.upload-area h3 {
    font-size: 1.8rem;
    font-weight: 600;
    color: white;
    margin-bottom: 0.5rem;
}

.upload-area p {
    color: rgba(255,255,255,0.9);
    margin-bottom: 1.5rem;
}

.file-hint {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0.9rem 2.2rem;
    border: none;
    border-radius: 40px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: 0.2s;
    box-shadow: 0 8px 20px rgba(0,30,0,0.2);
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: linear-gradient(145deg, var(--green-vibrant), var(--green-lime));
    color: #fff;
    box-shadow: 0 8px 20px rgba(46, 125, 50, 0.5);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 200%;
    height: 200%;
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(30deg);
    transition: left 0.5s;
}

.btn-primary:hover::after {
    left: 100%;
}

.btn-primary:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 15px 30px rgba(46, 125, 50, 0.7);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--green-lime);
    color: var(--green-lime);
}

.btn-outline:hover {
    background: var(--green-lime);
    color: #0f3b1e;
    border-color: var(--green-lime);
    transform: translateY(-2px);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,0.4);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.btn-icon:hover {
    background: rgba(255,255,255,0.7);
    color: #1e3b2c;
}

/* Preview */
.preview-container {
    margin: 1.5rem 0;
    text-align: center;
}

.preview-img-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

.preview-img-wrapper img {
    max-width: 100%;
    max-height: 320px;
    display: block;
}

.remove-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(220, 53, 69, 0.8);
    border: 2px solid white;
}

.remove-btn:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.analyze-btn {
    width: 100%;
    margin-top: 1.5rem;
}

/* Loading */
.loading-card {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(255,255,255,0.2);
    border-top-color: var(--green-lime);
    border-right-color: var(--gold);
    border-bottom-color: var(--green-lime);
    border-left-color: var(--gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

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

.loading-message {
    font-size: 1.3rem;
    font-weight: 600;
    color: white;
    margin-bottom: 1rem;
}

.loading-steps {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-start;
    max-width: 240px;
    margin: 1.5rem auto 0;
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
}

.step i {
    font-size: 1.1rem;
    width: 24px;
}

.step.active {
    color: white;
    font-weight: 600;
}

.step.active i {
    color: #b9f6ca;
}

/* Result Card */
.result-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid rgba(255,255,255,0.2);
}

.result-header h2 {
    font-size: 1.8rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
}

.leaf-detection {
    background: rgba(255,255,255,0.2);
    padding: 0.5rem 1.2rem;
    border-radius: 40px;
    font-size: 1rem;
    color: white;
    font-weight: 500;
}

.result-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.result-item {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 24px;
    padding: 1.2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(4px);
    transition: transform 0.2s, background 0.2s;
}

.result-item:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-4px);
}

.result-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(145deg, var(--green-vibrant), var(--green-lime));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    color: white;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

.result-label {
    display: block;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.result-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: white;
    line-height: 1.3;
    text-shadow: 0 2px 5px rgba(0, 30, 0, 0.5);
}

.confidence-wrapper {
    width: 100%;
}

.confidence-bar {
    height: 8px;
    background: rgba(255,255,255,0.3);
    border-radius: 20px;
    margin-top: 6px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green-lime), var(--gold));
    border-radius: 20px;
    transition: width 0.6s ease;
    box-shadow: 0 0 10px var(--gold);
}

.status-badge {
    display: inline-block;
    padding: 0.3rem 1rem;
    border-radius: 40px;
    font-weight: 600;
    font-size: 0.9rem;
    background: rgba(255,255,255,0.2);
    color: white;
    text-transform: capitalize;
}

.status-badge.healthy {
    background: linear-gradient(145deg, #2e7d32, #66bb6a);
    color: white;
    box-shadow: 0 4px 10px #2e7d32;
}

.status-badge.diseased {
    background: linear-gradient(145deg, #b71c1c, #f44336);
    color: white;
    box-shadow: 0 4px 10px #b71c1c;
}

/* Treatment Card */
.treatment-card {
    background: rgba(0, 20, 0, 0.3);
    border-radius: 28px;
    padding: 1.8rem;
    margin: 2rem 0 1.5rem;
    border: 1px solid var(--green-lime);
    box-shadow: 0 10px 30px rgba(0, 30, 0, 0.5);
}

.treatment-card h3 {
    font-size: 1.5rem;
    color: var(--green-neon);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.treatment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.2rem;
}

.treatment-item {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: rgba(255, 255, 255, 0.1);
    padding: 1.2rem;
    border-radius: 20px;
    border-left: 4px solid var(--green-lime);
    transition: 0.2s;
}

.treatment-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-left-color: var(--gold);
    transform: translateX(4px);
}

.treatment-item i {
    font-size: 2rem;
    color: white;
    background: linear-gradient(145deg, var(--green-vibrant), var(--green-lime));
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.treatment-item h4 {
    font-size: 1rem;
    color: rgba(255,255,255,0.8);
    margin-bottom: 5px;
}

.treatment-item p {
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    margin-bottom: 5px;
}

.dosage {
    font-size: 0.85rem;
    background: rgba(255,255,255,0.2);
    padding: 4px 10px;
    border-radius: 30px;
    display: inline-block;
    color: var(--green-neon);
    font-weight: 600;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Error Card */
.error-card {
    text-align: center;
}

.error-card i {
    font-size: 4rem;
    color: #ffb74d;
    margin-bottom: 1rem;
}

.error-card h3 {
    font-size: 1.8rem;
    color: white;
    margin-bottom: 0.5rem;
}

.error-card p {
    color: rgba(255,255,255,0.9);
    margin-bottom: 1.8rem;
}

/* Footer */
.footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 2rem;
    margin-top: 3rem;
    color: #ddd;
    font-size: 0.9rem;
    flex-wrap: wrap;
    gap: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255,255,255,0.15);
}

.footer p:first-child {
    font-weight: 600;
    color: var(--green-neon);
}

/* Responsive */
@media (max-width: 650px) {
    .app-wrapper {
        padding: 1rem;
    }
    .card {
        padding: 1.8rem;
    }
    .result-grid {
        grid-template-columns: 1fr;
    }
    .treatment-grid {
        grid-template-columns: 1fr;
    }
    .footer {
        flex-direction: column;
        text-align: center;
    }
}