/* Copyright (c) 2020-2025 Skarv Technologies AS */
/* All rights reserved. */
/* Unauthorized copying of this file, via any medium is strictly prohibited. */
/* Proprietary and confidential. */

/* General Styling */
.btn-primary {
    @apply bg-blue-500 text-white px-4 py-2 rounded hover:bg-blue-600 transition;
}

.btn-secondary {
    @apply bg-green-500 text-white px-4 py-2 rounded hover:bg-green-600 transition;
}

.btn-gray {
    @apply bg-gray-500 text-white px-4 py-2 rounded hover:bg-gray-600 transition;
}

.btn-danger {
    @apply bg-red-500 text-white px-4 py-2 rounded hover:bg-red-600 transition;
}

/* File Selection Page */
.file-list {
    @apply space-y-2;
}

.status-icon {
    @apply w-3 h-3 rounded-full;
}

.status-icon.has-annotations {
    @apply bg-green-500;
}

.status-icon.no-annotations {
    @apply bg-gray-300;
}

/* Video Player */
.video-container {
    @apply relative max-h-[45vh] overflow-hidden;
}

.video-controls {
    @apply absolute top-4 left-4 right-4 flex justify-between items-center bg-gray-900 bg-opacity-75 p-4 rounded;
}

.slider-container {
    @apply flex items-center;
}

.slider-label {
    @apply text-white mr-2 text-xs sm:text-base;
}

.slider-value {
    @apply text-white ml-2 text-xs sm:text-base;
}

/* Captures Panel */
.captures-panel {
    @apply w-96 bg-white h-[45vh] flex flex-col transition-all duration-300;
}

.thumbnail-list {
    @apply flex-1 overflow-hidden;
}

.thumbnail {
    @apply w-16 h-16 object-cover cursor-pointer rounded;
}

/* Metadata Section */
.metadata-section {
    @apply flex justify-between bg-gray-200 p-4 gap-4;
}

.metadata-panel {
    @apply w-1/3 bg-white p-2 rounded shadow;
}

.chart-container {
    @apply h-full;
}

/* Modal */
.annotation-modal {
    @apply fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50;
}

.modal-content {
    @apply bg-white rounded-lg p-6 max-w-4xl w-full mx-4;
}

.modal-header {
    @apply flex justify-between items-start mb-4;
}

.modal-body {
    @apply flex gap-6;
}

.metadata-display {
    @apply grid grid-cols-2 gap-2;
}

/* Species Grid */
.species-grid {
    @apply grid grid-cols-3 gap-2;
}

.species-category {
    @apply space-y-2;
}

.species-button {
    @apply w-full p-2 text-xs text-left bg-gray-50 hover:bg-blue-50 rounded transition;
}

/* Seafloor Types */
.seafloor-types {
    @apply flex gap-2;
}

.seafloor-button {
    @apply flex-1 p-2 text-sm text-center bg-gray-50 hover:bg-blue-50 rounded transition;
}

/* Notes Area */
.notes-textarea {
    @apply w-full h-32 px-3 py-2 border rounded resize-none focus:outline-none focus:ring-2 focus:ring-blue-500;
}

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

.flex-center {
    @apply flex items-center justify-center;
}

.text-overflow-ellipsis {
    @apply overflow-hidden whitespace-nowrap text-overflow-ellipsis;
}

#timelineMarkers {
    position: relative;
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.1);
    margin-top: 4px;
    pointer-events: auto;
    z-index: 10;
}

#timelineMarkers .absolute {
    height: 8px;
}

.info-popup {
    max-width: 300px;
    background-color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.info-button:hover {
    opacity: 0.8;
}

.info-popup ul li {
    color: #4a5568;
    line-height: 1.4;
}

#setupLoadingOverlay {
    transition: opacity 0.5s ease-in-out;
    z-index: 9999;
}

.project-header svg {
    transition: transform 0.2s ease-in-out;
}

#frameNotification {
    animation: fadeInOut 0.3s ease-in-out;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(-10px); }
    100% { opacity: 1; transform: translateY(0); }
}

/* Make the container responsive */
.file-item {
    @apply min-w-0; /* Allows flex items to shrink below their minimum content size */
}

