/* Prevent Bootstrap from shifting page layout when a modal opens.
   Bootstrap 5 injects padding-right inline on <body>, .sticky-top, .fixed-top,
   and .fixed-bottom elements to compensate for the scrollbar disappearing.
   scrollbar-gutter:stable makes the browser always reserve scrollbar space,
   so Bootstrap measures 0px compensation and injects nothing.
   The !important rules below are a fallback for browsers that don't support
   scrollbar-gutter yet. */
html {
    scrollbar-gutter: stable;
}

/* When the product details overlay is open, the page behind it can't scroll.
   Hide the html scrollbar gutter so only the overlay's own scrollbar is visible. */
html:has(#product-details-overlay) {
    overflow: hidden;
}

body.modal-open {
    padding-right: 0 !important;
    overflow: hidden;
}

.modal-open .sticky-top,
.modal-open .fixed-top,
.modal-open .fixed-bottom {
    padding-right: 0 !important;
}

/* Product Details Overlay */
.product-details-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    z-index: 1040;
    overflow-y: auto;
}

:root {
    /* Theme: Blue, Gray, White (Professional Medical/Tech) */
    --primary-color: #0056b3; /* Deep Professional Blue */
    --primary-light: #e6f0ff;
    --secondary-color: #6c757d; /* Neutral Gray */
    --accent-color: #0dcaf0; /* Cyan for digital highlights */
    --light-bg: #f4f6f9;
    --dark-text: #2c3e50;
    --border-color: #e9ecef;
}

html {
    font-family: Inter, sans-serif, "Khmer OS Battambang", Battambang !important;
    -webkit-text-size-adjust: 100% !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    font-feature-settings: normal !important;
    font-variation-settings: normal !important;
    -moz-tab-size: 4 !important;
    -o-tab-size: 4 !important;
    tab-size: 1 !important;
    -webkit-tap-highlight-color: transparent !important;
    font-size: 14px !important;
}

body, p, span, div, a, li, td, th, label {
    font-family: Inter, sans-serif, "Khmer OS Battambang", Battambang;
}

body {
    font-family: Inter, sans-serif, "Khmer OS Battambang", Battambang !important;
    font-size: 14px !important;
    margin: 0 !important;
    padding: 0 !important;
    color: #000 !important;
    background-color: #fff;
    position: relative;
    height: auto !important;
    min-height: 100% !important;
    box-sizing: border-box !important;
    -webkit-font-smoothing: inherit;
    --bs-btn-font-size: 0.9125rem;
    display: flex;
    flex-direction: column;
}

/* Main Content Area - ensures footer stays at bottom during loading */
#app-content {
    min-height: calc(100vh - 60px); /* viewport minus navbar */
}

h1, h2, h3, h4, h5, h6,
.btn,
.form-control,
.form-select,
input,
textarea,
select {
    font-family: Inter, sans-serif, "Khmer OS Battambang", Battambang;
}

/* Navigation */
.navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,0.07);
    padding: 1rem 0;
}

.navbar-brand {
    font-weight: 700;
    color: var(--primary-color) !important;
    font-size: 1.2rem;
    letter-spacing: -0.5px;
}

.nav-link {
    font-weight: 600;
    color: var(--dark-text);
    margin: 0 5px;
    padding: 0.5rem 1rem;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    font-size: 1.05rem;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

.nav-link.active {
    color: var(--primary-color) !important;
    font-weight: 600;
}

/* Underline for regular nav links (not dropdowns) */
.nav-link.active:not(.dropdown-toggle)::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, #0d6efd, #0dcaf0);
    border-radius: 2px;
}

.link-hover:hover,
.link-hover a:hover {
    color: var(--accent-color) !important;
}

/* Underline for dropdown toggle - use ::before to avoid conflict with Bootstrap's ::after */
.dropdown-toggle.active::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    height: 3px;
    background: linear-gradient(90deg, #0d6efd, #0dcaf0);
    border-radius: 2px;
    z-index: 1;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #004494;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
    padding: 130px 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.hero-content h1 {
    font-weight: 800;
    color: var(--dark-text);
    margin-bottom: 1.5rem;
}

.hero-badges i {
    color: var(--primary-color);
}

/* Product Cards */
.product-card {
    transition: all 0.3s ease;
    height: 100%;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 12px;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    border-color: var(--primary-light);
    background-color: #ffffff;
}

.product-img-wrapper {
    height: 200px;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-img {
    transform: scale(1.05);
}

/* Tooth Chart for Lab Form */
.tooth-chart-container {
    background: white;
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.02);
}

.tooth-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}

