/* Product Catalog Styles */

/* Mode Toggle */
.catalog-mode-toggle {
    margin-bottom: 20px;
}

.catalog-mode-toggle .btn-group .btn {
    padding: 8px 16px;
    font-weight: 500;
}

.catalog-mode-toggle .btn.active {
    background-color: #337ab7;
    color: white;
    border-color: #337ab7;
}

/* Breadcrumb */
.catalog-breadcrumb {
    margin-bottom: 20px;
}

.catalog-breadcrumb .breadcrumb {
    background-color: #f8f8f8;
    border-radius: 4px;
    margin-bottom: 0;
}

.catalog-breadcrumb .breadcrumb > li + li:before {
    content: ">";
    color: #666;
}

.catalog-breadcrumb .breadcrumb a {
    color: #337ab7;
    text-decoration: none;
}

.catalog-breadcrumb .breadcrumb a:hover {
    color: #23527c;
}

/* Breadcrumb Dropdown for Siblings */
.breadcrumb-item.dropdown {
    position: relative;
    display: inline-block;
}

.breadcrumb-item .dropdown-toggle {
    display: inline-block;
    padding: 0 5px;
    cursor: pointer;
    color: #007bff;
    font-size: 10px;
    vertical-align: middle;
    margin-left: 5px;
}

.breadcrumb-item .dropdown-toggle:hover {
    color: #0056b3;
}

.breadcrumb-item .dropdown-menu {
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-top: 5px;
}

.breadcrumb-item .dropdown-menu li {
    list-style: none;
}

.breadcrumb-item .dropdown-menu li a {
    display: block;
    padding: 8px 15px;
    color: #495057;
    text-decoration: none;
    transition: background-color 0.2s;
}

.breadcrumb-item .dropdown-menu li a:hover {
    background-color: #f8f9fa;
    color: #007bff;
}

.breadcrumb-item .dropdown-menu li.active a {
    background-color: #337ab7;
    color: white;
    font-weight: 500;
}

.breadcrumb-item .dropdown-menu li.active a:hover {
    background-color: #286090;
    color: white;
}

/* Catalog Items Grid (unified for both browse and search) */
.catalog-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Grouped Search Sections */
.search-group {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    background: #fff;
    margin: 20px 0;
    overflow: hidden;
}

.search-group-title {
    width: 100%;
    display: block;
    background: #f5f7fb;
    color: #333;
    font-weight: 600;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
    /* Optional accent */
    position: relative;
}

.search-group-title::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #337ab7;
}

.search-group-content {
    padding: 16px;
}

.search-group .catalog-items-grid {
    margin-top: 0; /* already have padding in section */
}

.empty-group-note {
    color: #777;
    font-style: italic;
    padding: 8px 4px;
}

/* Responsive tweaks for grouped sections */
@media (max-width: 768px) {
    .search-group-title {
        font-size: 14px;
        padding: 10px 12px;
    }
    .search-group-content {
        padding: 12px;
    }
}

/* Legacy support */
.hierarchy-items-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Hierarchy Item Cards */
.hierarchy-item-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 38px 20px 20px 20px; /* increase top padding so content doesn't sit under the type badge */
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    display: flex;              /* ensure stats can stick to bottom */
    flex-direction: column;
    min-height: 160px;          /* avoid too-short cards collapsing */
}

.hierarchy-item-card:hover {
    border-color: #337ab7;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}



.hierarchy-item-card .card-type {
    position: absolute;
    top: 8px;    /* tuck it closer to the corner */
    right: 6px;  /* tuck it closer to the corner */
    font-size: 11px;
    background-color: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    color: #666;
    text-transform: uppercase;
    font-weight: 500;
    z-index: 1;
    white-space: nowrap;
}

.hierarchy-item-card .card-type.business-line {
    background-color: #337ab7;
    color: white;
}

.hierarchy-item-card .card-type.product-line {
    background-color: #5bc0de;
    color: white;
}

.hierarchy-item-card .card-type.reporting-family {
    background-color: #5cb85c;
    color: white;
}

.hierarchy-item-card .card-type.product {
    background-color: #f0ad4e;
    color: white;
}

.hierarchy-item-card .card-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.hierarchy-item-card .card-description {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 15px;
}

.hierarchy-item-card .card-regions {
    margin-bottom: 15px;
}

.hierarchy-item-card .region-badge {
    display: inline-block;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 12px;
    margin-right: 6px;
    margin-bottom: 4px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hierarchy-item-card .region-badge.region-global {
    background-color: #337ab7;
    color: white;
}

.hierarchy-item-card .region-badge.region-country {
    background-color: #5cb85c;
    color: white;
}

.hierarchy-item-card .card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    font-size: 12px;
    color: #999;
    margin-top: auto;            /* stick stats to bottom of card */
}

.hierarchy-item-card .stat-item {
    display: flex;
    align-items: center;
    gap: 3px;
}


/* Header Section */
.catalog-header {
    margin: 20px 0 30px 0;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e5e5;
}

.catalog-header h1 {
    margin-bottom: 10px;
    color: #333;
}

.catalog-header .lead {
    color: #666;
    margin-bottom: 0;
}

/* Search Section */
.catalog-search-section {
    margin-bottom: 25px;
}

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

#catalog-search {
    border-radius: 4px 0 0 4px;
}

