/* STM Image Taxonomy Custom Styles */

:root {
    /* STM Brand Colors */
    --stm-dark-purple: #8F50E2;
    --stm-light-purple: #A973FF;
    --stm-midnight-blue: #221533;
    --stm-light-blue: #5AC4FE;
    --stm-red-orange: #CD4813;
    --stm-yellow: #FFC801;

    /* Override Bootstrap defaults with STM colors */
    --primary-color: #8F50E2;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --info-color: #0dcaf0;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #212529;
}

/* Global Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
}

/* Navigation Improvements */
.navbar-brand {
    font-weight: 600;
    font-size: 1.25rem;
}

.navbar-nav .nav-link {
    font-weight: 500;
}

/* STM Navbar Styling */
.navbar.stm-navbar {
    background-color: var(--stm-midnight-blue) !important;
}

.stm-navbar .navbar-brand img {
    height: 32px;
    width: auto;
    margin-right: 0.5rem;
}

/* STM Primary Button Styling */
.btn-primary {
    background-color: var(--stm-dark-purple);
    border-color: var(--stm-dark-purple);
    color: #ffffff;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--stm-light-purple);
    border-color: var(--stm-light-purple);
    color: #ffffff;
}

.btn-primary:active {
    background-color: var(--stm-light-purple);
    border-color: var(--stm-light-purple);
}

/* STM Search Button in Navbar */
.stm-navbar .btn-search {
    background-color: var(--stm-dark-purple);
    border-color: var(--stm-dark-purple);
    color: #ffffff;
}

.stm-navbar .btn-search:hover,
.stm-navbar .btn-search:focus {
    background-color: var(--stm-light-purple);
    border-color: var(--stm-light-purple);
    color: #ffffff;
}

/* STM Stat Numbers Styling */
.stat-number {
    color: var(--stm-dark-purple) !important;
    font-weight: 600;
}

.stat-label {
    font-weight: 600;
}

/* STM Breadcrumb Styling */
.breadcrumb-item a {
    color: var(--stm-light-blue);
    text-decoration: none;
}

.breadcrumb-item a:hover,
.breadcrumb-item a:focus {
    color: var(--stm-dark-purple);
    text-decoration: underline;
}

.breadcrumb-item.active {
    color: var(--stm-midnight-blue);
    font-weight: 600;
}

/* Category Card Enhancement */
.category-card {
    background-color: #fafbfc;
}

/* Override Bootstrap text-primary to use STM purple */
.text-primary {
    color: var(--stm-dark-purple) !important;
}

/* Override Bootstrap text-info to use STM purple for consistency */
.text-info {
    color: var(--stm-dark-purple) !important;
}

/* Search Form in Navbar */
.navbar .input-group {
    min-width: 250px;
}

@media (max-width: 767px) {
    .navbar .input-group {
        min-width: 200px;
        margin-top: 0.5rem;
    }
}