.tooth-checkbox {
    display: none;
}

.tooth-label {
    width: 42px;
    height: 42px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    color: var(--secondary-color);
    background: #f8f9fa;
    transition: all 0.2s;
    user-select: none;
}

.tooth-checkbox:checked + .tooth-label {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 5px rgba(0,86,179,0.3);
}

/* Tech Section */
.tech-card {
    padding: 2rem;
    border-radius: 12px;
    background: white;
    border: 1px solid var(--border-color);
    height: 100%;
    transition: all 0.3s ease;
}

.tech-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

/* Order card with prominent styling */
.order-card {
    position: relative;
}

.order-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 40px rgba(13, 110, 253, 0.2);
    border-color: rgba(13, 110, 253, 0.25);
}

.tech-icon {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

.white-icon {
  color: white;
}

/* Filter buttons */
.btn-filter {
    padding: 0.5rem 1rem;
    font-size: 0.98rem;
    font-weight: 600;
    border: 2px solid #dee2e6;
    background: white;
    color: var(--dark-text);
    transition: all 0.3s ease;
    white-space: nowrap;
    border-radius: 0.375rem;
}

.btn-filter:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-light);
}

.btn-filter.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Navigation buttons (Back / More) */
.btn-filter-nav {
    border-style: dashed;
    color: var(--secondary-color);
    font-weight: 600;
}

.btn-filter-nav:hover {
    border-style: solid;
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--primary-light);
}

/* Filter tabs wrapper - flex layout with wrap */
.filter-tabs-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

/* Mobile dropdown filter */
.mobile-filter-dropdown {
    width: 100%;
}

.mobile-filter-dropdown .form-select {
    font-weight: 600;
    padding: 0.5rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 0.375rem;
    background-color: white;
    font-size: 0.875rem;
}

.mobile-filter-dropdown .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 179, 0.1);
}

/* Desktop filter tabs */
.desktop-filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    width: 100%;
}

/* Page indicator */
.filter-page-indicator {
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary-color);
    user-select: none;
}

/* Search box styling */
.search-box-wrapper {
    min-width: 300px;
}

.search-box-wrapper .input-group {
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    overflow: hidden;
    transition: all 0.3s ease;
}

.search-box-wrapper .input-group:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(0, 86, 179, 0.1);
}

.search-box-wrapper .form-control {
    border: none;
    box-shadow: none;
}

.search-box-wrapper .form-control:focus {
    border: none;
    box-shadow: none;
}

.search-box-wrapper .input-group-text {
    border: none;
}

.search-box-wrapper .btn-link {
    padding: 0.375rem 0.75rem;
    text-decoration: none;
    border: none;
    background: transparent;
}

.search-box-wrapper .btn-link:hover {
    color: var(--primary-color) !important;
}

/* Cart Floating Button */
.cart-float {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid #ffffff;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 20px rgba(0, 86, 179, 0.4);
    cursor: pointer;
    z-index: 1050;
    transition: transform 0.2s;
}

.cart-float:hover {
    transform: scale(1.1);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 12px;
    padding: 0.35em 0.65em;
    background-color: #dc3545;
    border: 2px solid white;
}

/* Cart button specific styles */
#nav-cart-btn.btn-outline-primary:hover {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

#nav-cart-btn.btn-primary {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

#nav-cart-btn.btn-primary:hover {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
}

#nav-cart-btn.btn-outline-primary:hover #nav-cart-count {
    background-color: white !important;
    color: #0d6efd !important;
}

/* Account button specific styles */
#nav-account-btn.btn-outline-primary:hover {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    color: white !important;
}

#nav-account-btn.btn-primary {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

#nav-account-btn.btn-primary:hover {
    background-color: #0056b3 !important;
    border-color: #0056b3 !important;
}