#catalog-search:focus {
    border-color: #337ab7;
    box-shadow: 0 0 0 0.2rem rgba(51, 122, 183, 0.25);
}

/* Filter Pills */
.catalog-filters {
    margin-bottom: 30px;
    text-align: center;
}

.filter-pills {
    display: inline-block;
}

.filter-pill {
    margin: 0 5px 10px 0;
    border-radius: 20px;
    transition: all 0.2s ease;
}

.filter-pill.active {
    background-color: #337ab7;
    border-color: #337ab7;
    color: white;
}

.filter-pill:hover {
    background-color: #286090;
    border-color: #286090;
    color: white;
}

/* Results Section */
.catalog-results {
    min-height: 400px;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 10px 0;
    border-bottom: 1px solid #e5e5e5;
}

#results-count {
    font-weight: 500;
    color: #666;
}

.view-toggle .btn {
    margin-left: 5px;
}

.view-toggle .btn.active {
    background-color: #337ab7;
    border-color: #337ab7;
    color: white;
}

/* Work Package Grid */
.work-packages-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Work Package Cards */
.work-package-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    background: white;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.work-package-card:hover {
    border-color: #337ab7;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.work-package-card .card-header {
    display: flex;
    align-items: flex-start;
    margin-bottom: 15px;
}

.work-package-card .thumbnail {
    width: 60px;
    height: 60px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-right: 15px;
    flex-shrink: 0;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.work-package-card .thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.work-package-card .thumbnail.no-preview {
    background: #f0f0f0;
    color: #999;
    font-size: 10px;
    text-align: center;
}

.work-package-card .card-title {
    flex-grow: 1;
}

.work-package-card .activity-code {
    font-weight: bold;
    color: #337ab7;
    font-size: 14px;
    margin-bottom: 5px;
}

.work-package-card .title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    line-height: 1.3;
}

.work-package-card .hierarchy-path {
    font-size: 12px;
    color: #666;
    margin-bottom: 10px;
    font-style: italic;
}

.work-package-card .description {
    color: #666;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.work-package-card .keywords {
    margin-bottom: 15px;
}

.work-package-card .keyword-tag {
    display: inline-block;
    background-color: #f0f0f0;
    color: #666;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    margin: 0 5px 5px 0;
}

.work-package-card .card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #999;
    border-top: 1px solid #f0f0f0;
    padding-top: 10px;
}

.work-package-card .meta-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.work-package-card .meta-item {
    display: flex;
    align-items: center;
    gap: 3px;
}

.work-package-card .card-actions {
    position: absolute;
    top: 15px;
    right: 15px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.work-package-card:hover .card-actions {
    opacity: 1;
}

.work-package-card .btn-sm {
    padding: 4px 8px;
    font-size: 11px;
    margin-left: 5px;
}

/* List View */
.work-packages-list .work-package-card {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    margin-bottom: 10px;
}

.work-packages-list .work-package-card .card-header {
    margin-bottom: 0;
    flex-grow: 1;
}

.work-packages-list .work-package-card .thumbnail {
    width: 50px;
    height: 50px;
}

.work-packages-list .work-package-card .description {
    -webkit-line-clamp: 2;
    margin-bottom: 5px;
}

/* Preview Modal */
#previewModal .modal-lg {
    width: 80%;
    max-width: 1000px;
    height: 100vh;
}

#preview-details {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;

    /* Make details panel use full height and allow inner scrolling */
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 200px); /* constrain to viewport height */
    overflow: hidden;
}

#preview-details h5 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

#preview-info .info-row {
    margin-bottom: 15px;
    font-size: 13px;
    display: block; /* Stack label and value vertically */
}

#preview-info .info-label {
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
    display: block; /* Full width */
}

#preview-info .info-value {
    color: #333;
    display: block; /* Full width */
    word-wrap: break-word; /* Handle long text */
}

.preview-actions {
    /* Keep actions visible in short viewports */
    position: sticky;
    bottom: 0;
    background: #f8f8f8;
    z-index: 2;

    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    box-shadow: 0 -6px 10px -8px rgba(0,0,0,0.2);
}

/* Let the info area scroll independently so actions stay visible */
#preview-info {
    flex: 1 1 auto;
    overflow-y: scroll; /* always show scrollbar */
    overflow-x: hidden;
    min-height: 0; /* allow flex child to shrink */
    padding-right: 5px; /* space for scrollbar */
    scrollbar-width: thin; /* for Firefox */
    -webkit-overflow-scrolling: touch; /* for iOS */
}

