/* 
 * MediSale Medical eCommerce - Main Stylesheet
 * Theme: Medical Professional (White, Light Blue, Teal)
 */

:root {
    --primary: #00838f;
    --primary-dark: #006064;
    --primary-light: #4fb3bf;
    --secondary: #e1f5fe;
    --accent: #26c6da;
    --success: #4caf50;
    --warning: #ff9800;
    --danger: #f44336;
    --dark: #263238;
    --light: #eceff1;
    --white: #ffffff;
    --text: #37474f;
    --text-muted: #78909c;
    --font-primary: 'Poppins', sans-serif;
    --font-secondary: 'Montserrat', sans-serif;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius: 8px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-primary);
    color: var(--text);
    background-color: var(--light);
    line-height: 1.6;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    max-width: 100%;
}

html {
    overflow-x: hidden;
    max-width: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-secondary);
    font-weight: 600;
    text-align: center;
    /* Generally center headers on mobile? Safer to just rely on specific overrides */
    overflow-wrap: break-word;
    /* Prevent long words from breaking layout */
}

/* Force center headers only on small screens via media query later if needed, but for now stick to body overflow fix */

a {
    color: var(--primary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

.bg-primary {
    background-color: var(--primary) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    border-color: var(--primary);
}

/* Top Bar */
.top-bar {
    font-size: 0.85rem;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    letter-spacing: 0.3px;
    font-weight: 500;
}

.fs-xs {
    font-size: 0.75rem;
}

.cursor-pointer {
    cursor: pointer;
}

.hover-opacity-100:hover {
    opacity: 1 !important;
}

/* Navbar */
.navbar {
    padding: 12px 0;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.98) !important;
    backdrop-filter: blur(10px);
}

/* Brand Logo */
.brand-logo {
    height: 42px;
    width: auto;
    flex-shrink: 0;
}

/* Brand Name */
.brand-name {
    font-family: var(--font-secondary);
    font-size: 1.2rem;
    letter-spacing: -0.3px;
    white-space: nowrap;
}

/* Brand Slogan */
.brand-slogan {
    font-size: 0.72rem;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

.nav-link {
    font-weight: 500;
    font-family: var(--font-secondary);
    color: var(--dark) !important;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    transition: all 0.2s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary) !important;
}

.nav-link.active {
    font-weight: 600;
}

/* Navbar Actions */
.search-trigger,
.position-relative {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hover-bg-light:hover {
    background-color: var(--secondary);
    color: var(--primary) !important;
}

.avatar-circle-sm {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* Hamburger Icon */
.hamburger-icon {
    width: 24px;
    height: 20px;
    position: relative;
    transform: rotate(0deg);
    transition: .5s ease-in-out;
    cursor: pointer;
}

.hamburger-icon span {
    display: block;
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--dark);
    border-radius: 2px;
    opacity: 1;
    left: 0;
    transform: rotate(0deg);
    transition: .25s ease-in-out;
}

.hamburger-icon span:nth-child(1) {
    top: 0px;
}

.hamburger-icon span:nth-child(2) {
    top: 9px;
}

.hamburger-icon span:nth-child(3) {
    top: 18px;
}

/* Offcanvas Premium */
.offcanvas {
    border: none;
    box-shadow: var(--shadow-lg);
}

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
}

.btn-close-white {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.btn-close-white:hover {
    opacity: 1;
}

/* Animate Slide Up for Dropdown */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-slide-up {
    animation: slideUp 0.3s ease forwards;
}

/* Hero Section */
.hero-section {
    background: linear-gradient(135deg, var(--secondary) 0%, var(--white) 100%);
    padding: 80px 0;
    position: relative;
    overflow: hidden;
    /* CRITICAL: Clips the decorative blob that sticks out to the right */
}

.hero-section .container {
    position: relative;
    z-index: 1;
}

.hero-section::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 60%;
    height: 200%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--primary) 100%);
    opacity: 0.1;
    border-radius: 50%;
    transform: rotate(-15deg);
}

.hero-title {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--dark);
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-muted);
}