/* Allow the right side of file items to shrink */
.file-item > div:last-child {
    @apply flex-shrink min-w-0;
}

/* Make the metadata info shrink before the buttons */
.file-item .text-gray-600 {
    @apply flex-shrink;
}

/* Make buttons shrink gracefully */
.file-item button {
    @apply flex-shrink-0; /* Don't shrink buttons by default */
}

/* Add responsive padding to buttons */
.file-item button {
    @apply px-2 sm:px-3; /* Smaller padding on mobile */
}

/* Handle text overflow */
.text-overflow-ellipsis {
    @apply overflow-hidden whitespace-nowrap text-overflow-ellipsis;
}

/* Hide metadata at smaller screens */
@media (max-width: 1200px) {
    [style*="width: 70vw"] {
        width: 90vw !important;
    }
    
    .file-item .text-gray-600:not(.loading-text),  /* Duration text */
    .file-item .flex-col.items-end {               /* Annotation count and progress */
        display: none;
    }
}

/* Prevent video names from wrapping to multiple lines */
.video-name-text {
    white-space: nowrap;
}

/* Start truncating video names early to prevent layout issues */
@media (max-width: 1800px) {
    .video-name-text {
        max-width: 250px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .button-text {
        display: none;
    }
}

/* More aggressive truncation as space gets tighter */
@media (max-width: 1600px) {
    .video-name-text {
        max-width: 200px;
    }
}

/* Major space constraint - aggressive truncation before metadata disappears */
@media (max-width: 1250px) {
    .video-name-text {
        max-width: 150px;
    }
}

@media (min-width: 2000px) {
    .button-text {
        display: inline;
    }
}

/* Project Menu */
.project-menu {
    position: relative;
}

.project-menu-button {
    transition: background-color 0.2s;
}

.project-menu-content {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.5rem;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 50;
    min-width: 12rem;
}

.project-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    font-size: 0.875rem;
    color: #374151;
    transition: background-color 0.2s;
}

.project-menu-item:hover {
    background-color: #F3F4F6;
}

/* Project Sections */
.project-section {
    margin-bottom: 2rem;
}

.project-section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 1rem;
}

.project-year-section {
    margin-bottom: 1rem;
}

.project-year-title {
    font-size: 1.125rem;
    font-weight: 500;
    color: #4B5563;
    margin-bottom: 0.5rem;
}

/* Archived Projects */
.archived-project {
    opacity: 0.75;
    transition: opacity 0.2s;
}

.archived-project:hover {
    opacity: 1;
}

/* Tab System Styles */
.tab-item {
    position: relative;
    min-width: 120px;
    max-width: 200px;
    transition: all 0.2s ease;
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-item:not(.active) {
    background-color: #f3f4f6;
    color: #6b7280;
    border-bottom: 1px solid #d1d5db;
}

.tab-item:not(.active):hover {
    background-color: #e5e7eb;
    color: #374151;
}

.tab-item.active {
    background-color: #3b82f6;
    color: white;
    border-bottom: none;
    z-index: 10;
}

.tab-item img {
    filter: brightness(0) invert(0.5); /* Dark icons for inactive tabs */
}

.tab-item.active img {
    filter: brightness(0) invert(1); /* White icons for active tabs */
}

.tab-close-btn {
    margin-left: 8px;
    padding: 2px 6px;
    border-radius: 50%;
    transition: background-color 0.2s ease;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.tab-close-btn:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.tab-item.active .tab-close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.tab-content {
    display: none;
    width: 100%;
    height: 100%;
}

.tab-content.active {
    display: block;
}

.tab-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    overflow: auto;
}

/* Tab bar scrolling for many tabs */
#tabBar {
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* Internet Explorer 10+ */
}

#tabBar::-webkit-scrollbar {
    display: none; /* WebKit */
}

/* Ensure proper z-index for overlays */
#globalInfoPopup {
    z-index: 1000;
}

/* Loading overlay for iframe content */
.iframe-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.iframe-loading.hidden {
    display: none;
}