/* Button disabled states */
.btn-primary:disabled {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
    opacity: 1;
    cursor: not-allowed;
}

.btn-primary:disabled:hover {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

/* Auth Pages Styling */
.auth-container {
    min-height: calc(100vh - 200px);
    display: flex;
    align-items: center;
}

.auth-card {
    border-radius: 16px;
    overflow: hidden;
}

.auth-icon-wrapper i {
    opacity: 0.9;
}

.input-group-text {
    background-color: #f8f9fa;
}

.cursor-pointer {
    cursor: pointer;
}

.divider {
    position: relative;
    text-align: center;
    border-top: 1px solid #dee2e6;
}

.divider-text {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 0 15px;
    color: var(--secondary-color);
    font-size: 0.875rem;
}

.social-login .btn {
    font-weight: 600;
}

.password-strength .progress {
    border-radius: 3px;
}

.password-strength .progress-bar {
    transition: width 0.3s, background-color 0.3s;
}

/* Login Tabs Styling */
#loginTabs .nav-link {
    color: var(--secondary-color);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-weight: 500;
    transition: all 0.2s;
}

#loginTabs .nav-link:hover:not(.active) {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

#loginTabs .nav-link.active {
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* Remove underline from login tabs */
#loginTabs .nav-link.active::after,
#loginTabs .nav-link.active::before {
    display: none !important;
    content: none !important;
}

/* OTP Input Styling */
.otp-input {
    width: 40px !important;
    height: 45px !important;
    font-size: 1.25rem !important;
    font-weight: 600;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    transition: all 0.2s;
    padding: 0 !important;
}

.otp-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* OTP Verify Card in Registration */
.otp-verify-card {
    border: 1px solid #dee2e6;
}

.otp-verify-card .otp-input {
    width: 38px !important;
    height: 42px !important;
    font-size: 1.1rem !important;
}

@media (max-width: 400px) {
    .otp-input {
        width: 35px !important;
        height: 40px !important;
        font-size: 1rem !important;
    }
}

/* Phone Input Group */
.input-group .input-group-text img {
    vertical-align: middle;
}

/* Profile Page Styling */
.profile-container {
    background-color: var(--light-bg);
}

.list-group-item {
    transition: all 0.18s ease;
    border-radius: 8px;
}

/* Hover and keyboard focus should highlight the full row with a white background and subtle shadow
   Use :focus-within so child inputs/buttons still trigger the highlight when focused/hovered */
.list-group-item:hover:not(.active),
.list-group-item:focus-within:not(.active) {
    background-color: #ffffff; /* use white for hover as requested */
    color: var(--dark-text);
    box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

/* Keep active state as primary color */
.list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Make small inline buttons within list items visible on hover/focus */
.list-group-item .btn-link {
    transition: background-color 0.15s ease, color 0.15s ease;
    border-radius: 6px;
}
.list-group-item .btn-link:hover, .list-group-item .btn-link:focus {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Responsive Auth Pages */
@media (max-width: 768px) {
    .auth-card .card-body {
        padding: 2rem !important;
    }
}

@media (max-width: 576px) {
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card .card-body {
        padding: 1.5rem !important;
    }
    
    .auth-icon-wrapper i {
        font-size: 3rem !important;
    }
}

/* Footer */
footer {
    margin-top: auto;
    background-color: var(--primary-color);
    color: white;
    padding: 80px 0 30px;
}

footer h5 {
    color: white;
    margin-bottom: 25px;
    font-weight: 700;
}

footer a {
    color: #a0aec0;
    transition: color 0.2s;
}

footer a:hover {
    color: white;
}

/* Fade Animation for Router */
.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* QR Payment Modal Styling */
.qr-code-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.qr-frame {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#qrPaymentModal .modal-content {
    border: none;
    border-radius: 16px;
    overflow: hidden;
}

#qrPaymentModal .modal-header {
    padding: 1.5rem;
}

#qrPaymentModal .modal-body {
    padding: 2rem 1.5rem;
}