/* Features Section */
.feature-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 30px 20px;
    text-align: center;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.feature-icon {
    width: 70px;
    height: 70px;
    background: var(--secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 1.8rem;
    color: var(--primary);
}

/* Product Cards */
/* Product Cards */
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.product-image {
    height: 200px;
    overflow: hidden;
    background: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    border-bottom: 1px solid var(--light);
}

.product-image img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: var(--transition);
}

.product-card:hover .product-image img {
    transform: scale(1.05);
}

.product-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--dark);
    line-height: 1.4;
}

.product-title a {
    color: var(--dark);
}

.product-title a:hover {
    color: var(--primary);
}

.product-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

.product-price .original {
    text-decoration: line-through;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 400;
    margin-right: 8px;
}

/* Product Description on Detail Page */
.product-description {
    font-size: 0.95rem;
    line-height: 1.8;
    color: var(--text);
}

.product-description p {
    margin-bottom: 12px;
}

.product-description p:last-child {
    margin-bottom: 0;
}

.product-brand {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stock-badge {
    font-size: 0.75rem;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 500;
}

.stock-in {
    background: rgba(76, 175, 80, 0.1);
    color: var(--success);
}

.stock-out {
    background: rgba(244, 67, 54, 0.1);
    color: var(--danger);
}

/* Buttons */
.btn {
    border-radius: var(--radius);
    font-weight: 500;
    padding: 0.5rem 1.25rem;
    transition: var(--transition);
}

.btn-add-cart {
    width: 100%;
    margin-top: auto;
}

/* Section Titles */
.section-title {
    position: relative;
    margin-bottom: 40px;
    padding-bottom: 15px;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: var(--primary);
    border-radius: 2px;
}

/* Brand Slider */
.brand-slider {
    background: var(--white);
    padding: 30px 0;
}

.brand-item {
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-item img {
    max-height: 50px;
    opacity: 0.6;
    transition: var(--transition);
    filter: grayscale(100%);
}

.brand-item:hover img {
    opacity: 1;
    filter: grayscale(0%);
}

/* Cart Page */
.cart-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: var(--shadow);
}

.cart-item-image {
    width: 80px;
    height: 80px;
    object-fit: contain;
    background: var(--light);
    border-radius: var(--radius);
}

.quantity-control {
    display: flex;
    align-items: center;
}

.quantity-control .btn {
    padding: 0.25rem 0.75rem;
}

.quantity-control input {
    width: 50px;
    text-align: center;
    border: 1px solid var(--light);
}

/* Checkout */
.order-summary {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.payment-option {
    border: 2px solid var(--light);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: var(--transition);
}

.payment-option:hover,
.payment-option.selected {
    border-color: var(--primary);
    background: var(--secondary);
}

/* Forms */
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(0, 131, 143, 0.25);
}

/* Filter Sidebar */
.mobile-filter-toggle {
    display: none;
}

.filter-section {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.filter-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--light);
}

/* Alerts */
.alert {
    border-radius: var(--radius);
    border: none;
}

/* Footer */
footer a:hover {
    color: var(--primary) !important;
}

/* Responsive */
@media (max-width: 768px) {
    .hero-title {
        font-size: 1.8rem;
    }

    .hero-section {
        padding: 50px 0;
    }

    .product-image {
        height: 150px;
    }

    .top-bar {
        display: none !important;
    }

    .hero-section .container {
        z-index: 2;
    }

    /* Mobile Header Adjustments */
    .navbar {
        padding: 8px 0;
    }

    .brand-logo {
        height: 34px;
    }

    .brand-name {
        font-size: 1.05rem;
    }

    .brand-slogan {
        font-size: 0.65rem;
    }
}