/* Animation for tab transitions */
.tab-content {
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

.tab-content:not(.active) {
    pointer-events: none;
}

.tab-content.active {
    opacity: 1;
    pointer-events: auto;
}

/* Barber pole loading animation */
.barber-pole-container {
    height: 12px;
    background-color: #f3f4f6;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
    animation: pulse 2s ease-in-out infinite;
}

.barber-pole {
    height: 100%;
    background: linear-gradient(
        45deg,
        #3b82f6 25%,
        #60a5fa 25%,
        #60a5fa 50%,
        #3b82f6 50%,
        #3b82f6 75%,
        #60a5fa 75%
    );
    background-size: 20px 20px;
    animation: barber-slide 1s linear infinite;
    width: 100%;
}

@keyframes barber-slide {
    0% {
        background-position: 0 0;
    }
    100% {
        background-position: 20px 0;
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.8;
        transform: scaleX(0.95);
    }
    50% {
        opacity: 1;
        transform: scaleX(1);
    }
}

/* Download menu styles */
.download-menu-item {
    transition: all 0.2s ease-in-out;
}

.download-menu-item:hover {
    transform: translateX(2px);
    background-color: #f9fafb;
}

.download-menu-item:active {
    transform: translateX(1px);
    background-color: #f3f4f6;
}

.download-menu-item svg {
    flex-shrink: 0;
}

/* Ensure download menu appears above all project content */
div[id^="download-menu-"] {
    z-index: 99999 !important;
    position: fixed !important;
}

/* Download button styling */
.file-item button[title="Download Files"] {
    background-color: #6b7280;
    transition: all 0.2s ease-in-out;
}

.file-item button[title="Download Files"]:hover {
    background-color: #4b5563;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.file-item button[title="Download Files"]:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Toast notification styles */
.toast-notification {
    background: linear-gradient(45deg, #ef4444, #dc2626);
    border-left: 4px solid #b91c1c;
    animation: slideInRight 0.3s ease-out;
}

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

/* Polygon drawing styles */
.polygon-instructions {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    pointer-events: none;
    user-select: none;
    transition: opacity 0.3s ease;
}

.polygon-point-label {
    background: rgba(0, 0, 0, 0.7) !important;
    color: white !important;
    border: none !important;
    border-radius: 3px !important;
    padding: 2px 6px !important;
    font-size: 11px !important;
    font-weight: bold !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.polygon-point-label:before {
    display: none !important;
}

/* Polygon button active state */
.polygon-button {
    transition: background-color 0.3s ease;
}

.polygon-button:hover {
    background-color: #f5f5f5 !important;
}

/* Custom cursor for polygon mode */
.leaflet-container.polygon-mode {
    cursor: crosshair !important;
}

/* Polygon drawing feedback */
.polygon-area-display {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

/* Quick Annotation Modal Button Number Labels */
.quick-annotation-button {
    position: relative;
}

.quick-annotation-button .keyboard-shortcut-number {
    position: absolute;
    top: 2px;
    left: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    line-height: 1;
    z-index: 1;
}

/* ============================== */
/*     DENSITY VISUALIZATION     */
/* ============================== */

/* Density Controls Styling */
.density-controls {
    background: rgba(255, 248, 220, 0.95);
    border: 1px solid #f59e0b;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.density-controls:hover {
    background: rgba(255, 248, 220, 1);
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.2);
}

/* Density Markers */
.density-marker-icon {
    z-index: 500;
}

.density-marker {
    transition: all 0.2s ease-in-out;
    border-radius: 50%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    border: 1px solid white;
    mix-blend-mode: plus-lighter;
    cursor: pointer;
}

.density-marker:hover {
    transform: scale(1.1);
    z-index: 1000;
}

/* Density Legend */
.density-legend {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    border: 1px solid rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(4px);
    min-width: 400px;
    max-width: 500px;
}

/* Ensure Leaflet control container doesn't constrain density legend width */
.leaflet-control-container .leaflet-control:has(.density-legend) {
    min-width: 420px !important;
    max-width: 520px !important;
    width: auto !important;
}

/* Fallback for browsers that don't support :has() selector */
.leaflet-control.leaflet-bar:has(.density-legend),
.leaflet-control.leaflet-bar .density-legend {
    min-width: 420px !important;
    max-width: 520px !important;
    width: auto !important;
}

/* Marker Design Modal */
#markerDesignModal {
    z-index: 50000 !important;
}

#markerDesignModal .bg-white {
    z-index: 50001 !important;
    position: relative;
}

.marker-preview {
    transition: all 0.2s ease-in-out;
}

.preset-color {
    transition: all 0.2s ease-in-out;
    cursor: pointer;
}

.preset-color:hover {
    transform: scale(1.1);
    border-color: #3b82f6 !important;
}

/* Legend header with marker */
.legend-header-with-marker {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.legend-title {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 4px 0;
    text-align: center;
}

.legend-subtitle {
    font-size: 12px;
    color: #6b7280;
    margin: 0 0 8px 0;
    text-align: center;
    font-style: italic;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.legend-scale {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin: 8px 0;
}

.legend-step {
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.8);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
    cursor: help;
}

.legend-step:hover {
    transform: scale(1.1);
}

/* Histogram styles */
.histogram-container {
    margin: 10px 0;
    padding: 5px;
}

.histogram-bars {
    height: 80px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    position: relative;
    margin-bottom: 20px;
    margin-top: 25px;
    padding: 20px 5px 0 5px;
    border-top-width: 20px;
}

.histogram-bar {
    position: relative;
    transition: all 0.2s ease-in-out;
    cursor: help;
}

.histogram-bar:hover {
    opacity: 0.8;
    transform: translateY(-2px);
}

.histogram-axis {
    font-size: 10px;
    color: #666;
    text-align: center;
    margin-top: 25px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
}

.legend-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #6b7280;
    margin-top: 8px;
}

.legend-low,
.legend-high {
    font-weight: 500;
}

.legend-info {
    text-align: center;
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.legend-info small {
    font-size: 10px;
    color: #9ca3af;
}

/* Density Popup */
.density-popup {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    min-width: 150px;
}

.density-popup h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    border-bottom: 1px solid #e5e7eb;
    padding-bottom: 4px;
}

.density-popup p {
    margin: 4px 0;
    font-size: 12px;
    color: #4b5563;
    line-height: 1.4;
}

.density-popup strong {
    color: #1f2937;
    font-weight: 600;
}

/* Density Controls Form Styling */
#densityControlsContainer {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#densitySettings {
    transition: all 0.3s ease;
}

#densitySpeciesSelect {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 16px;
    padding-right: 32px;
}

