/**
 * Detection Details Modal Styles
 * Professional, clean styling for modal and ag-Grid integration
 */

/* Modal Container */
.detection-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease-in-out;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.detection-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
}

.detection-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.2), 0 12px 24px rgba(0, 0, 0, 0.1);
    width: 96%;
    max-width: 1500px;
    height: 92vh;
    max-height: 950px;
    display: flex;
    flex-direction: column;
    animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
    overflow: hidden;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Modal Header */
.detection-modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    border-radius: 16px 16px 0 0;
}

.detection-modal-header h2 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-icon {
    font-size: 26px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.detection-modal-close {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 24px;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    font-weight: 300;
}

.detection-modal-close:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.detection-modal-close:active {
    transform: scale(0.95);
}

/* Toolbar */
.detection-modal-toolbar {
    padding: 20px 28px;
    background: #fafbfc;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.grid-search-input {
    padding: 11px 16px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    min-width: 320px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    font-family: inherit;
}

.grid-search-input::placeholder {
    color: #9ca3af;
}

.grid-search-input:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: white;
}

.grid-row-count {
    padding: 9px 16px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    letter-spacing: -0.2px;
}

.toolbar-btn {
    padding: 11px 20px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #374151;
    font-family: inherit;
}

.toolbar-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.toolbar-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Modal Body */
.detection-modal-body {
    flex: 1;
    padding: 0;
    overflow: hidden;
    position: relative;
    background: #fafbfc;
}

/* ag-Grid Customization - Professional Theme */
#detections-grid {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    height: 100%;
}

.ag-theme-alpine {
    --ag-header-height: 52px;
    --ag-header-foreground-color: #111827;
    --ag-header-background-color: #f9fafb;
    --ag-odd-row-background-color: #ffffff;
    --ag-row-hover-color: #f3f4f6;
    --ag-selected-row-background-color: #ede9fe;
    --ag-range-selection-border-color: #6366f1;
    --ag-border-color: #e5e7eb;
    --ag-row-border-color: #f3f4f6;
    --ag-font-size: 14px;
    --ag-borders: solid 1px;
    --ag-row-height: 68px;
    --ag-cell-horizontal-padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* Header Cells */
.ag-header-cell-label {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
    letter-spacing: -0.1px;
}

.ag-header-cell {
    padding: 0 16px;
}

/* Data Cells */
.ag-cell {
    color: #374151;
    font-size: 14px;
    line-height: 68px; /* Match row height for vertical centering */
}

.ag-cell-wrapper {
    height: 100%;
    display: flex;
    align-items: center;
}

.ag-cell-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

/* Center aligned columns */
.ag-cell.text-center .ag-cell-wrapper {
    justify-content: center;
}

.ag-cell.text-center .ag-cell-value {
    text-align: center;
}

.ag-header-cell.text-center .ag-header-cell-label {
    justify-content: center;
}

.ag-row {
    border-bottom: 1px solid #f3f4f6;
    transition: background-color 0.15s ease;
}

.ag-row:hover {
    background-color: #f9fafb !important;
}

/* Grid Thumbnail */
.grid-thumbnail {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.grid-thumbnail:hover {
    border-color: #6366f1;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}

.no-image {
    width: 40px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px dashed #d1d5db;
    font-size: 20px;
    color: #9ca3af;
}

/* Confidence Badge - Plain Text Only */
.confidence-badge {
    font-size: 14px;
    font-weight: 400;
    color: #374151;
}

/* Grid Action Button */
.grid-action-btn {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
}

.grid-action-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.grid-action-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Text Center */
.text-center {
    justify-content: center;
    text-align: center;
}

/* Modal Footer */
.detection-modal-footer {
    padding: 20px 28px;
    border-top: 1px solid #e5e7eb;
    background: #fafbfc;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 0 0 16px 16px;
}

.footer-info {
    font-size: 13px;
    color: #6b7280;
    font-weight: 500;
}

#selected-count {
    padding: 6px 14px;
    background: #f3f4f6;
    border-radius: 8px;
    font-weight: 600;
    color: #374151;
}

.btn-secondary {
    padding: 11px 24px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: #374151;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-secondary:active {
    transform: translateY(0);
    box-shadow: none;
}

/* Error State */
.grid-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #dc2626;
    gap: 12px;
    padding: 40px;
}

.error-icon {
    font-size: 56px;
    opacity: 0.8;
}

.grid-error p {
    font-size: 16px;
    font-weight: 500;
    margin: 0;
    color: #374151;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .detection-modal-content {
        width: 98%;
        height: 95vh;
    }
    
    .detection-modal-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .toolbar-left,
    .toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .grid-search-input {
        min-width: auto;
        flex: 1;
    }
}

@media (max-width: 768px) {
    .detection-modal-header h2 {
        font-size: 18px;
    }
    
    .modal-icon {
        font-size: 22px;
    }
    
    .toolbar-btn {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    .detection-modal-footer {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
}

/* Additional Grid Styling for Professional Look */
.ag-theme-alpine .ag-cell-wrapper {
    width: 100%;
    height: 100%;
}

.ag-theme-alpine .ag-cell-label-container {
    overflow: hidden;
}

/* Remove hover overflow - causes layout issues */
.ag-cell[col-id="species"],
.ag-cell[col-id="behavior"],
.ag-cell[col-id="moonPhase"] {
    overflow: hidden;
}

/* Better spacing for filter inputs */
.ag-theme-alpine .ag-floating-filter-input {
    font-size: 13px;
    padding: 6px 10px;
}

.ag-theme-alpine .ag-input-field-input {
    font-size: 13px;
}

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

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