/* Card Link Wrapper - Makes entire card clickable */
.card-link-wrapper {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-link-wrapper:hover,
.card-link-wrapper:focus {
    text-decoration: none;
    color: inherit;
}

/* Card Enhancements */
.category-card,
.subcategory-card,
.search-result-card {
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border: 1px solid rgba(0, 0, 0, 0.125);
    cursor: pointer;
}

.card-link-wrapper:hover .category-card,
.card-link-wrapper:hover .subcategory-card,
.card-link-wrapper:hover .search-result-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Keep old hover selectors for backwards compatibility */
.category-card:hover,
.subcategory-card:hover,
.search-result-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Jumbotron Styling */
.jumbotron {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
}

/* Breadcrumb Improvements */
.breadcrumb {
    background-color: transparent;
    padding: 0.5rem 0;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    font-weight: bold;
}

.breadcrumb-sm {
    font-size: 0.875rem;
}

/* Statistics Display */
.stat-item h3,
.stat-item h5 {
    margin-bottom: 0.25rem;
    font-weight: 600;
}

/* Search Highlighting */
mark {
    background-color: #fff3cd;
    padding: 0.1em 0.2em;
    border-radius: 0.2em;
    font-weight: 500;
}

/* Level Badges */
.badge {
    font-weight: 500;
}

/* Button Enhancements */
.btn {
    font-weight: 500;
    transition: all 0.2s ease-in-out;
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Button spans inside clickable cards - prevent pointer events since card is clickable */
.card-link-wrapper .btn {
    pointer-events: none;
}

/* Footer Styling */
footer {
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

footer h6 {
    color: var(--dark-color);
    font-weight: 600;
}

footer a {
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Form Enhancements */
.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

/* Toast Container */
#toast-container {
    z-index: 9999;
}

/* Category Icons */
.bi-folder,
.bi-folder2,
.bi-file-earmark {
    margin-right: 0.5rem;
}

/* Responsive Images */
img {
    max-width: 100%;
    height: auto;
}

/* Print Styles */
@media print {
    .navbar,
    .btn,
    #toast-container,
    .modal {
        display: none !important;
    }

    .card {
        border: 1px solid #000;
        break-inside: avoid;
    }

    .breadcrumb {
        margin-bottom: 1rem;
    }

    body {
        font-size: 12pt;
        line-height: 1.4;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    :root:not(.theme-light) .jumbotron {
        background: linear-gradient(135deg, #343a40 0%, #495057 100%);
        color: white;
    }

    :root:not(.theme-light) .card {
        background-color: #2d3748;
        border-color: #4a5568;
        color: white;
    }

    :root:not(.theme-light) .bg-light {
        background-color: #2d3748 !important;
        color: white;
    }

    :root:not(.theme-light) .text-muted {
        color: #a0aec0 !important;
    }

    :root:not(.theme-light) footer h6 {
        color: #e2e8f0 !important;
    }
}

/* Manual Dark Mode Override */
.theme-dark .jumbotron {
    background: linear-gradient(135deg, #343a40 0%, #495057 100%);
    color: white;
}

.theme-dark .card {
    background-color: #2d3748;
    border-color: #4a5568;
    color: white;
}

.theme-dark .bg-light {
    background-color: #2d3748 !important;
    color: white;
}

.theme-dark .text-muted {
    color: #a0aec0 !important;
}

.theme-dark footer h6 {
    color: #e2e8f0 !important;
}

/* Manual Light Mode Override */
.theme-light .jumbotron {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    color: inherit;
}

.theme-light .card {
    background-color: white;
    border-color: rgba(0, 0, 0, 0.125);
    color: inherit;
}

.theme-light .bg-light {
    background-color: #f8f9fa !important;
    color: inherit;
}

.theme-light .text-muted {
    color: #495057 !important;
}

/* Accessibility - Color Contrast Improvements */
.text-muted {
    color: #495057 !important;
}

.text-muted.small {
    color: #495057 !important;
}

/* Navigation links should be white on dark navbar */
.navbar-dark .nav-link {
    color: #ffffff !important;
}

.navbar-dark .nav-link:hover,
.navbar-dark .nav-link:focus {
    color: rgba(255, 255, 255, 0.75) !important;
}

/* Regular nav links (not in navbar) need dark color for contrast */
.nav-link:not(.navbar-dark .nav-link) {
    color: #212529 !important;
}

.nav-link:not(.navbar-dark .nav-link):hover,
.nav-link:not(.navbar-dark .nav-link):focus {
    color: #0d6efd !important;
}

a.text-muted {
    color: #495057 !important;
}

a.text-muted:hover,
a.text-muted:focus {
    color: #212529 !important;
}

/* Accessibility Enhancements */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--primary-color);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}

/* Focus Indicators */
.btn:focus,
.form-control:focus,
.nav-link:focus,
.breadcrumb-item a:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.card-link-wrapper:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 4px;
    border-radius: 0.375rem;
}

.card-link-wrapper:focus .category-card,
.card-link-wrapper:focus .subcategory-card,
.card-link-wrapper:focus .search-result-card {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .card {
        border: 2px solid #000;
    }

    .btn {
        border: 2px solid currentColor;
    }

    mark {
        background-color: #ffff00;
        color: #000;
    }
}

/* Animation for Page Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

/* API Modal Enhancements */
.modal-body code {
    background-color: #f8f9fa;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    word-break: break-all;
}

/* Responsive Typography */
@media (max-width: 768px) {
    .display-4 {
        font-size: 2rem;
    }

    .display-5 {
        font-size: 1.75rem;
    }

    .display-6 {
        font-size: 1.5rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }
}

/* Utility Classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Status Indicators */
.status-online {
    color: var(--success-color);
}

.status-offline {
    color: var(--danger-color);
}

/* Loading Spinner */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* Image Thumbnail Styles */
.example-images-container {
    margin: 1rem 0;
}

.thumbnail-wrapper {
    position: relative;
    display: inline-block;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.thumbnail-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.example-thumbnail {
    border-radius: 8px;
    border: 2px solid #dee2e6;
    transition: border-color 0.2s ease-in-out;
    display: block;
}

.example-thumbnail:hover {
    border-color: var(--primary-color);
}

.thumbnail-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    border-radius: 6px;
}

.thumbnail-wrapper:hover .thumbnail-overlay {
    opacity: 1;
}

.thumbnail-overlay i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.thumbnail-overlay small {
    font-size: 0.75rem;
    text-align: center;
}

/* Image Modal Enhancements */
.modal-dialog.modal-lg {
    max-width: 900px;
}

#modalImage {
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

#imageLoadingSpinner {
    padding: 3rem 0;
}

#imageLoadingSpinner .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .example-thumbnail {
        max-width: 120px !important;
    }

    .modal-dialog.modal-lg {
        max-width: 95vw;
        margin: 1rem;
    }

    #modalImage {
        max-height: 60vh !important;
    }
}

@media (max-width: 576px) {
    .example-thumbnail {
        max-width: 100px !important;
    }

    .thumbnail-overlay small {
        font-size: 0.65rem;
    }
}