/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #8B4513;
    --secondary-color: #A0522D;
    --accent-color: #F5DEB3;
    --text-color: #333;
    --bg-color: #f8f9fa;
    --card-bg: #fff;
    --border-color: #ddd;
    --shadow: rgba(0,0,0,0.1);
}

[data-theme="dark"] {
    --primary-color: #CD853F;
    --secondary-color: #DEB887;
    --accent-color: #F5DEB3;
    --text-color: #e0e0e0;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --border-color: #333;
    --shadow: rgba(0,0,0,0.3);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--bg-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px var(--shadow);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--accent-color);
}

.logo {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent-color);
}

.header-disclaimer {
    color: var(--accent-color);
    opacity: 0.8;
    font-style: italic;
    text-align: center;
    flex-basis: 100%;
    order: 3;
}

.header-nav {
    order: 2;
}

nav ul {
    display: flex;
    list-style: none;
    gap: 2rem;
    align-items: center;
}

nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover {
    color: var(--accent-color);
}

/* Theme Toggle */
.theme-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Hero Section */
.hero {
    background: linear-gradient(rgba(139, 69, 19, 0.8), rgba(160, 82, 45, 0.8)),
                url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 600"><rect fill="%23D2691E" width="1000" height="600"/><path fill="%23CD853F" d="M0 300L100 280L200 320L300 290L400 310L500 285L600 305L700 275L800 295L900 320L1000 300V600H0Z"/></svg>') center/cover;
    color: white;
    padding: 6rem 0;
    text-align: center;
}

.hero h2 {
    font-size: 3rem;
    margin-bottom: 1rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: white;
    border: 2px solid white;
}

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

/* Browse Section */
.browse-section {
    padding: 4rem 0;
}

.browse-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: var(--primary-color);
    font-size: 2.5rem;
}

.search-bar {
    display: flex;
    max-width: 600px;
    margin: 0 auto 2rem;
    gap: 1rem;
}

.search-bar input {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-bar {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.filter-bar select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--card-bg);
    color: var(--text-color);
    min-width: 150px;
}

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

/* Results Counter */
.results-counter {
    text-align: center;
    margin: 1rem 0;
    padding: 0.5rem;
}

.results-counter span {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
    font-style: italic;
}

/* Species Grid */
.species-grid {
    margin-top: 2rem;
}

/* Species Sections */
.species-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 3rem 0 1.5rem 0;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px var(--shadow);
}

.species-section-header:first-child {
    margin-top: 1rem;
}

.species-section-header h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
}

.section-count {
    font-size: 0.9rem;
    opacity: 0.9;
    background: rgba(255, 255, 255, 0.2);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-weight: 500;
}

.species-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.species-card {
    background: var(--card-bg);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px var(--shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
}

.species-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px var(--shadow);
}

.species-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(45deg, #D2691E, #CD853F);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
    position: relative;
    overflow: hidden;
}

.species-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s ease;
}

.image-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    padding: 1rem;
    box-sizing: border-box;
}

.fallback-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: block;
}

.fallback-text {
    font-size: 0.9rem;
    font-weight: 600;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

.species-info {
    padding: 1.5rem;
}

.species-info h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.2rem;
}

.species-info .scientific-name {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 1rem;
}

.species-info .category {
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
}

/* Identify Section */
.identify-section {
    background: var(--bg-color);
    padding: 4rem 0;
}

.identify-section h2 {
    text-align: center;
    margin-bottom: 3rem;
    color: var(--primary-color);
    font-size: 2.5rem;
}

.upload-area {
    max-width: 600px;
    margin: 0 auto;
}

.upload-box {
    border: 3px dashed var(--primary-color);
    border-radius: 10px;
    padding: 3rem;
    text-align: center;
    background: var(--card-bg);
    transition: all 0.3s ease;
}

.upload-box:hover {
    border-color: var(--secondary-color);
    background: var(--bg-color);
}

.camera-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

.upload-box p {
    font-size: 1.2rem;
    margin-bottom: 2rem;
    color: var(--text-color);
    opacity: 0.7;
}

.upload-box input[type="file"] {
    display: none;
}

.upload-box .btn {
    margin: 0 0.5rem;
}

/* Image Preview */
.image-preview {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 2rem;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 15px var(--shadow);
}

.image-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Identification Results */
.identification-result {
    margin-top: 2rem;
    background: var(--card-bg);
    border-radius: 10px;
    padding: 2rem;
}

.identification-result h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    text-align: center;
}

.result-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.result-confidence {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: bold;
    min-width: 60px;
    text-align: center;
}

/* Wood Identification Tips */
.identification-tips {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--card-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
}

