/* FONT IMPORT */
@import url('https://fonts.googleapis.com/css2?family=Merriweather:wght@700&family=Montserrat:wght@400;500;600&display=swap');

/* BASIC RESET & THEME */
:root {
    --primary-green: #556b2f;
    --dark-green: #2e4034;
    --background-dark: #1a2a26;
    --text-light: #f2f2f2;
    --text-muted: #a0a0a0;
    --border-color: rgba(255, 255, 255, 0.15);
    --module-bg: rgba(255, 255, 255, 0.05);
    --module-bg-hover: rgba(255, 255, 255, 0.1);
}

body {
    font-family: 'Montserrat', sans-serif;
    background-color: var(--background-dark);
    color: var(--text-light);
    margin: 0;
    padding-top: 80px; /* Space for fixed header */
}

/* BACKGROUND CYCLER & OVERLAY */
#background-cycler {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2; background-size: cover; background-position: center;
    transition: background-image 1.5s ease-in-out;
}
.background-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to bottom, rgba(26, 42, 38, 0.9), rgba(26, 42, 38, 0.7));
    z-index: -1;
}

/* MAIN LAYOUT */
.page-container { max-width: 1600px; margin: 2rem auto; padding: 0 20px; }
.page-header { text-align: center; margin-bottom: 1rem; background-color: transparent; padding: 0; border-radius: 0; }
.page-header h1 { font-family: 'Merriweather', serif; font-size: 3rem; margin-bottom: 1rem; }
.search-bar-container { display: flex; justify-content: center; gap: 10px; align-items: flex-start; }
.search-bar-container input[type="search"] { width: 100%; padding: 12px 20px; border-radius: 50px; border: 1px solid var(--border-color); background-color: var(--module-bg); color: var(--text-light); font-size: 1rem; box-sizing: border-box; }
.search-bar-container button { padding: 12px 25px; border-radius: 50px; border: none; background-color: var(--primary-green); color: white; cursor: pointer; font-weight: bold; }
.search-layout { display: flex; align-items: flex-start; gap: 2rem; margin-top: 2rem; }
.filter-panel { flex: 1; max-width: 250px; position: sticky; top: 100px; }
.results-panel { flex: 4; }

