/**
 * Cell Image Analysis Software Database Widget Styles
 * 37degrees, inc. Theme Colors
 */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:ital,opsz,wght@0,6..12,200..1000;1,6..12,200..1000&display=swap');

:root {
    /* 37degrees, inc. Brand Colors from Logo */
    --37deg-bg-dark: #082540;        /* Dark blue background */
    --37deg-bg-darker: #050a14;     /* Darker blue */
    --37deg-pink: #FF7BAC;          /* Pink */
    --37deg-pink-light: #ff9bc5;   /* Lighter pink for hover */
    --37deg-pink-dark: #e55a8f;     /* Darker pink */
    --37deg-white: #ffffff;
    --37deg-gray-light: #f5f5f5;
    --37deg-gray: #e0e0e0;
    --37deg-gray-dark: #888888;
    --37deg-text: #333333;
    --37deg-text-light: #666666;
}

.cell-image-widget {
    position: relative;
    width: 100%;
    max-width: 1200px;
    margin: 20px auto;
    background: var(--37deg-white);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(10, 22, 40, 0.3);
    z-index: 1;
    font-family: 'Nunito Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.cell-image-widget-main {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Header */
.cell-image-widget-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--37deg-bg-dark);
    color: white;
    border-radius: 12px 12px 0 0;
}

.cell-image-widget-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.cell-image-widget-favicon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

.cell-image-widget-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
}

.cell-image-widget-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.cell-image-widget-minimize {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    font-weight: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.cell-image-widget-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Minimized state */
.cell-image-widget-minimized .cell-image-widget-main > *:not(.cell-image-widget-header) {
    display: none;
}

.cell-image-widget-minimized {
    max-height: fit-content;
}

/* Search Bar */
.cell-image-widget-search {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    background: var(--37deg-gray-light);
    border-bottom: 1px solid var(--37deg-gray);
}

.cell-image-widget-search-input {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid var(--37deg-gray);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.cell-image-widget-search-input:focus {
    border-color: var(--37deg-pink);
}

.cell-image-widget-search-button {
    padding: 10px 20px;
    background: var(--37deg-pink);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.cell-image-widget-search-button:hover {
    background: var(--37deg-pink-dark);
}

/* Filters - Compact Horizontal Layout */
.cell-image-widget-filters {
    padding: 12px 20px;
    background: var(--37deg-gray-light);
    border-bottom: 1px solid var(--37deg-gray);
}

.cell-image-widget-filters-inner {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.cell-image-widget-filter-select {
    padding: 6px 12px;
    border: 1px solid var(--37deg-gray);
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
    min-width: 140px;
    transition: border-color 0.2s;
}

.cell-image-widget-filter-select:focus {
    outline: none;
    border-color: var(--37deg-pink);
}

.cell-image-widget-filter-reset {
    padding: 6px 14px;
    background: white;
    border: 1px solid var(--37deg-gray);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--37deg-text);
    margin-left: auto;
}

.cell-image-widget-filter-reset:hover {
    background: var(--37deg-pink);
    border-color: var(--37deg-pink);
    color: white;
}

/* Results - Table View */
.cell-image-widget-results {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    background: white;
}

.cell-image-widget-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(10, 22, 40, 0.1);
    font-size: 13px;
}

.cell-image-widget-table thead {
    background: var(--37deg-bg-dark);
    color: white;
}

.cell-image-widget-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    vertical-align: top;
}

.popularity-header {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.2;
}

.popularity-subtitle {
    font-size: 10px;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    margin-top: 2px;
    opacity: 0.8;
}

.cell-image-widget-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--37deg-gray);
    font-size: 13px;
    color: var(--37deg-text);
}

/* Ensure popularity rank cell doesn't lose styling */
.cell-image-widget-table td:has(.popularity-rank) {
    position: relative;
}

.cell-image-widget-table tbody tr:hover {
    background: var(--37deg-gray-light);
    cursor: pointer;
}

/* Ensure popularity rank stays visible on row hover */
.cell-image-widget-table tbody tr:hover .popularity-rank {
    opacity: 1;
}

.cell-image-widget-table tbody tr:last-child td {
    border-bottom: none;
}

.cell-image-widget-table-link {
    color: var(--37deg-pink);
    text-decoration: none;
    font-weight: 500;
}

.cell-image-widget-table-link:hover {
    color: var(--37deg-pink-dark);
    text-decoration: underline;
}