@media (max-width: 576px) {

    /* Mobile Typography & Spacing */
    body {
        font-size: 14px;
    }

    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.3rem;
    }

    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    .product-title {
        font-size: 0.9rem;
    }

    .product-price {
        font-size: 1rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.9rem;
    }

    /* Stack Cart properly */
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }


    .cart-item-image {
        width: 60px;
        height: 60px;
        margin-bottom: 10px;
    }

    .cart-item>.flex-grow-1 {
        width: calc(100% - 80px);
        /* Remaining space next to image if not wrapped, or full width */
    }

    .cart-item>.text-end {
        width: 100%;
        margin-left: 0 !important;
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid var(--light);
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: left !important;
    }

    /* Restore safer padding on mobile to swallow default row margins */
    .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Ensure all rows respect the container width */
    .row {
        margin-left: -12px;
        margin-right: -12px;
    }

    /* Product Cards in Grid */
    .col-6 {
        padding-left: 5px;
        padding-right: 5px;
    }

    .product-card {
        margin-bottom: 0;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        text-align: center;
        /* Center align content for "majhkhane ano" */
    }

    .product-body {
        padding: 8px;
        /* Slightly tighter padding */
        display: flex;
        flex-direction: column;
        align-items: center;
        /* Center flex items */
    }

    .product-title {
        font-size: 0.85rem;
        font-weight: 600;
        line-height: 1.3;
        height: 2.6em;
        overflow: hidden;
        margin-bottom: 5px;
        width: 100%;
        /* Ensure full width for centering text */
    }

    .product-price {
        font-size: 0.95rem;
        margin-bottom: 5px;
    }

    .stock-badge {
        font-size: 0.65rem;
        margin-bottom: 5px;
    }

    .btn {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
        width: 100%;
        /* Full width button looks better on small cards */
    }

    .product-price {
        font-size: 0.95rem;
    }

    .btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.8rem;
    }

    /* Ensure navbar is always on top */
    .navbar {
        z-index: 1030;
        padding: 6px 0;
    }

    /* Mobile Header - Compact Brand */
    .brand-logo {
        height: 30px;
    }

    .brand-name {
        font-size: 0.95rem;
        letter-spacing: -0.3px;
    }

    .brand-slogan {
        font-size: 0.6rem;
        letter-spacing: 0.3px;
    }

    .navbar-brand {
        margin-right: 0 !important;
        max-width: calc(100% - 110px);
    }

    .navbar-brand .me-2 {
        margin-right: 0.35rem !important;
    }

    /* Mobile nav icons spacing */
    .d-flex.d-lg-none.gap-3 {
        gap: 0.6rem !important;
    }

    /* Offcanvas Filter Styles */
    .offcanvas-lg {
        border-right: none;
    }

    .offcanvas-body {
        padding: 20px;
        overflow-y: auto;
    }

    /* Mobile Cart Delete Button - Smaller Icon */
    .remove-cart-item {
        font-size: 0.75rem !important;
        padding: 0.25rem 0.5rem !important;
    }

    .remove-cart-item i {
        font-size: 0.9rem;
    }
}

/* Ensure Offcanvas resets on desktop */
@media (min-width: 992px) {
    .offcanvas-lg {
        position: static;
        z-index: auto;
        padding: 0;
        visibility: visible;
        background-color: transparent;
        border: none;
        width: 100%;
        height: auto;
        transform: none;
        transition: none;
    }

    .offcanvas-header {
        display: none;
    }

    .offcanvas-body {
        padding: 0;
        overflow: visible;
    }
}

/* ============================================
   PREMIUM SEARCH MODAL STYLES (Global)
   ============================================ */
.search-modal-premium .modal-dialog {
    max-width: 600px;
}

.search-modal-premium .modal-content {
    border-radius: 16px;
    overflow: hidden;
    background-color: #ffffff;
    border: none;
}

.search-modal-premium .modal-body {
    background-color: #ffffff;
}

.search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 5px;
    transition: all 0.3s ease;
    width: 100%;
}

.search-input-group:focus-within {
    background: #fff;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 131, 143, 0.1);
}

.search-icon {
    position: absolute;
    left: 20px;
    color: var(--text-muted);
    font-size: 1.2rem;
    pointer-events: none;
    z-index: 10;
}

.search-input {
    border: none !important;
    background: transparent !important;
    padding-left: 50px !important;
    padding-right: 15px !important;
    height: 55px;
    box-shadow: none !important;
    font-size: 1.05rem;
    flex: 1;
}

.search-input:focus {
    box-shadow: none !important;
    outline: none !important;
}

.search-btn {
    border-radius: 8px;
    padding: 0 30px;
    height: 45px;
    font-weight: 600;
    margin-right: 2px;
    flex-shrink: 0;
}

