/*
 * SmartAdmin v4 Compatibility Stylesheet
 * Bridges v3-specific utility classes that are still referenced in templates
 * to work with Bootstrap 5 + SmartAdmin 5.3.8
 */

/* ============================================
   Font Weight Utilities (SmartAdmin v3)
   ============================================ */
.fw-n { font-weight: normal !important; }
.fw-100 { font-weight: 100 !important; }
.fw-200 { font-weight: 200 !important; }
.fw-300 { font-weight: 300 !important; }
.fw-400 { font-weight: 400 !important; }
.fw-500 { font-weight: 500 !important; }
.fw-600 { font-weight: 600 !important; }
.fw-700 { font-weight: 700 !important; }
.fw-800 { font-weight: 800 !important; }
.fw-900 { font-weight: 900 !important; }

/* ============================================
   Font Size Utilities (SmartAdmin v3)
   ============================================ */
.fs-nano { font-size: 0.625rem !important; }
.fs-xs { font-size: 0.6875rem !important; }
.fs-sm { font-size: 0.8125rem !important; }
.fs-md { font-size: 0.9375rem !important; }
.fs-b { font-size: 0.875rem !important; }
.fs-lg { font-size: 1.125rem !important; }
.fs-xl { font-size: 1.25rem !important; }
.fs-xxl { font-size: 1.5rem !important; }

/* ============================================
   Icon / Element Size Utilities
   ============================================ */
.size-ss { font-size: 0.625rem !important; }
.size-sm { font-size: 0.875rem !important; }
.size-md { font-size: 1.25rem !important; }
.size-lg { font-size: 1.5rem !important; }
.size-hg { font-size: 2rem !important; }
.md-48 { font-size: 48px !important; }
.md-left { margin-left: 0.5rem !important; }
.md-right { margin-right: 0.5rem !important; }

/* ============================================
   Icon Color Utilities
   ============================================ */