.cell-image-widget-table-button {
    padding: 4px 10px;
    background: var(--37deg-pink);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.cell-image-widget-table-button:hover {
    background: var(--37deg-pink-dark);
}

.cell-image-widget-result-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.cell-image-widget-dark .cell-image-widget-result-card {
    background: #2a2a2a;
    border-color: #404040;
}

.cell-image-widget-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cell-image-widget-result-card h3 {
    margin: 0 0 10px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--37deg-primary);
}

.cell-image-widget-result-description {
    margin: 0 0 15px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cell-image-widget-dark .cell-image-widget-result-description {
    color: #b0b0b0;
}

.cell-image-widget-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 12px;
    color: #888;
}

.cell-image-widget-result-meta span {
    background: #f0f0f0;
    padding: 4px 8px;
    border-radius: 4px;
}

.cell-image-widget-dark .cell-image-widget-result-meta span {
    background: #1a1a1a;
    color: #b0b0b0;
}

.cell-image-widget-result-card a {
    color: var(--37deg-primary);
    text-decoration: none;
    font-weight: 500;
    font-size: 14px;
}

.cell-image-widget-result-card a:hover {
    text-decoration: underline;
}

.cell-image-widget-no-results,
.cell-image-widget-error {
    text-align: center;
    padding: 40px;
    color: #888;
    font-size: 16px;
}

.cell-image-widget-dark .cell-image-widget-no-results,
.cell-image-widget-dark .cell-image-widget-error {
    color: #b0b0b0;
}

/* Table responsive */
@media (max-width: 768px) {
    .cell-image-widget-table {
        font-size: 12px;
    }
    
    .cell-image-widget-table th,
    .cell-image-widget-table td {
        padding: 8px;
    }
    
    .cell-image-widget-table th:nth-child(2),
    .cell-image-widget-table td:nth-child(2) {
        max-width: 150px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}


/* Modal */
.cell-image-widget-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10003;
    padding: 20px;
}

.cell-image-widget-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    max-height: 90vh;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cell-image-widget-modal-content {
    background: white;
}

.cell-image-widget-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--37deg-bg-dark);
    color: white;
}

.cell-image-widget-modal-header h2 {
    margin: 0;
    font-size: 24px;
}

.cell-image-widget-modal-header button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
}

.cell-image-widget-modal-body {
    padding: 20px;
    overflow-y: auto;
    line-height: 1.6;
}

.cell-image-widget-modal-body p {
    margin: 15px 0;
}

.cell-image-widget-modal-body ul {
    margin: 10px 0;
    padding-left: 20px;
}

.cell-image-widget-modal-body a {
    color: var(--37deg-pink);
    text-decoration: none;
}

.cell-image-widget-modal-body a:hover {
    color: var(--37deg-pink-dark);
    text-decoration: underline;
}

.cell-image-widget-modal-link {
    display: inline-block;
    margin-top: 20px;
    padding: 12px 24px;
    background: var(--37deg-pink);
    color: white !important;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s;
    font-family: 'Nunito Sans', sans-serif;
}

.cell-image-widget-modal-link:hover {
    background: var(--37deg-pink-dark);
    text-decoration: none;
    color: white !important;
}

.cell-image-widget-modal-link:visited {
    color: white !important;
}

.cell-image-widget-modal-link:link {
    color: white !important;
}

/* Popularity Rank Color Coding */
.popularity-rank {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    color: var(--37deg-text);
    background: var(--37deg-gray-light);
    /* Ensure visibility even when parent row is hovered */
    position: relative;
    z-index: 1;
    /* Prevent text selection issues */
    user-select: none;
    /* Ensure it stays visible on all states */
    opacity: 1 !important;
    visibility: visible !important;
}

.popularity-high {
    background: #10b981 !important;
    color: white !important;
}

.popularity-medium {
    background: #f59e0b !important;
    color: white !important;
}

.popularity-low {
    background: #ef4444 !important;
    color: white !important;
}

/* Ensure rank stays visible on row hover and click */
.cell-image-widget-table tbody tr:hover .popularity-rank,
.cell-image-widget-table tbody tr:active .popularity-rank,
.cell-image-widget-table tbody tr:focus .popularity-rank {
    opacity: 1 !important;
    visibility: visible !important;
    color: inherit !important;
}