.hover-bg-gray:hover {
    background-color: #e9ecef !important;
    color: var(--dark) !important;
}

/* Mobile Search Modal Overrides */
@media (max-width: 767px) {
    .search-modal-premium .modal-dialog {
        margin: 0;
        width: 100%;
        max-width: 100% !important;
        min-height: auto;
    }

    .search-modal-premium .modal-content {
        border-radius: 0 0 20px 20px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    }

    .search-modal-premium .modal-body {
        padding: 20px !important;
    }

    .search-input-group {
        flex-direction: row;
        padding: 4px;
        border: 1px solid #e0e0e0;
    }

    .search-input {
        height: 48px;
        font-size: 1rem;
        padding-left: 45px !important;
    }

    .search-btn {
        padding: 0 15px;
        height: 40px;
        font-size: 0.9rem;
        min-width: 80px;
    }

    .search-modal-premium .btn-close {
        top: 15px !important;
        right: 15px !important;
        font-size: 1rem;
        background-color: #f8f9fa;
        padding: 0.5rem;
        border-radius: 50%;
        opacity: 1;
        z-index: 20;
    }
}


/* Loading Spinner */
.spinner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

/* Fix Bootstrap Gutter Overflow on Mobile */
@media (max-width: 576px) {
    .row.g-4 {
        --bs-gutter-x: 0.5rem;
        /* ~8px to match tight padding */
        --bs-gutter-y: 0.5rem;
    }

    /* Mobile Header Optimization */
    .navbar-brand img {
        height: 40px !important;
        width: auto !important;
        max-width: 150px;
        object-fit: contain;
    }

    .navbar-brand .d-flex {
        margin-left: 0.25rem !important;
    }

    .navbar-brand {
        margin-right: auto;
        display: flex;
        align-items: center;
    }
}

/* Utility */
.fs-sm {
    font-size: 0.875rem !important;
}

.fs-xs {
    font-size: 0.75rem !important;
}

.fw-medium {
    font-weight: 500 !important;
}

.ls-1 {
    letter-spacing: 1px;
}

/* Custom Scrollbar for Offcanvas */
.offcanvas-body::-webkit-scrollbar {
    width: 5px;
}

.offcanvas-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.offcanvas-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 5px;
}

.offcanvas-body::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* 
=============================================
Floating WhatsApp Widget Styles
=============================================
*/

.ms-whatsapp-container {
    position: fixed;
    bottom: 25px;
    right: 25px;
    z-index: 9999;
}

.ms-btn-whatsapp {
    width: 60px;
    height: 60px;
    background-color: #25D366;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    position: relative;
    z-index: 10000;
    /* Ensure button is above the pulse ring */
    text-decoration: none;
}

.ms-btn-whatsapp:hover {
    background-color: #20b85a;
    color: #fff;
    transform: scale(1.05);
    /* Slight grow */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ms-btn-whatsapp i {
    line-height: 1;
}

/* Tooltip Styling */
.ms-tooltip {
    position: absolute;
    right: 70px;
    /* Position to the left of the button */
    top: 50%;
    transform: translateY(-50%) translateX(10px);
    background-color: #fff;
    color: #333;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

/* Tooltip Arrow */
.ms-tooltip::after {
    content: '';
    position: absolute;
    top: 50%;
    right: -6px;
    margin-top: -6px;
    border-width: 6px 0 6px 6px;
    border-style: solid;
    border-color: transparent transparent transparent #fff;
}

/* Show Tooltip on Hover */
.ms-btn-whatsapp:hover .ms-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) translateX(0);
}

/* Pulse Animation Ring */
.ms-pulse-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #25D366;
    z-index: 9998;
    /* Behind the button */
    animation: ms-pulse-animation 2s infinite;
}

@keyframes ms-pulse-animation {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    70% {
        transform: scale(1.5);
        opacity: 0;
    }

    100% {
        transform: scale(1.5);
        opacity: 0;
    }
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .ms-whatsapp-container {
        bottom: 20px;
        right: 15px;
    }

    .ms-btn-whatsapp {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .ms-pulse-ring {
        width: 50px;
        height: 50px;
    }

    /* Hide tooltip on mobile to avoid clutter */
    .ms-tooltip {
        display: none;
    }
}