/* GeoPhoto Tagger - Additional Styles */

/* Smooth transitions */
* {
    transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

/* Body and container */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Photo grid item hover effect */
[data-photo-id]:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

/* Photo grid item active state for mobile */
[data-photo-id]:active {
    transform: scale(0.95);
    opacity: 0.8;
}

/* Button hover effects */
button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Details sheet animation */
#detailsSheet {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(100%);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Map container */
#map {
    z-index: 0;
}

/* Leaflet popup styling */
.leaflet-popup-content {
    margin: 8px;
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* File input label hover */
label:has(input[type="file"]):hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

/* Input focus styles */
input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Loading animation */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Tab button transition */
.tab-btn {
    transition: all 0.2s ease;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    #detailsSheet > div {
        max-height: 90vh;
        border-radius: 16px 16px 0 0;
        padding: 1rem;
    }

    .grid.gap-4 {
        gap: 1rem;
    }

    /* Easier to tap buttons on mobile */
    #detailsSheet button {
        padding: 0.75rem 1rem;
        font-size: 15px;
    }

    /* Better input fields on mobile */
    #detailsSheet input {
        font-size: 16px; /* Prevent iOS zoom */
        padding: 0.75rem;
    }

    /* Selection actions on mobile */
    #selectionActions .flex {
        flex-direction: column;
    }

    #selectionActions button {
        width: 100%;
    }
}

/* Empty message visibility is controlled by JavaScript */

/* Image object-fit for thumbnails */
img {
    object-fit: cover;
}

/* Prevent text selection on interactive elements */
.tab-btn,
[data-photo-id],
button {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
}

/* Touch-friendly tap highlighting */
@media (hover: none) {
    button,
    .tab-btn,
    [data-photo-id] {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    }
}

/* Ensure full-width on mobile */
@media (max-width: 768px) {
    .md\:w-\[720px\] {
        width: 100%;
    }
}

/* Better visibility for GPS icon */
[data-photo-id] .absolute.top-1.left-1 {
    backdrop-filter: blur(8px);
}

/* Smooth fade-in for photo grid */
#photoGrid > div {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Tags in photo grid */
.absolute.bottom-1 span {
    backdrop-filter: blur(4px);
}

/* Export button styling */
#exportTab button {
    transition: all 0.2s ease;
}

#exportTab button:hover {
    transform: translateY(-2px);
}

/* Settings tab input */
#apiKeyInput {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 14px;
}

/* Detail sheet sections */
.border.rounded-xl {
    transition: box-shadow 0.2s ease;
}

.border.rounded-xl:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Ensure map renders correctly */
.leaflet-container {
    font-family: inherit;
}

/* Loading indicator pulse */
#busyIndicator:not(:empty) {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Sticky header shadow on scroll */
.sticky {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Info chip styling */
#infoChip b {
    color: #1f2937;
}

/* Modal backdrop */
#detailsSheet {
    backdrop-filter: blur(2px);
}

/* Responsive grid adjustments */
@media (min-width: 1280px) {
    #photoGrid {
        grid-template-columns: repeat(8, minmax(0, 1fr));
    }
}

@media (max-width: 480px) {
    #photoGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
    }
}

/* Better button spacing on mobile */
@media (max-width: 640px) {
    .flex.gap-2 {
        flex-wrap: wrap;
    }

    /* Export tab buttons */
    #exportTab button {
        padding: 0.875rem 1rem;
        font-size: 15px;
        min-height: 52px;
    }

    /* Stack export buttons on mobile */
    #exportTab .grid {
        grid-template-columns: 1fr;
    }
}

/* Ensure proper touch targets */
button,
label,
.tab-btn {
    min-height: 44px;
}

/* Touch manipulation for better mobile experience */
.touch-manipulation {
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.2);
}

/* Mobile-specific improvements */
@media (max-width: 640px) {
    /* Larger touch targets on mobile */
    button,
    label {
        min-height: 48px;
        font-size: 16px; /* Prevent zoom on iOS */
    }

    /* Better spacing on mobile */
    .p-4 {
        padding: 1rem;
    }

    /* Photo grid optimization */
    #photoGrid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.75rem;
    }

    /* Larger tab buttons */
    .tab-btn {
        padding: 0.75rem 0.5rem;
        font-size: 14px;
    }
}

/* Improve readability of pre-formatted text */
pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Photo selection checkbox */
.photo-checkbox {
    appearance: none;
    -webkit-appearance: none;
    background-color: white;
    border: 2px solid #ddd;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    display: inline-block;
    position: relative;
}

.photo-checkbox:checked {
    background-color: #3b82f6;
    border-color: #3b82f6;
}

.photo-checkbox:checked::after {
    content: "✓";
    color: white;
    font-size: 18px;
    font-weight: bold;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Selection mode border animation */
[data-photo-id].border-blue-500 {
    animation: selectedPulse 0.3s ease;
}

@keyframes selectedPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}