/* Prevent rank from disappearing when row is clicked */
.cell-image-widget-table tbody tr:active td .popularity-rank,
.cell-image-widget-table tbody tr:focus td .popularity-rank {
    background-color: inherit !important;
    color: inherit !important;
}

/* Ensure rank colors are preserved on all states */
.cell-image-widget-table tbody tr .popularity-rank.popularity-high,
.cell-image-widget-table tbody tr:hover .popularity-rank.popularity-high,
.cell-image-widget-table tbody tr:active .popularity-rank.popularity-high {
    background: #10b981 !important;
    color: white !important;
}

.cell-image-widget-table tbody tr .popularity-rank.popularity-medium,
.cell-image-widget-table tbody tr:hover .popularity-rank.popularity-medium,
.cell-image-widget-table tbody tr:active .popularity-rank.popularity-medium {
    background: #f59e0b !important;
    color: white !important;
}

.cell-image-widget-table tbody tr .popularity-rank.popularity-low,
.cell-image-widget-table tbody tr:hover .popularity-rank.popularity-low,
.cell-image-widget-table tbody tr:active .popularity-rank.popularity-low {
    background: #ef4444 !important;
    color: white !important;
}

/* Scrollbar styling */
.cell-image-widget-results::-webkit-scrollbar,
.cell-image-widget-modal-body::-webkit-scrollbar {
    width: 8px;
}

.cell-image-widget-results::-webkit-scrollbar-track,
.cell-image-widget-modal-body::-webkit-scrollbar-track {
    background: var(--37deg-gray-light);
}

.cell-image-widget-results::-webkit-scrollbar-thumb,
.cell-image-widget-modal-body::-webkit-scrollbar-thumb {
    background: var(--37deg-gray-dark);
    border-radius: 4px;
}

.cell-image-widget-results::-webkit-scrollbar-thumb:hover,
.cell-image-widget-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--37deg-gray);
}

/* Pagination */
.cell-image-widget-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 16px 0;
    border-top: 1px solid var(--37deg-gray);
}

.cell-image-widget-pagination-info {
    font-size: 13px;
    color: var(--37deg-text-light);
}

.cell-image-widget-pagination-controls {
    display: flex;
    gap: 6px;
    align-items: center;
}

.cell-image-widget-pagination-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid var(--37deg-gray);
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--37deg-text);
    font-family: 'Nunito Sans', sans-serif;
}

.cell-image-widget-pagination-btn:hover:not(:disabled) {
    background: var(--37deg-pink);
    border-color: var(--37deg-pink);
    color: white;
}

.cell-image-widget-pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cell-image-widget-pagination-btn.active {
    background: var(--37deg-bg-dark);
    border-color: var(--37deg-bg-dark);
    color: white;
}

.cell-image-widget-pagination-ellipsis {
    padding: 0 4px;
    color: var(--37deg-text-light);
    font-size: 13px;
}

/* Sortable header */
.sortable-header {
    user-select: none;
    transition: background 0.2s;
    color: white !important;
    background: var(--37deg-bg-dark) !important;
}

.sortable-header:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: white !important;
}

.sortable-header:active,
.sortable-header:focus,
.sortable-header:active:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
    outline: none;
}

/* Ensure thead background stays dark even when header is clicked */
.cell-image-widget-table thead {
    background: var(--37deg-bg-dark) !important;
}

.cell-image-widget-table thead th {
    background: var(--37deg-bg-dark) !important;
    color: white !important;
}

.cell-image-widget-table thead th.sortable-header:active,
.cell-image-widget-table thead th.sortable-header:focus {
    background: rgba(255, 255, 255, 0.15) !important;
    color: white !important;
}

/* Ensure popularity header content stays visible */
.sortable-header .popularity-header,
.sortable-header:active .popularity-header,
.sortable-header:focus .popularity-header,
.sortable-header:hover .popularity-header {
    color: white !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.sortable-header .popularity-header > div,
.sortable-header:active .popularity-header > div,
.sortable-header:focus .popularity-header > div {
    color: white !important;
}

/* Responsive */
@media (max-width: 768px) {
    .cell-image-widget {
        width: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    .cell-image-widget-results {
        grid-template-columns: 1fr;
    }
    
    .cell-image-widget-pagination {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .cell-image-widget-pagination-controls {
        justify-content: center;
        flex-wrap: wrap;
    }
}