#qrPaymentModal .modal-footer {
    padding: 1rem 1.5rem 1.5rem;
    background: #f8f9fa;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .hero-section {
        padding: 60px 0;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .btn-filter {
        font-size: 0.75rem;
        padding: 0.4rem 0.8rem;
    }
    
    .cart-float {
        width: 50px;
        height: 50px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }
    
    .search-box-wrapper {
        min-width: 100%;
        width: 100%;
        order: 3; /* Move search below on mobile */
    }
    
    /* Ensure filter dropdown is full width on mobile */
    .mobile-filter-dropdown {
        order: 2;
    }
    
    /* Adjust product page header for mobile */
    .filter-tabs-wrapper {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .navbar-brand {
        font-size: 1.2rem;
    }
    
    .hero-badges {
        flex-direction: column;
        gap: 1rem !important;
    }
    
    .btn-filter {
        font-size: 0.7rem;
        padding: 0.35rem 0.7rem;
    }
    
    .search-box-wrapper {
        min-width: 100%;
        width: 100%;
    }
    
    .mobile-filter-dropdown .form-select {
        font-size: 0.8rem;
    }
}

/* Jobs/Careers Page Styles */
.hover-shadow {
    transition: all 0.3s ease;
}

.hover-shadow:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.transition {
    transition: all 0.3s ease;
}

/* ==========================================
   SKELETON LOADING STYLES
   ========================================== */

/* Base skeleton element */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite ease-in-out;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Skeleton card */
.skeleton-card {
    overflow: hidden;
}

/* Skeleton image placeholder */
.skeleton-img {
    background: linear-gradient(90deg, #e9ecef 25%, #dee2e6 50%, #e9ecef 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite ease-in-out;
}

/* Skeleton title */
.skeleton-title {
    border-radius: 6px;
}

/* Skeleton text */
.skeleton-text {
    border-radius: 4px;
}

/* Skeleton badge */
.skeleton-badge {
    border-radius: 20px;
}

/* Skeleton button */
.skeleton-btn {
    border-radius: 6px;
}

/* Skeleton avatar */
.skeleton-avatar {
    border-radius: 50%;
}

/* Skeleton spinner */
.skeleton-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f0f0f0;
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: skeleton-spin 1s linear infinite;
}

@keyframes skeleton-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Skeleton hero section */
.skeleton-hero {
    background: linear-gradient(135deg, #ffffff 0%, #f0f7ff 100%);
}

/* Skeleton fade in animation */
.skeleton-fade-out {
    animation: skeletonFadeOut 0.3s ease forwards;
}

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

/* ==========================================
   LAZY LOADING STYLES
   ========================================== */

/* Lazy image placeholder - show immediately, fade when loaded */
.lazy-img {
    background-color: #f0f0f0;
    transition: opacity 0.3s ease;
}

.lazy-img.lazy-loaded {
    opacity: 1;
}

/* Blur effect for lazy loading */
.lazy-blur {
    filter: blur(10px);
    transition: filter 0.3s ease;
}

.lazy-blur.lazy-loaded {
    filter: blur(0);
}

/* Image loading placeholder */
.img-placeholder {
    position: relative;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite ease-in-out;
    overflow: hidden;
}

.img-placeholder::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.5), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Page transition loading */
.page-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.page-loading.active {
    opacity: 1;
    pointer-events: auto;
}

/* Progress bar for page loading */
.page-loading-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    z-index: 10000;
    transition: width 0.3s ease;
}

.page-loading-bar.active {
    animation: loadingProgress 1.5s ease-in-out forwards;
}

@keyframes loadingProgress {
    0% {
        width: 0;
    }
    20% {
        width: 30%;
    }
    50% {
        width: 60%;
    }
    80% {
        width: 85%;
    }
    100% {
        width: 100%;
    }
}

/* Smooth content transitions */
.content-fade-in {
    opacity: 0;
    transform: translateY(10px);
    animation: contentFadeIn 0.4s ease forwards;
}

@keyframes contentFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Staggered animation for grid items */
.stagger-item {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-item.visible {
    animation: staggerFadeIn 0.5s ease forwards;
}

@keyframes staggerFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive skeleton adjustments */
@media (max-width: 768px) {
    .skeleton-spinner {
        width: 40px;
        height: 40px;
    }
}