/* FILTER MODULES */
.filter-group { background-color: var(--module-bg); border: 1px solid var(--border-color); border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; }
.filter-group h3 { margin-top: 0; border-bottom: 1px solid var(--border-color); padding-bottom: 0.5rem; font-size: 1.1rem; }
.filter-group p { font-size: 0.9rem; color: var(--text-muted); line-height: 1.5; margin-top: 0.5rem; }
.filter-group input[type="text"] { width: 100%; box-sizing: border-box; padding: 8px; background-color: rgba(0,0,0,0.2); border: 1px solid #444; color: #fff; border-radius: 4px; }
.checkbox-list div, .radio-list div { margin-bottom: 0.5rem; }

/* ADVANCED SEARCH TOOLS SECTION */
.advanced-search-tools { margin-top: 3rem; margin-bottom: 2rem; display: flex; flex-direction: column; gap: 1rem; }
.deep-search-tool { padding: 1.5rem; }
.deep-search-controls { display: flex; align-items: flex-end; gap: 1.5rem; flex-wrap: wrap; margin-top: 1rem; }
.control-item { display: flex; flex-direction: column; gap: 0.5rem; }
.control-item label { font-size: 0.9rem; font-weight: 500; color: var(--text-muted); }
.control-item select, .control-item input[type="search"] { padding: 10px 15px; border-radius: 5px; border: 1px solid var(--border-color); background-color: rgba(0,0,0,0.2); color: var(--text-light); font-size: 1rem; min-width: 200px; }
.search-button-small { padding: 10px 20px; border-radius: 5px; border: none; background-color: var(--primary-green); color: white; cursor: pointer; font-weight: bold; }
.small-wrapper { max-width: 300px; width: auto; }

/* --- Breadcrumb navigation --- */
.navigation-bar {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}
.breadcrumb-nav {
    display: flex;
    align-items: center;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}
.breadcrumb-nav li {
    position: relative;
    padding: 0.5rem 1rem;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.2s;
}
.breadcrumb-nav li:hover { color: var(--text-light); }
.breadcrumb-nav li.active-lineage { color: #fff; font-weight: bold; }
.breadcrumb-nav li:not(:last-child)::after {
    content: '>';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}
.breadcrumb-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1002;
    background-color: var(--dark-green);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
    width: 250px;
}
.breadcrumb-nav li:hover > .breadcrumb-dropdown { display: block; }
.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 5px;
    color: var(--text-light);
    text-decoration: none;
}
.dropdown-item:hover { background-color: var(--primary-green); }
.dropdown-item img { width: 40px; height: 40px; object-fit: cover; border-radius: 50%; background-color: #333; }
.dropdown-item .item-text { display: flex; flex-direction: column; }
.dropdown-item .item-text strong { font-size: 0.9rem; }
.dropdown-item .item-text em { font-size: 0.8rem; color: var(--text-muted); font-style: normal; }

/* RESULTS HEADER */
.results-header { display: flex; justify-content: flex-end; align-items: center; margin-bottom: 1rem; gap: 1rem; }

/* Grid View */
#search-results.grid-view { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }

/* List View */
#search-results.list-view { display: flex; flex-direction: column; gap: 10px; }
#search-results.list-view .species-card { flex-direction: row; align-items: center; }
#search-results.list-view .card-image { width: 60px; height: 60px; }

/* Species Card */
.species-card { 
    position: relative;
    background-color: var(--module-bg); border: 1px solid var(--border-color); border-radius: 8px; 
    overflow: hidden; text-decoration: none; color: var(--text-light); 
    transition: background-color 0.2s; display: flex; flex-direction: column;
}
.species-card:hover { background-color: var(--module-bg-hover); }
.card-image { width: 100%; height: 110px; object-fit: cover; background-color: #333; }
.card-info { padding: 8px; flex-grow: 1; }
.card-info h4 { margin: 0 0 4px 0; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-info p { margin: 0; font-size: 0.75rem; color: var(--text-muted); }
.card-icons { 
    position: absolute; top: 5px; right: 5px; font-size: 1rem; display: flex; gap: 4px;
    background-color: rgba(0,0,0,0.5); padding: 3px 5px; border-radius: 5px;
}
.card-icons span { display: none; }
.card-icons span.active { display: block; }

/* NEW: Explore button (for non-species ranks) */
.species-card .explore-btn {
    position: absolute;
    left: 6px;
    bottom: 6px;
    background: rgba(0,0,0,0.55);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}
.species-card .explore-btn:hover {
    background: var(--primary-green);
    transform: translateY(-2px);
}

/* NEW: Share button on cards */
.species-card .share-btn {
    position: absolute;
    right: 6px;
    bottom: 6px;
    background: rgba(0,0,0,0.55);
    border: 1px solid var(--border-color);
    color: #fff;
    font-size: 0.65rem;
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: background 0.2s, transform 0.15s;
    line-height: 1;
}
.species-card .share-btn:hover {
    background: var(--primary-green);
    transform: translateY(-2px);
}

/* Search Suggestions Styles */
.search-input-wrapper { position: relative; width: 50%; max-width: 500px; }
.suggestions-container {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background-color: #2e4034; border: 1px solid var(--border-color); border-top: none;
    border-radius: 0 0 16px 16px; z-index: 1001; max-height: 300px; overflow-y: auto;
}
.suggestion-item {
    padding: 12px 20px; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
}
.suggestion-item:hover, .suggestion-item.active { background-color: var(--primary-green); }
.suggestion-item .suggestion-name { font-weight: bold; }
.suggestion-item .suggestion-rank { font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; }

/* Pagination Styles */
.pagination-controls { display: flex; justify-content: center; align-items: center; margin-top: 2rem; gap: 5px; }
.page-btn {
    background-color: var(--module-bg); border: 1px solid var(--border-color);
    color: var(--text-muted); padding: 8px 14px; border-radius: 5px; cursor: pointer; transition: all 0.2s;
}
.page-btn:hover { background-color: var(--module-bg-hover); color: var(--text-light); }
.page-btn.active { background-color: var(--primary-green); color: white; font-weight: bold; border-color: var(--primary-green); }
.page-btn.disabled { opacity: 0.5; cursor: not-allowed; }
.page-info { color: var(--text-muted); margin: 0 10px; }

/* --- Share modal styles (matches Species Detail minimal styles) --- */
.share-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.7);
    display: none; justify-content: center; align-items: center; z-index: 4000;
}
.share-modal-content {
    background: #2c2c2c; color: #f2f2f2; width: 95%; max-width: 560px;
    border-radius: 10px; padding: 1.25rem 1.25rem 1rem; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
.share-modal-header {
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.15); padding-bottom: 0.5rem; margin-bottom: 0.75rem;
}
.share-modal-header h2 { margin: 0; font-size: 1.2rem; }
.share-close-btn { background: none; border: none; color: #f2f2f2; font-size: 1.6rem; cursor: pointer; }
.share-form label { display:block; margin: 0.5rem 0 0.25rem; color: #ddd; }
.share-form textarea, .share-form select, .share-form input[type="text"] {
    width: 100%; box-sizing: border-box; background: #444; color: #fff; border: 1px solid #666; border-radius: 6px; padding: 8px;
}
.share-form .row { display: grid; grid-template-columns: 1fr; gap: 0.75rem; }
.share-form .checkbox-row { display: flex; gap: 0.75rem; align-items: center; }
.share-friend-list { max-height: 180px; overflow-y: auto; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; padding: 8px; }
.friend-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; }
.friend-item img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.share-actions { display: flex; gap: 10px; margin-top: 1rem; }
.share-actions .primary { background: #556b2f; color: #fff; border: none; padding: 10px 14px; border-radius: 6px; cursor: pointer; }
.share-actions .secondary { background: none; color: #ff8a80; border: 1px solid #aa5555; padding: 10px 14px; border-radius: 6px; cursor: pointer; }
.hint { color: #a0a0a0; font-size: 0.85rem; }
.section-title { margin: 0.75rem 0 0.25rem; font-weight: 600; }
.pill { display:inline-block; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color:#ddd; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; margin-left: 6px; }
.small-note { color: #bbb; font-size: 0.85rem; margin-top: 0.25rem; }