#densitySpeciesSelect:focus {
    outline: none;
    ring: 2px;
    ring-color: #3b82f6;
    border-color: #3b82f6;
}

/* Density range sliders */
input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-webkit-slider-thumb:hover {
    background: #2563eb;
    transform: scale(1.1);
}

input[type="range"]::-webkit-slider-track {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-track {
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    border: none;
}

/* Density checkbox styling */
input[type="checkbox"]:focus {
    outline: none;
    ring: 2px;
    ring-color: #3b82f6;
    ring-offset: 2px;
}

/* Density mode active indicator */
.density-mode-active {
    position: relative;
}

.density-mode-active::after {
    content: "DENSITY MODE";
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(45deg, #f59e0b, #d97706);
    color: white;
    font-size: 8px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    animation: pulse 2s infinite;
}

/* Responsive density controls */
@media (max-width: 768px) {
    .density-legend {
        max-width: 140px;
        padding: 8px;
    }
    
    .legend-title {
        font-size: 12px;
    }
    
    .legend-subtitle {
        font-size: 10px;
    }
    
    .density-controls {
        padding: 8px;
    }
    
    .density-marker {
        border-width: 1px;
    }
}

/* Density loading state */
.density-loading {
    position: relative;
    overflow: hidden;
}

.density-loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(59, 130, 246, 0.3),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Error states for density */
.density-error {
    background-color: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.density-error-message {
    background-color: #fef2f2;
    border: 1px solid #fca5a5;
    color: #dc2626;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 8px;
}

/* Success states for density */
.density-success {
    background-color: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

/* Density marker clustering effects */
.density-cluster-high {
    animation: densityPulse 2s ease-in-out infinite;
}

@keyframes densityPulse {
    0%, 100% {
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        box-shadow: 0 4px 12px rgba(59, 130, 246, 0.6), 0 0 0 4px rgba(59, 130, 246, 0.2);
    }
}