:root {
    --primary-color: #2e7d32;
    --primary-light: #4caf50;
    --primary-dark: #1b5e20;
    --accent-color: #8bc34a;
    --bg-color: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --error: #ef4444;
    --error-light: #fee2e2;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --border-radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

body {
    background: rgba(248, 250, 252, 0.8);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

.results-page .container {
    max-width: 900px;
}

.results-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(248, 250, 252, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 1.25rem 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 1rem;
    border-bottom: 0px solid rgba(0, 0, 0, 0.05);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin: 0;
}

.primary-btn.sm {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    min-width: auto;
    border-radius: 10px;
}

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

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 0.5rem;
    letter-spacing: -0.025em;
}

header h1 i {
    color: var(--primary-color);
}

header p {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

/* Upload Section */
.upload-section {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.drop-zone {
    border: 2px dashed #c2d784;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    background: #fdfdfd;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: #f0fdf4;
}

.drop-zone i {
    font-size: 3.5rem;
    color: var(--primary-light);
}

.drop-zone p {
    font-weight: 600;
    color: var(--text-main);
}

/* Error Banner */
.error-banner {
    background-color: var(--error-light);
    color: var(--error);
    padding: 1rem;
    border-radius: 12px;
    margin-top: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Preview Area */
.preview-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.25rem;
    margin-top: 2rem;
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.remove-btn {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #e54d2e;
    color: var(--white);
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    z-index: 10;
    line-height: 1;
}

.remove-btn:hover {
    background: #c63a1c;
}

.organ-select {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 6px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--primary-dark);
}

/* Options Panel */
.options-panel {
    margin-top: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2rem;
}

.settings-grid {
    width: 100%;
    display: flex;
    justify-content: center;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-item select {
    width: 200px;
    padding: 12px 16px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
    background-color: #fff;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.setting-item select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Primary Button */
.primary-btn {
    width: 100%;
    max-width: 300px;
    padding: 1.1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    border-radius: 14px;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    text-decoration: none;
    box-shadow: 0 4px 14px 0 rgba(46, 125, 50, 0.3);
}

.result-header-button {
    max-width: 120px;
}

.results-header h1 {
    color: #333;
    font-weight: 600;
    font-size: 20px;
}

.primary-btn:hover:not(:disabled) {
    background: var(--primary-dark);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #94a3b8;
    box-shadow: none;
}

/* Results Card Design */
.result-card {
    background: var(--white);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(0, 0, 0, 0.03);
    position: relative;
    overflow: hidden;
}

.score-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: var(--accent-color);
    color: var(--white);
    padding: 8px 16px;
    font-weight: 800;
    font-size: 0.85rem;
    border-bottom-left-radius: 20px;
    box-shadow: var(--shadow-sm);
}

.scientific-name {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-dark);
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.common-names {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
}

.taxonomy {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 2rem;
}

.taxonomy span {
    background: #f1f5f9;
    color: var(--text-main);
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 700;
    border: 1px solid #e2e8f0;
}

.related-images-title {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.related-images {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-light) transparent;
}

.related-images::-webkit-scrollbar {
    height: 6px;
}

.related-images::-webkit-scrollbar-thumb {
    background-color: var(--primary-light);
    border-radius: 10px;
}

.related-images img {
    height: 140px;
    width: 140px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.loader-sm {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem 1rem;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .upload-section {
        padding: 1.5rem;
    }

    .drop-zone {
        padding: 2rem 1rem;
    }

    .scientific-name {
        font-size: 1.4rem;
    }

    .primary-btn {
        max-width: 100%;
    }

    .results-header {
        flex-direction: column;
        text-align: center;
        gap: 1rem;
        padding: 1rem 0.5rem;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

footer {
    text-align: center;
    margin-top: 2rem;
    padding-bottom: 2rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 700;
}

.hidden {
    display: none;
}