* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

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

header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
}

header h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
}

header p {
    font-size: 1.2rem;
    opacity: 0.9;
}

/* Network Toggle Button */
.network-toggle-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.network-toggle-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.network-toggle-btn:active {
    transform: translateY(0);
}

/* Responsive: Move button below title on small screens */
@media (max-width: 768px) {
    .network-toggle-btn {
        position: static;
        display: block;
        margin: 10px auto 20px;
        max-width: 200px;
    }
}

/* Header Actions - Responsive Button Grid */
.header-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    max-width: 800px;
    margin: 20px auto 0;
    padding: 0 15px;
}

/* Desktop: 3 columns for wider screens */
@media (min-width: 768px) {
    .header-actions {
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
    }
}

/* Larger desktop: auto-fit for all buttons in a row */
@media (min-width: 1024px) {
    .header-actions {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        max-width: 1000px;
    }
}

.header-actions button,
.header-actions a {
    width: 100%;
    padding: 12px 16px;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

main {
    display: grid;
    gap: 30px;
}

/* Upload Section */
.upload-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.upload-section h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 500;
}

.form-group input[type="text"],
.form-group input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="file"]:focus {
    outline: none;
    border-color: #667eea;
}

.btn-upload {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
}

.btn-upload:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-upload:active {
    transform: translateY(0);
}

.status-message {
    margin-top: 15px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    font-weight: 500;
    display: none;
}