/* ===== Main page modal styles (wp- prefix) ===== */
#wp-preview-details {
    background-color: #f8f8f8;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;

    /* Make details panel use full height and allow inner scrolling */
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: calc(100vh - 200px); /* constrain to viewport height */
    overflow: hidden;
}

#wp-preview-details h5 {
    margin-top: 0;
    color: #333;
    border-bottom: 1px solid #ddd;
    padding-bottom: 8px;
    margin-bottom: 15px;
}

#wp-preview-info .info-row {
    margin-bottom: 15px;
    font-size: 13px;
    display: block; /* Stack label and value vertically */
}

#wp-preview-info .info-label {
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
    display: block; /* Full width */
}

#wp-preview-info .info-value {
    color: #333;
    display: block; /* Full width */
    word-wrap: break-word; /* Handle long text */
}

.wp-preview-actions {
    /* Keep actions visible in short viewports */
    position: sticky;
    bottom: 0;
    background: #f8f8f8;
    z-index: 2;

    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    box-shadow: 0 -6px 10px -8px rgba(0,0,0,0.2);
}

/* Let the info area scroll independently so actions stay visible */
#wp-preview-info {
    flex: 1 1 auto;
    overflow-y: scroll; /* always show scrollbar */
    overflow-x: hidden;
    min-height: 0; /* allow flex child to shrink */
    padding-right: 5px; /* space for scrollbar */
    scrollbar-width: thin; /* for Firefox */
    -webkit-overflow-scrolling: touch; /* for iOS */
}

#wp-preview-thumbnails {
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Make modal body and images column use full height */
#workPackagePreviewModal .modal-body {
    height: calc(100vh - 120px);
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

/* Ensure columns inside modal body stretch to full height */
#workPackagePreviewModal .modal-body > .row {
    flex: 1;
    display: flex;
}
#workPackagePreviewModal .modal-body > .row > .col-md-4,
#workPackagePreviewModal .modal-body > .row > .col-md-8 {
    display: flex;
    flex-direction: column;
}
#wp-preview-images {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Removed - consolidated with later rule at line 624 */

.preview-thumbnail {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 15px;
    padding: 5px;
    background: white;
}

.preview-thumbnail img {
    width: 100%;
    height: auto;
    border-radius: 2px;
}

.preview-thumbnail .page-number {
    text-align: center;
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Make modal body and images column use full height */
#previewModal .modal-body {
    height: calc(100vh - 120px);
    overflow-y: hidden;
    display: flex;
    flex-direction: column;
}

/* Combined with rule at line 638 */

#preview-thumbnails {
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* Ensure columns inside modal body stretch to full height */
#previewModal .modal-body > .row {
    flex: 1;
    display: flex;
}
#previewModal .modal-body > .row > .col-md-4,
#previewModal .modal-body > .row > .col-md-8 {
    display: flex;
    flex-direction: column;
}
#preview-images {
    flex: 1;             /* right column fills remaining height */
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;   /* allow child thumbnails to show scrollbar */
}

/* Fullscreen full-size preview modal */
#fullSizePreview .modal-dialog {
    width: 100vw;
    max-width: none;
    margin: 0;
}
#fullSizePreview .modal-content {
    height: 100vh;
    border-radius: 0;
}
#fullSizePreview .modal-body {
    height: calc(100vh - 60px); /* account for header height */
}
#fullSizeContainer {
    width: 100%;
    height: 100%;
    overflow: auto;              /* scroll when zoomed */
}
#fullSizeImage {
    max-width: none;             /* no width constraint when zoomed */
    max-height: none;            /* allow full zoom */
    -webkit-user-drag: none;     /* prevent native drag */
    user-select: none;
    pointer-events: auto;
}

/* Loading States */
.loading-results {
    padding: 40px 0;
}

.loading-results img {
    margin-bottom: 15px;
}

/* Welcome Message */
#welcome-message {
    padding: 60px 0;
    color: #666;
}

#welcome-message h3 {
    color: #333;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .work-packages-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .search-container {
        max-width: 100%;
    }
    
    .filter-pills {
        text-align: left;
    }
    
    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .work-package-card .card-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .work-package-card .thumbnail {
        width: 100%;
        height: 120px;
        margin-right: 0;
        margin-bottom: 15px;
    }
    
    .work-package-card .card-actions {
        position: static;
        opacity: 1;
        margin-top: 10px;
    }
}

/* Search Highlighting */
.highlight {
    background-color: #fff3cd;
    padding: 1px 2px;
    border-radius: 2px;
}

/* Utility Classes */
.text-muted-small {
    color: #999;
    font-size: 12px;
}

.mb-0 { margin-bottom: 0 !important; }
.mt-10 { margin-top: 10px !important; }
.mb-10 { margin-bottom: 10px !important; }