.icon-info-color { color: var(--bs-primary, #886ab5) !important; }
.icon-btn-color { color: inherit !important; }
.sort-icon { font-size: 0.75rem; vertical-align: middle; }

/* ============================================
   Color Utilities (SmartAdmin v3 palette)
   ============================================ */
.color-primary-50 { color: #e3f2fd !important; }
.color-primary-100 { color: #bbdefb !important; }
.color-primary-200 { color: #90caf9 !important; }
.color-primary-300 { color: #64b5f6 !important; }
.color-primary-400 { color: #42a5f5 !important; }
.color-primary-500 { color: var(--bs-primary, #886ab5) !important; }
.color-primary-600 { color: #1e88e5 !important; }
.color-primary-700 { color: #1976d2 !important; }
.color-primary-800 { color: #1565c0 !important; }
.color-primary-900 { color: #0d47a1 !important; }

.color-success-500 { color: var(--bs-success, #1dc9b7) !important; }
.color-danger-500 { color: var(--bs-danger, #fd3995) !important; }
.color-warning-500 { color: var(--bs-warning, #ffc241) !important; }
.color-info-500 { color: var(--bs-info, #2196f3) !important; }
.color-white { color: #fff !important; }

/* ============================================
   Background Utilities
   ============================================ */
.bg-faded { background-color: var(--bs-light, #f8f9fa) !important; }
.bg-trans-gradient {
    background: linear-gradient(250deg, rgba(var(--bs-primary-rgb, 136, 106, 181), 0.85), rgba(var(--bs-primary-rgb, 136, 106, 181), 0.95)) !important;
}
.bg-primary-500 { background-color: var(--bs-primary, #886ab5) !important; }
.bg-transparent { background-color: transparent !important; }

/* ============================================
   Layout Compatibility
   ============================================ */
.page-wrapper { min-height: 100vh; display: flex; flex-direction: column; }
.page-inner { display: flex; flex: 1; }
.page-content-wrapper { flex: 1; display: flex; flex-direction: column; }
.page-content { flex: 1; padding: 1rem; }

/* ============================================
   Badge / Label Utilities
   ============================================ */
.dl-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.25rem;
    padding: 0 0.375rem;
    font-size: 0.6875rem;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    border-radius: 10rem;
    background-color: var(--bs-primary, #886ab5);
}
.badge-top {
    position: relative;
    top: -0.125rem;
}

/* ============================================
   Position Utilities (SmartAdmin v3)
   ============================================ */
.pos-top { top: 0 !important; }
.pos-bottom { bottom: 0 !important; }
.pos-left { left: 0 !important; }
.pos-right { right: 0 !important; }

/* ============================================
   Width Utilities
   ============================================ */
.width-5 { width: 5rem !important; }
.width-mobile-auto { width: auto !important; }

/* ============================================
   Opacity Utilities (SmartAdmin v3)
   ============================================ */
.opacity-10 { opacity: 0.1 !important; }
.opacity-20 { opacity: 0.2 !important; }
.opacity-30 { opacity: 0.3 !important; }
.opacity-40 { opacity: 0.4 !important; }
.opacity-50 { opacity: 0.5 !important; }
.opacity-60 { opacity: 0.6 !important; }
.opacity-70 { opacity: 0.7 !important; }
.opacity-80 { opacity: 0.8 !important; }
.opacity-85 { opacity: 0.85 !important; }
.opacity-90 { opacity: 0.9 !important; }
.opacity-100 { opacity: 1 !important; }

/* ============================================
   Margin Utilities (non-standard)
   ============================================ */
.mg-right-10 { margin-right: 10px !important; }
.mg-right-15 { margin-right: 15px !important; }
.mt-15 { margin-top: 15px !important; }

/* ============================================
   Line-Height Utilities
   ============================================ */
.l-h-n { line-height: normal !important; }

/* ============================================
   Misc Compatibility
   ============================================ */
.press-scale-down { transition: transform 0.15s ease; }
.press-scale-down:active { transform: scale(0.95); }

.subheader-icon { margin-right: 0.5rem; }

.text-truncate-sm { max-width: 120px; }
.text-truncate-md { max-width: 200px; }
.text-truncate-lg { max-width: 280px; }

.nav-link-text { display: inline; }

.form-credentials {
    max-width: 420px;
    margin: 0 auto;
    padding: 2rem;
}

.form-label-group { position: relative; margin-bottom: 1rem; }
.form-label-group input { height: auto; padding: 0.75rem 1rem; }
.form-label-placeholder {
    display: block;
    font-size: 0.875rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.25rem;
}

.image { display: block; max-width: 100%; height: auto; }
.image.size-lg { max-width: 200px; }

.section-account-header { margin-bottom: 1.5rem; }
.section-account-header h1 { font-size: 1.5rem; font-weight: 600; margin: 0; }

.account-info-container { margin-top: 1rem; }

.wbox { background: var(--bs-body-bg, #fff); border-radius: var(--bs-border-radius, 0.375rem); border: 1px solid var(--bs-border-color, #dee2e6); margin-bottom: 1.5rem; }
.wbox .card-header { padding: 0.75rem 1.25rem; font-weight: 600; border-bottom: 1px solid var(--bs-border-color, #dee2e6); }
.wbox .wbox_content { padding: 1.25rem; }
.wbox .card-footer { padding: 0.75rem 1.25rem; border-top: 1px solid var(--bs-border-color, #dee2e6); }

.security-myip-icon { font-size: 1.5rem; }

/* ============================================
   Card / Panel Legacy Classes
   ============================================ */
.card-transparent { background: transparent !important; border: 0 !important; box-shadow: none !important; }

.panel-hdr { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--bs-border-color, #dee2e6); }
.panel-hdr h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.panel-container { position: relative; }
.panel-content { padding: 1.25rem; }
.panel-tag { padding: 0.75rem 1.25rem; background: var(--bs-light, #f8f9fa); border-bottom: 1px solid var(--bs-border-color, #dee2e6); font-size: 0.875rem; color: var(--bs-secondary-color, #6c757d); }

/* ============================================
   Subheader / Page Title
   ============================================ */
.subheader {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
}
.subheader h1 { font-size: 1.25rem; font-weight: 600; margin: 0; }

/* ============================================
   Custom Scroll
   ============================================ */
.custom-scroll { overflow-y: auto; max-height: 300px; }

/* ============================================
   Quick Menu / App List (legacy)
   ============================================ */
.app-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; }
.app-list-item { display: flex; flex-direction: column; align-items: center; padding: 0.75rem; text-decoration: none; color: inherit; }
.app-list-name { font-size: 0.75rem; margin-top: 0.25rem; }

/* ============================================
   Responsive Visibility (v3 fallbacks)
   ============================================ */
.noncrucial {}
@media (max-width: 767.98px) {
    .noncrucial { display: none !important; }
}

/* ============================================
   Status / Profile Image
   ============================================ */
.profile-image { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.profile-image-md { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; display: inline-block; }

.status { position: relative; display: inline-flex; }
.status-success::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bs-success, #198754);
    border: 2px solid #fff;
}

/* ============================================
   Semantic UI Search - Navbar Search
   ============================================ */

/* Search wrapper inside header */
.header-search {
    flex: 1;
    max-width: 480px;
    margin: 0 1.5rem;
}

.header-search .navbar-search {
    position: relative;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: none;
}

.navbar-search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.navbar-search-input-wrap .navbar-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--bs-secondary-color, #6c757d);
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 2;
}

.header-search .navbar-search .prompt {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.25rem;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.5rem;
    background: var(--bs-tertiary-bg, #f8f9fa);
    color: var(--bs-body-color, #212529);
    font-size: 0.875rem;
    line-height: 1.5;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out, background-color .15s ease-in-out;
    outline: none;
}

.header-search .navbar-search .prompt:focus {
    border-color: var(--bs-primary, #0d6efd);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb, 13,110,253), .15);
    background: var(--bs-body-bg, #fff);
}

.header-search .navbar-search .prompt::placeholder {
    color: var(--bs-secondary-color, #6c757d);
}

.navbar-search-loader {
    display: none;
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid var(--bs-border-color, #dee2e6);
    border-top-color: var(--bs-primary, #0d6efd);
    border-radius: 50%;
    animation: spin-loader 0.6s linear infinite;
}

.navbar-search-loader.active {
    display: block;
}

@keyframes spin-loader {
    to { transform: translateY(-50%) rotate(360deg); }
}

.search-shortcut {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.1rem 0.4rem;
    font-size: 0.7rem;
    font-family: inherit;
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-body-bg, #fff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 0.25rem;
    pointer-events: none;
    line-height: 1.4;
}

/* Semantic UI Search results dropdown */
.navbar-search .navbar-search-results {
    left: 0;
    right: 0;
    z-index: 1060;
    min-width: 100%;
    max-height: 70vh;
    overflow-y: auto;
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
    padding: 0;
    margin-top: 0;
    border-top: none;
}

.navbar-search .navbar-search-results.show {
    display: block !important;
}

/* Semantic UI category search results */
.navbar-search-results .category {
    padding: 0;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,.05));
}

.navbar-search-results .category:last-child {
    border-bottom: none;
}

.navbar-search-results .category > .results {
    padding: 0;
    margin: 0;
    list-style: none;
    display: block;
}

.navbar-search-results .category .name {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-tertiary-bg, #f8f9fa);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    margin: 0;
}

.navbar-search-results .category .result,
.navbar-search-results .result {
    display: block;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--bs-border-color-translucent, rgba(0,0,0,.05));
    cursor: pointer;
    transition: background-color .1s ease;
    text-decoration: none;
    color: var(--bs-body-color, #212529);
}

.navbar-search-results .category .result:hover,
.navbar-search-results .result:hover {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

.navbar-search-results .result .content {
    flex: 1;
    min-width: 0;
}

.navbar-search-results .result .title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bs-body-color, #212529);
    margin: 0;
}

.navbar-search-results .result .description {
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.navbar-search-results .result .price {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bs-primary, #0d6efd);
    float: right;
}

.navbar-search-results .result .image {
    width: 32px;
    height: 32px;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.navbar-search-results .result .image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0.25rem;
}

.navbar-search-results .action {
    display: block;
    padding: 0.5rem 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--bs-primary, #0d6efd);
    border-top: 1px solid var(--bs-border-color, #dee2e6);
    cursor: pointer;
    transition: background-color .1s ease;
}

.navbar-search-results .action:hover {
    background: var(--bs-tertiary-bg, #f8f9fa);
}

/* Semantic UI message (no results, errors) */
.navbar-search-results .message {
    padding: 1rem;
    text-align: center;
}

.navbar-search-results .message .header {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--bs-body-color, #212529);
    margin-bottom: 0.25rem;
}

.navbar-search-results .message .description {
    font-size: 0.8rem;
    color: var(--bs-secondary-color, #6c757d);
}

/* Overlay when search results are open */
.main-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.3);
    z-index: 1050;
}

.main-overlay.active {
    display: block;
}

/* Dark mode adjustments for search */
[data-theme="dark"] .header-search .navbar-search .prompt {
    background: var(--bs-tertiary-bg, #2b3035);
    border-color: var(--bs-border-color, #495057);
    color: var(--bs-body-color, #dee2e6);
}

[data-theme="dark"] .header-search .navbar-search .prompt:focus {
    background: var(--bs-body-bg, #212529);
}

[data-theme="dark"] .navbar-search .navbar-search-results {
    background: var(--bs-body-bg, #212529);
    border-color: var(--bs-border-color, #495057);
}

[data-theme="dark"] .navbar-search-results .category .name {
    background: var(--bs-tertiary-bg, #2b3035);
}

/* Hide search on small screens */
@media (max-width: 767.98px) {
    .header-search {
        display: none;
    }
    .header-search.mobile-visible {
        display: block;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        max-width: 100%;
        margin: 0;
        padding: 0.5rem;
        background: var(--bs-body-bg, #fff);
        border-bottom: 1px solid var(--bs-border-color, #dee2e6);
        z-index: 1059;
    }
}

/* ============================================
   Dropdown Multilevel (hover sub-menus)
   ============================================ */
.dropdown-multilevel {
    position: relative;
}

.dropdown-multilevel > .dropdown-item {
    cursor: pointer;
}

.dropdown-multilevel > .dropdown-item::after {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 0.5rem;
    vertical-align: middle;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 4px solid currentColor;
}

.dropdown-multilevel > .dropdown-menu {
    display: none;
    position: absolute;
    top: 0;
    margin: 0;
    border-radius: var(--bs-dropdown-border-radius, 0.375rem);
    box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15);
}

.dropdown-multilevel-left > .dropdown-menu {
    right: 100%;
    left: auto;
}

.dropdown-multilevel:hover > .dropdown-menu {
    display: block;
}

.dropdown-multilevel > .dropdown-item:hover,
.dropdown-multilevel:hover > .dropdown-item {
    background-color: var(--bs-dropdown-link-hover-bg, #e9ecef);
    color: var(--bs-dropdown-link-hover-color, #1e2125);
}