.status-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.file-count {
    margin-top: 8px;
    color: #667eea;
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-progress {
    margin-top: 15px;
}

.progress-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.progress-item.success {
    background: #d4edda;
    color: #155724;
}

.progress-item.error {
    background: #f8d7da;
    color: #721c24;
}

.progress-item.uploading {
    background: #d1ecf1;
    color: #0c5460;
}

/* Gallery Section */
.gallery-section {
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

/* Search and Filter Section */
.search-filter-section {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
}

.search-group,
.filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-group {
    grid-column: 1 / -1; /* Make search span full width */
}

.search-group label,
.filter-group label {
    color: #555;
    font-weight: 500;
    font-size: 0.95rem;
}

.search-group input[type="text"],
.filter-group select {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    background: white;
}

.search-group input[type="text"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: #667eea;
}

@media (max-width: 768px) {
    .search-filter-section {
        grid-template-columns: 1fr;
    }
}

.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
}

.gallery-header h2 {
    color: #333;
    font-size: 1.8rem;
}

.gallery-actions {
    display: flex;
    gap: 10px;
}

.btn-refresh {
    background: #667eea;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-refresh:hover {
    background: #5568d3;
}

.btn-filter {
    background: #ff9800;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-filter:hover {
    background: #f57c00;
}

.btn-filter.active {
    background: #4caf50;
}

.btn-filter.active:hover {
    background: #45a049;
}

.btn-delete-last {
    background: #ff6b6b;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-delete-last:hover {
    background: #ff5252;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.bird-card {
    background: #f8f9fa;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s, box-shadow 0.3s;
}

.bird-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.bird-card img {
    width: 100%;
    height: 400px;
    object-fit: cover;
    background: #f0f0f0;
}

.bird-info {
    padding: 15px;
}

.bird-info h3 {
    color: #333;
    margin-bottom: 8px;
    font-size: 1.2rem;
}

.bird-info p {
    color: #666;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.bird-info .date {
    color: #999;
    font-size: 0.85rem;
    margin-top: 8px;
}

.bird-info .confidence {
    color: #667eea;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 5px;
}

.ai-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.ai-badge:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.exif-badge {
    display: inline-block;
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 8px;
    cursor: pointer;
    transition: transform 0.2s, opacity 0.2s;
}

.exif-badge:hover {
    transform: translateY(-1px);
    opacity: 0.9;
}

.photo-date {
    color: #667eea;
    font-weight: 500;
}

.gps-link {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px dashed #667eea;
    transition: color 0.3s;
}

.gps-link:hover {
    color: #5568d3;
    border-bottom-color: #5568d3;
}

.btn-delete {
    background: #dc3545;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 10px;
    width: 100%;
    transition: background 0.3s;
}

.btn-delete:hover {
    background: #c82333;
}

.no-birds {
    text-align: center;
    padding: 40px;
    color: #999;
    font-size: 1.1rem;
}

/* Batch Actions */
.batch-actions {
    background: #f0f4ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    border: 2px solid #667eea;
}

.selected-count {
    color: #667eea;
    font-weight: 600;
    font-size: 1rem;
}

/* Batch action buttons - consistent styling */
.btn-select-all,
.btn-select-species,
.btn-batch-rename,
.btn-batch-edit,
.btn-download,
.btn-identify-selected {
    background: #667eea;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-select-all:hover,
.btn-select-species:hover,
.btn-batch-rename:hover,
.btn-batch-edit:hover,
.btn-download:hover,
.btn-identify-selected:hover {
    background: #5568d3;
}

/* Delete selected button - red color for destructive action */
.btn-delete-selected {
    background: #ef4444;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-delete-selected:hover {
    background: #dc2626;
}

/* Auto-focus selected button - purple gradient */
.btn-auto-focus-selected {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-auto-focus-selected:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8a 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

/* Show selected only button - teal color */
.btn-show-selected {
    background: #14b8a6;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-show-selected:hover {
    background: #0d9488;
}

.btn-show-selected.active {
    background: #f97316;
}

.btn-show-selected.active:hover {
    background: #ea580c;
}

/* Card Selection */
.card-select {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 10;
}

.bird-card {
    position: relative;
}

/* Hidden state for show-selected-only mode - prevents flicker by keeping element in DOM */
.bird-card.hidden-filtered {
    display: none !important;
}

.bird-checkbox {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #667eea;
}

/* Edit Mode */
.bird-edit-mode {
    padding-top: 10px;
}

.bird-edit-mode .form-group {
    margin-bottom: 15px;
}

.bird-edit-mode .form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-weight: 500;
    font-size: 0.9rem;
}

.bird-edit-mode .form-group input[type="text"] {
    width: 100%;
    padding: 8px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.3s;
}

.bird-edit-mode .form-group input[type="text"]:focus {
    outline: none;
    border-color: #667eea;
}

/* Card Actions */
.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-edit,
.btn-save,
.btn-cancel {
    flex: 1;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-edit {
    background: #667eea;
    color: white;
}

.btn-edit:hover {
    background: #5568d3;
}

.btn-save {
    background: #28a745;
    color: white;
}

.btn-save:hover {
    background: #218838;
}

.btn-cancel {
    background: #6c757d;
    color: white;
}

.btn-cancel:hover {
    background: #5a6268;
}

.btn-reidentify {
    background: #ff9800;
    color: white;
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    margin-bottom: 10px;
    transition: background 0.3s;
}

.btn-reidentify:hover {
    background: #f57c00;
}

.btn-reidentify:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 50px;
    color: white;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1002;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.lightbox-close:hover {
    transform: scale(1.2);
    color: #667eea;
}

/* Navigation Arrows */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.3s;
    backdrop-filter: blur(10px);
}

.lightbox-nav:hover {
    background: rgba(102, 126, 234, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
    left: 30px;
}

.lightbox-next {
    right: 30px;
}

/* Bottom Controls Bar */
.lightbox-controls {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 1002;
    background: rgba(0, 0, 0, 0.7);
    padding: 12px 20px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.control-btn {
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s;
    padding: 0;
}

.control-btn:hover {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.control-btn svg {
    pointer-events: none;
}

/* Quality toggle button (wider for text) */
.quality-toggle-btn {
    width: auto;
    min-width: 140px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.lightbox-content {
    max-width: 90%;
    max-height: 90%;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

#lightboxImage {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    transition: transform 0.3s ease;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}

/* Lightbox Info Panel */
.lightbox-info {
    position: absolute;
    top: 20px;
    left: 20px;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    color: white;
    z-index: 1002;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.lightbox-info-content h3 {
    margin: 0 0 15px 0;
    font-size: 1.5rem;
    color: #667eea;
    border-bottom: 2px solid rgba(102, 126, 234, 0.5);
    padding-bottom: 10px;
}

.info-row-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.info-row {
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.95rem;
    line-height: 1.5;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row strong {
    color: #a5b4fc;
    display: inline-block;
    min-width: 120px;
}

.info-counter {
    text-align: center;
    font-size: 1rem;
    color: #667eea;
    padding-top: 15px;
    margin-top: 10px;
    border-top: 2px solid rgba(102, 126, 234, 0.5);
}

.lightbox-info .gps-link {
    color: #a5b4fc;
    text-decoration: none;
    border-bottom: 1px dashed #a5b4fc;
}

.lightbox-info .gps-link:hover {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Loading Indicator */
.loading-indicator {
    text-align: center;
    padding: 30px;
    color: white;
}

.loading-indicator p {
    margin-top: 15px;
    font-size: 1.1rem;
    opacity: 0.9;
}

.spinner {
    margin: 0 auto;
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Custom Multi-Select Dropdown */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-selected {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    user-select: none;
    transition: border-color 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.multiselect-selected::after {
    content: '▼';
    font-size: 0.8rem;
    color: #666;
    margin-left: 10px;
}

.multiselect-selected:hover {
    border-color: #667eea;
}

.multiselect-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 2px solid #667eea;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
}

.multiselect-options {
    padding: 8px;
}

.multiselect-option {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
    user-select: none;
}

.multiselect-option:hover {
    background: #f0f4ff;
}

.multiselect-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #667eea;
    margin-right: 10px;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }

    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

    .upload-section,
    .gallery-section {
        padding: 20px;
    }

    .lightbox-close {
        font-size: 40px;
        top: 10px;
        right: 10px;
        width: 50px;
        height: 50px;
    }

    .lightbox-nav {
        width: 50px;
        height: 50px;
    }

    .lightbox-prev {
        left: 10px;
    }

    .lightbox-next {
        right: 10px;
    }

    .lightbox-controls {
        bottom: 20px;
        padding: 10px 15px;
        gap: 8px;
    }

    .control-btn {
        width: 40px;
        height: 40px;
    }

    .control-btn svg {
        width: 18px;
        height: 18px;
    }

    .lightbox-info {
        max-width: calc(100vw - 40px);
        left: 10px;
        top: 70px;
        max-height: calc(100vh - 180px);
        font-size: 0.9rem;
    }

    .lightbox-info-content h3 {
        font-size: 1.2rem;
    }
}
