/* iNaturalist Species Overlap Mapper — Styles */
/* Mirrors the shared iNaturalist suite: Ocean blue + Monarch orange/yellow */

/* ===== CSS Variables ===== */
:root {
    --primary-color: #1e5aa8;
    --primary-dark: #0a2f5f;
    --primary-light: #4fc3f7;
    --accent-color: #ff8c00;
    --accent-yellow: #ffa500;
    --accent-light: #ffb84d;
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ff8c00;
    --info-color: #4299e1;
    --text-primary: #2d3748;
    --text-secondary: #718096;
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --bg-ocean: #0b3d91;
    --border-color: #e2e8f0;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.2);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, var(--bg-ocean) 0%, var(--primary-dark) 100%);
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

/* ===== Header Bar ===== */
.header-bar {
    background: linear-gradient(135deg, var(--bg-ocean) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 15px 0;
    border-bottom: 3px solid var(--accent-yellow);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.header-logo {
    max-width: 800px;
    width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 20px auto;
    background: var(--bg-primary);
    padding: 40px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

/* ===== Typography ===== */
h1 { color: var(--text-primary); margin-bottom: 10px; font-size: 2em; }
h2 { color: var(--text-primary); margin-bottom: 15px; font-size: 1.5em; }
h3 { color: var(--text-primary); margin-bottom: 10px; font-size: 1.2em; }

.version {
    color: var(--text-secondary);
    font-size: 0.9em;
    margin-bottom: 30px;
}

a { color: var(--accent-color); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--accent-yellow); text-decoration: underline; }

/* ===== Form Elements ===== */
.form-group { margin-bottom: 20px; }

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 90, 168, 0.1);
}

.help-text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* ===== Buttons ===== */
button {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    font-family: inherit;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(255, 140, 0, 0.5);
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--accent-yellow) 100%);
}

button:active { transform: translateY(0); }

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.secondary-btn {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
    margin-bottom: 20px;
    font-size: 14px;
    padding: 10px 20px;
}

.secondary-btn:hover {
    background: var(--border-color);
    transform: none;
    box-shadow: none;
    color: var(--text-primary);
}

/* ===== Species fields ===== */
.species-field label {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.remove-species-btn {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 26px;
    height: 26px;
    min-width: 26px;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    flex-shrink: 0;
}

.remove-species-btn:hover {
    background: #c53030;
    transform: none;
    box-shadow: none;
}

/* ===== Autocomplete ===== */
.autocomplete-wrapper { position: relative; }

.autocomplete-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--primary-color);
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--shadow);
}

.autocomplete-results.active { display: block; }

.autocomplete-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.autocomplete-item:last-child { border-bottom: none; }

.autocomplete-item:hover,
.autocomplete-item.selected { background: var(--bg-secondary); }

.autocomplete-item-name { font-weight: 600; color: var(--text-primary); }
.autocomplete-item-detail { font-size: 0.85em; color: var(--text-secondary); margin-top: 2px; }

.autocomplete-loading,
.autocomplete-no-results {
    padding: 10px 12px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* ===== Location input ===== */
.location-input-group {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.location-input-group .autocomplete-wrapper { flex: 1; }

.map-picker-btn {
    width: auto;
    padding: 0 14px;
    height: 48px;
    font-size: 20px;
    flex-shrink: 0;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.map-picker-btn:hover {
    background: var(--border-color);
    transform: none;
    box-shadow: none;
    color: var(--text-primary);
}

/* ===== Loading ===== */
.loading { display: none; text-align: center; padding: 40px; }
.loading.active { display: block; }

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

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== Error ===== */
.error {
    display: none;
    padding: 15px;
    margin-top: 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--error-color);
    background: #fff5f5;
    color: #742a2a;
}

.error.active { display: block; }

/* ===== Result ===== */
.result { display: none; margin-top: 30px; }
.result.active { display: block; }

.stats {
    background: var(--bg-secondary);
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    line-height: 1.8;
}

.stats-line { margin: 2px 0; }

.map-container {
    width: 100%;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 2px solid var(--border-color);
}

.map-container iframe {
    width: 100%;
    height: 700px;
    border: none;
    display: block;
}

/* ===== Footer ===== */
footer {
    margin-top: 30px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9em;
}

footer p { margin: 5px 0; }

/* ===== Modal ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 { margin: 0; font-size: 1.3em; }

.modal-close {
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    min-width: 32px;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: #c53030;
    transform: none;
    box-shadow: none;
}

.modal-body { padding: 20px 30px; flex: 1; overflow-y: auto; }

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-footer button { width: auto; }

#locationPickerMap {
    width: 100%;
    height: 400px;
    border-radius: var(--border-radius);
    margin: 15px 0;
    border: 2px solid var(--border-color);
}

.selected-coords {
    padding: 12px 15px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    font-family: monospace;
    font-size: 0.9em;
}

.selected-coords strong { color: var(--primary-color); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .container { margin: 10px; padding: 20px; }
    h1 { font-size: 1.5em; }
    .map-container iframe { height: 450px; }
}