.identification-tips h3 {
    text-align: center;
    color: var(--primary-color);
    font-size: 1.8rem;
    margin-bottom: 2rem;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.tip-card {
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.5rem;
    text-align: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tip-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px var(--shadow);
}

.tip-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

.tip-card h4 {
    color: var(--primary-color);
    font-size: 1.2rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.tip-card p {
    color: var(--text-color);
    line-height: 1.6;
    font-size: 0.95rem;
}

/* AI Results Styling */
.ai-results {
    margin-top: 1rem;
}

.ai-primary {
    border-left: 4px solid #4CAF50;
    background: rgba(76, 175, 80, 0.1);
}

.ai-alternative {
    border-left: 4px solid #FF9800;
    background: rgba(255, 152, 0, 0.1);
}

.ai-reasoning {
    font-style: italic;
    color: var(--text-color);
    opacity: 0.8;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.ai-characteristics {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.ai-characteristics h4 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

.ai-characteristics ul {
    margin: 0;
    padding-left: 1.5rem;
}

.ai-characteristics li {
    margin-bottom: 0.3rem;
    color: var(--text-color);
}

.ai-powered {
    text-align: center;
    margin-top: 1rem;
    font-style: italic;
    color: var(--primary-color);
    font-weight: 600;
}

.ai-error {
    color: #f44336;
    background: rgba(244, 67, 54, 0.1);
    padding: 1rem;
    border-radius: 8px;
    border-left: 4px solid #f44336;
    margin-top: 1rem;
}

.ai-fallback-notice {
    background: rgba(255, 193, 7, 0.1);
    border-left: 4px solid #FFC107;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.ai-fallback-notice p {
    margin: 0.5rem 0;
    color: var(--text-color);
}

.ai-fallback-notice strong {
    color: #FF8F00;
}

/* Image Attribution */
.image-attribution {
    margin-top: 2rem;
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 8px;
    border-left: 4px solid var(--primary-color);
    opacity: 0.8;
}

.image-attribution h4 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.image-attribution p {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-color);
}

.image-attribution strong {
    font-weight: 600;
}

.image-attribution a {
    color: var(--accent-color);
    text-decoration: none;
}

.image-attribution a:hover {
    text-decoration: underline;
}

.image-attribution small {
    font-style: italic;
    opacity: 0.7;
}

/* Utility Classes */
.hidden {
    display: none;
}

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

/* Footer */
footer {
    background: #333;
    color: white;
    text-align: center;
    padding: 2rem 0;
}

.footer-copyright {
    margin-bottom: 1rem;
}

.footer-copyright a {
    color: var(--accent-color);
    text-decoration: none;
}

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

.footer-links {
    font-size: 0.9rem;
}

.footer-links a {
    color: #ccc;
    text-decoration: none;
    transition: color 0.3s ease;
}

.footer-links a:hover {
    color: var(--accent-color);
}

/* Cookie Consent */
.cookie-consent {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    border-radius: 10px;
    padding: 1.5rem;
    max-width: 400px;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 1000;
}

.cookie-content p {
    margin-bottom: 1rem;
    color: var(--text-color);
}

.cookie-buttons {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.cookie-buttons .btn {
    padding: 8px 16px;
    font-size: 0.9rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--card-bg);
    margin: 2rem;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    color: var(--text-color);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.modal-content h3 {
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.close {
    color: var(--text-color);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.close:hover {
    color: var(--primary-color);
}

.privacy-content {
    line-height: 1.6;
}

.privacy-content ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.privacy-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.privacy-content a:hover {
    text-decoration: underline;
}

/* Species Details Modal */
.species-modal-content {
    max-width: 800px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
}

.species-modal-body {
    padding: 1rem 0;
}

.species-header {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
}

.species-image-large {
    flex: 0 0 250px;
    height: 200px;
    border-radius: 10px;
    overflow: hidden;
    background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 3rem;
}

.species-image-large img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.species-title-section {
    flex: 1;
}

.species-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.species-scientific {
    font-style: italic;
    font-size: 1.2rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 1rem;
}

.species-badges {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.species-badge {
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.badge-category {
    background: var(--accent-color);
    color: var(--primary-color);
}

.badge-region {
    background: var(--primary-color);
    color: white;
}

.badge-sustainability {
    background: #28a745;
    color: white;
}

.badge-sustainability.limited {
    background: #ffc107;
    color: #000;
}

.badge-sustainability.rare {
    background: #dc3545;
    color: white;
}

.species-description {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    color: var(--text-color);
}

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

.detail-section {
    background: var(--bg-color);
    border-radius: 10px;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
}

.detail-section h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-size: 1.3rem;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 0.5rem;
}

.characteristics-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.characteristics-list li {
    background: var(--accent-color);
    color: var(--primary-color);
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

.uses-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.uses-list li {
    background: var(--primary-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 15px;
    font-size: 0.9rem;
    font-weight: 500;
}

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

.property-item {
    text-align: center;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.property-label {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.7;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.property-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

/* Responsive adjustments for species modal */
@media (max-width: 768px) {
    .species-modal-content {
        width: 98%;
        max-height: 95vh;
        margin: 1rem;
    }

    .species-header {
        flex-direction: column;
        text-align: center;
    }

    .species-image-large {
        flex: none;
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
    }

    .species-details-grid {
        grid-template-columns: 1fr;
    }

    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .species-badges {
        justify-content: center;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    header .container {
        flex-direction: column;
        gap: 1rem;
    }

    nav ul {
        gap: 1rem;
    }

    .hero h2 {
        font-size: 2rem;
    }

    .hero-buttons {
        flex-direction: column;
        align-items: center;
    }

    .species-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 1rem;
    }

    .search-bar {
        flex-direction: column;
    }

    .image-actions {
        flex-direction: column;
    }

    .upload-box {
        padding: 2rem 1rem;
    }
}