/*
    MyCarCare Custom Stylesheet
    ---
    Table of Contents (Updated):
    1.  Global Resets & Variables      - Root variables and global box-sizing.
    2.  General & Typography           - Body, headings, and link styles.
    3.  Header & Navigation            - Navbar, brand, links, and scroll behavior.
    4.  Hero Section                   - Homepage hero styles, including transparent cards.
    5.  Forms & Buttons                - Global styles for form inputs and buttons.
    6.  Cards & General Components     - Base card styles and specific product card designs.
    7.  Page-Specific Sections         - Styles for unique sections on various pages.
        - Car Selector                 - The vehicle filter on the homepage.
        - CTA Section                  - Call-to-action blocks.
        - Testimonials                 - Customer testimonial cards.
        - Product Categories           - Icon-based category links.
        - Brands                       - Grayscale brand logos.
    8.  Feature-Specific Components    - Styles for distinct application features.
        - Map                          - Responsive map container.
        - Autocomplete                 - Search and input autocomplete dropdowns.
        - Header Search                - The search bar in the main navigation.
        - Garage                       - 'My Garage' vehicle card styles.
        - Filters & Grid Switcher      - Product page filtering UI.
        - Cart (Page & Mini)           - Styles for the main cart page and the mini-cart drawer.
        - Checkout Page                - Address selection and other checkout UI.
        - Modals                       - Custom modal animations.
        - Undo Notification            - The "Undo" message after item removal.
    9.  Responsive & Mobile            - Media queries for various screen sizes.
*/

/* --- 1. Global Resets & Variables --- */
:root {
    --mycar-primary: #FFC107;      /* Primary theme color, a vibrant gold */
    --mycar-primary-darker: #e0a800; /* For hover states on primary elements */
    --mycar-accent: #004A99;      /* Accent color, a deep blue */
    --mycar-accent-darker: #003b7a; /* For hover states on accent elements */
    --mycar-dark-text: #333;
    --mycar-dark-bg: #343a40;
    --navbar-height: 70px; /* default navbar height for spacing */
    --navbar-height-desktop: 6rem; /* desktop top spacing used previously */
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Roboto', sans-serif;
    color: var(--mycar-dark-text);
        /* --- Sticky Footer Fix --- */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* This makes the main content area grow to push the footer down */
main { 
    flex: 1; 
    /* --- Smooth Page Transition --- */
}

/* NEW: Target the #page-content wrapper for transitions */
#page-content {
    /* Use our new motion variables for a smoother feel */
    transition: opacity var(--duration-fast) var(--ease-out-quint), transform var(--duration-fast) var(--ease-out-quint);
}

/* Animate the wrapper for exit */
#page-content.is-exiting {
    opacity: 0;
    transform: translateY(10px);
}

a {
    /* Add a subtle transition to all links */
    transition: color 0.2s ease-in-out;
}

h1, h2, h3, h4, h5, h6, .navbar-brand {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
}

/* NEW: Consistent Section Heading Style */
.section-heading {
    border-bottom: 2px solid var(--mycar-primary);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem !important; /* Use !important to override Bootstrap's mb-4/mb-5 */
    display: inline-block; /* Ensures the border only spans the text length */
}

/* --- 2. Header & Navigation --- */
.navbar-brand {
    font-family: 'Racing Sans One', sans-serif;
    font-size: 2.3rem;
    font-weight: 400;
    letter-spacing: 1px;
    text-decoration: underline;
}

.navbar .nav-link {
    font-weight: 500;
    transition: color 0.3s;
}

.navbar .nav-link:hover, .navbar .nav-link.active {
    color: var(--mycar-primary) !important; /* Gold for nav highlights */
}

/* Make the default dark navbar pure black for consistency */
.navbar.bg-dark {
    background-color: #000 !important;
}

/* --- 3. Hero Section --- */
.hero-section {
    position: relative; /* Establishes a positioning context for the overlay */
    background: url('../img/hero-background.jpg') no-repeat center center;
    background-size: cover;
    background-color: var(--mycar-dark-bg); /* Fallback color */
    z-index: 1;
    min-height: 100vh; /* Set to full viewport height */
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center the content vertically */
    padding-top: 4rem; /* reduced padding since header is now fixed and opaque */
    padding-bottom: 4rem;
}

/* Prefer WebP background when supported */
.webp .hero-section {
    background-image: url('../img/hero-background.webp');
}

.hero-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.4); /* The dark overlay */
    z-index: -1; /* Places the overlay between the background image and the content */
}


.usp-content {
    margin-top: 4rem; /* Add space between hero text and USP cards */
}

/* Style for the transparent cards in the hero section */
.hero-section .card {
    background-color: rgba(255, 255, 255, 0.1); /* Semi-transparent white for a glassy look */
    border: 1px solid rgba(255, 255, 255, 0.2);  /* Subtle light border */
    color: #fff; /* Make all text inside white */
    box-shadow: none; /* Remove the default shadow */
    backdrop-filter: blur(5px); /* Frosted glass effect (gracefully degrades on older browsers) */
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.hero-section .card .card-title {
    color: #fff;
}

.hero-section .card:hover {
    background-color: rgba(255, 255, 255, 0.2); /* Brighten slightly on hover */
    border-color: rgba(255, 255, 255, 0.4);
}

.hero-section .btn {
    /* Add a subtle shadow to lift them off the page */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    border-width: 2px;
    background-color: #f0f0f0; /* Very light grey background */
    color: #000;               /* Black text */
    border-color: #f0f0f0;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
.hero-section .btn:hover {
    background-color: #302f2f;              /* Switch to black on hover */
    color: #fff;                         /* Switch to white text on hover */
    border-color: #302f2f;
}

/* --- 4. Forms & Buttons --- */
/* A more modern, Apple-inspired aesthetic for all form inputs */
.form-control,
.form-select {
    border-radius: 8px;
    border: 1px solid #d2d2d7;
    background-color: #f5f5f7;
    padding: 0.6rem 1rem;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.form-control:focus,
.form-select:focus {
    background-color: #fff;
    border-color: var(--mycar-primary);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.25); /* A soft gold glow */
    outline: none;
}

/* Redefined button styles for a cleaner look */
.btn-primary {
    background-color: var(--mycar-primary);
    border-color: var(--mycar-primary);
    color: #212529; /* Dark text on gold for better contrast */
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-primary:hover {
    background-color: var(--mycar-primary-darker);
    border-color: var(--mycar-primary-darker);
    color: #212529;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}
/* NEW: Add to Cart button animation */
.btn.is-adding {
    background-color: #28a745; /* Success green */
    border-color: #28a745;
    color: #fff;
    transform: scale(1.05);
    pointer-events: none; /* Disable clicks during animation */
}

.btn.is-adding i {
    animation: checkmark-pop 0.4s var(--ease-out-quint);
}

@keyframes checkmark-pop {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.btn-secondary {
    background-color: #e9ecef;
    border-color: #e9ecef;
    color: var(--mycar-dark-text);
}
.btn-secondary:hover {
    background-color: #dbe1e6;
    border-color: #dbe1e6;
}

.btn-accent {
    background-color: var(--mycar-accent);
    border-color: var(--mycar-accent);
    color: #fff;
}
.btn-accent:hover {
    background-color: var(--mycar-accent-darker);
    border-color: var(--mycar-accent-darker);
}

.btn {
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease-in-out;
}

.card {
    border-radius: 12px; /* Softer, more modern radius */
    border: 1px solid #e9ecef; /* A subtle border for all cards */
    box-shadow: 0 4px 12px rgba(0,0,0,0.05); /* A softer, more diffused shadow */
    transition: transform var(--duration-fast) var(--ease-in-out-quad), box-shadow var(--duration-fast) var(--ease-in-out-quad), border-color var(--duration-fast) var(--ease-in-out-quad);
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

/* --- Disabled Form States for Better UX --- */
.form-control:disabled,
.form-select:disabled,
.btn:disabled {
    background-color: #e9ecef;
    opacity: 0.7;
    cursor: not-allowed;
}

/* Make disabled list group items for services more obvious */
.list-group-item input[type="checkbox"]:disabled + span,
.list-group-item input[type="checkbox"]:disabled ~ div {
    opacity: 0.5;
}

.list-group-item input[type="checkbox"]:disabled {
    cursor: not-allowed;
}

label.list-group-item:has(input:disabled) {
    background-color: #f8f9fa;
    cursor: not-allowed;
}
/* --- 5. Cards & Components --- */
.product-card {
    background-color: #f5f5f7; /* A very light, Apple-like grey */
    border: 1px solid transparent; /* Start with a transparent border */
    border-radius: 18px; /* Softer, more rounded corners */
    box-shadow: none; /* Remove default shadow */
    transition: border-color 0.25s ease-in-out, transform 0.25s ease-in-out;
}

.product-card:hover {
    transform: translateY(-4px);
    border-color: #d2d2d7; /* Add a subtle border on hover */
    box-shadow: none; /* Ensure no shadow appears on hover */
}

.product-card-new {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.product-card .product-card-img-container {
    padding: 1.5rem; /* Give the image breathing room */
    background-color: #fff; /* White background for the image */
    border-radius: 18px 18px 0 0;
}

.product-card .card-img-top {
    aspect-ratio: 4 / 3; /* Maintain a consistent aspect ratio */
    object-fit: contain; /* Ensure the whole product is visible */
}

.product-card .card-title {
    font-size: 1.1rem;
    font-weight: 600;
}

/* --- 6. Page-Specific Sections --- */

.cta-section {
    background-color: var(--mycar-dark-bg);
    color: #fff;
}

.map-responsive {
    overflow: hidden;
    padding-bottom: 75%; /* Adjust this value for aspect ratio */
    position: relative;
    height: 0;
}

.map-responsive iframe {
    left: 0;
    top: 0;
    height: 100%;
    width: 100%;
    position: absolute;
}

/* --- 7. Components --- */
.autocomplete {
    position: relative;
    width: 100%;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid #d4d4d4;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    background-color: #fff;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.autocomplete-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    color: var(--mycar-dark-text); /* Ensure dropdown text is readable */
}

.autocomplete-item:hover {
    background-color: #f1f1f1;
}

.list-group-item {
    cursor: pointer; /* Make the whole row clickable */
}

/* Carousel image fixes: make all carousel images behave consistently regardless of original resolution */
.carousel .carousel-item .row.g-0 {
    align-items: stretch; /* ensure columns stretch to same height */
}

.carousel .carousel-item img {
    width: 100%;
    height: 220px; /* default height for medium screens */
    object-fit: cover; /* crop to fill without distortion */
    display: block;
}

/* Larger screens: increase carousel image height for better visuals */
@media (min-width: 992px) {
    .carousel .carousel-item img {
        height: 320px;
    }
}

/* Small screens: reduce height to keep the hero visible and avoid large scroll jumps */
@media (max-width: 575.98px) {
    .carousel .carousel-item img {
        height: 160px;
    }
    .carousel-caption {
        font-size: 0.95rem;
        padding: 0.5rem 0.75rem;
        background: rgba(0,0,0,0.35);
        border-radius: 6px;
    }
}

/* Ensure carousel rows do not overflow their container */
.carousel .row.g-0 { margin: 0; }


.list-group-item .form-check-input {
    pointer-events: none; /* The label handles the click, preventing double-firing */
}

/* Ensure form labels are white on dark backgrounds */
.bg-dark .form-label {
    color: #fff;
}

.product-category-card {
    border: 1px solid #eee;
}
.product-category-card .icon-circle {
    width: 70px;
    height: 70px;
    background-color: rgba(0, 74, 153, 0.1); /* Transparent version of the new blue */
    color: var(--mycar-blue);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin-bottom: 1rem;
}

.brands-section img {
    max-height: 40px;
    filter: grayscale(100%);
    opacity: 0.7;
    transition: filter 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

.brands-section img:hover {
    filter: grayscale(0%);
    opacity: 1;
    transform: scale(1.1);
}

.cart-icon {
    position: relative;
    font-size: 1.2rem;
}

.cart-count {
    position: absolute;
    top: -8px;
    right: -12px;
    background-color: var(--mycar-accent); /* Blue for notifications provides good contrast */
    color: #fff;
    border-radius: 50%;
    padding: 0.1em 0.4em;
    font-size: 0.75rem;
    font-weight: 700;
}

.cart-icon.is-bouncing {
    animation: cart-bounce 0.6s ease;
}

@keyframes cart-bounce {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.3);
    }
    50% {
        transform: scale(0.9);
    }
    70% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

.cart-item-img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.header-search-container {
    position: relative;
    width: 250px; /* A good default width */
    transition: width 0.3s ease-in-out;
}

@media (min-width: 992px) { /* On larger screens, make it longer */
    .header-search-container {
        width: 350px;
    }
}

.header-search-container .form-control {
    padding-right: 2.5rem; /* Make space for the icon */
}

.header-search-container .search-btn {
    position: absolute;
    top: 50%;
    right: 0.1rem;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #6c757d; /* A subtle grey color */
    padding: 0.375rem 0.75rem;
    cursor: pointer;
    z-index: 10; /* Ensure it's clickable */
}

.garage-car-img {
    height: 180px;
    width: 100%;
    object-fit: cover;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
}

footer.bg-dark {
    background-color: #000 !important;
}

/* --- 8. Responsive & Mobile Optimizations --- */
/* Mobile and small screens: some mobile-specific tweaks kept, but navbar styling
    will be enforced globally below. */
@media (max-width: 991.98px) {
    /* Mobile-first typography and spacing */
    body {
        font-size: 15px; /* slightly larger base font for readability on phones */
        line-height: 1.45;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }

    /* Make header search full-width in collapsed menu */
    .header-search-container {
        width: 100%;
        margin-bottom: 1rem; /* Add space between search and nav links */
    }

    /* Stack auth buttons horizontally with more breathing room */
    #header-right-container .navbar-nav {
        flex-direction: row;
        justify-content: space-around;
        width: 100%;
        gap: 0.5rem;
    }

    /* Adjust hero section font size for smaller screens */
    .hero-section h1 {
        font-size: 2.4rem;
    }
    .hero-section p.lead {
        font-size: 1.05rem;
    }

    /* Make primary CTAs easier to tap */
    .hero-section .btn,
    .btn {
        padding: 0.65rem 1rem;
        font-size: 1rem;
        border-radius: 0.5rem;
        min-height: 44px; /* meets touch target recommendations */
    }

    /* Slightly larger form controls for mobile */
    .form-control {
        padding: 0.6rem 0.75rem;
        font-size: 1rem;
        border-radius: 0.375rem;
    }

    /* Make product slider images smaller on mobile */
    #product-slider-section .carousel-item img {
        max-height: 200px; /* Smaller height for mobile */
        object-fit: cover;
    }

    /* Improve click/tap targets for navbar toggler */
    .navbar-toggler {
        padding: 0.5rem 0.75rem;
        border-radius: 0.375rem;
    }

    /* Add solid background to expanded mobile menu on homepage for readability */
    .homepage .navbar-collapse.show,
    .homepage .navbar-collapse.collapsing {
        background-color: rgba(0, 0, 0, 0.95); /* Near-solid black background */
        padding: 1rem;
        border-radius: 0.375rem;
        margin-top: 0.5rem;
        border: 1px solid #000; /* solid black border to match the background */
    }

    /* Ensure collapsed navbar panels (not using offcanvas) are fully black with solid borders */
    .navbar-collapse {
        background-color: #000; /* ensure solid black */
        border: 1px solid #000;
    }

    /* Offcanvas mobile menu overrides (Bootstrap offcanvas) */
    .offcanvas {
        background-color: #000 !important;
        color: #fff;
        border: 1px solid #000 !important;
    }

    .offcanvas.show {
        background-color: #000 !important;
        border: 1px solid #000 !important;
    }

    /* mobile-specific tweaks only */

    /* Prevent page content from being hidden under the fixed navbar.
       Apply padding to the common SPA container `#page-content` and its
       typical direct children so pages that don't use a top-level <main>
       (like the index hero sections) are also handled. */
    #page-content,
    #page-content > main,
    #page-content > section,
    #page-content .container {
        padding-top: var(--navbar-height);
    }

    /* Make lists, cards and product items breathe more on mobile */
    .card,
    .list-group-item,
    .product-card {
        padding: 0.9rem;
        margin-bottom: 0.8rem;
    }

    /* Ensure interactive icons & controls have sufficient size */
    .icon-button,
    .qty-control .btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.4rem;
    }
}

@media (max-width: 767.98px) {
    /* Further refine cart item layout on smaller screens */
    .cart-item-layout-wrapper {
        flex-direction: column;
        align-items: flex-start;
    }

    .cart-item-controls {
        width: 100%;
        justify-content: space-between !important;
        margin-top: 1rem;
    }

    /* Make cart page header stack cleanly */
    .cart-page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
}

@media (max-width: 576px) {
    /* Reduce brand logo font size on very small screens */
    .navbar-brand {
        font-size: 1.8rem;
    }

    h1, .h1 { font-size: 1.9rem; }
    h2, .h2 { font-size: 1.5rem; }

    /* Make primary buttons full-width and easy to tap on very small screens */
    .btn-primary {
        display: block;
        width: 100%;
        padding: 0.75rem 0.9rem;
        font-size: 1rem;
        border-radius: 0.5rem;
        text-align: center;
    }

    /* Improve spacing for small form groups */
    .form-group,
    .form-row {
        gap: 0.5rem;
    }
}

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1050;
    background-color: #000; /* default background (may be overridden by .homepage rules) */
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}
/* Ensure page content is pushed down under the navbar in all viewports */
#page-content,
#page-content > main,
#page-content > section,
#page-content .container {
    padding-top: var(--navbar-height);
}


.filter-group h6 {
    border-bottom: 1px solid #eee;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
}

#grid-view-switcher .btn.active {
    background-color: var(--mycar-primary);
    color: white;
}

/* --- Checkout Page Enhancements --- */
.list-group-item-action.active {
    border-color: var(--mycar-primary-darker) !important;
    background-color: rgba(255, 193, 7, 0.1) !important;
    color: var(--mycar-dark-text) !important;
    box-shadow: 0 0 0 2px var(--mycar-primary);
}

/* --- Gentle Modal Animation --- */
.modal.fade .modal-dialog {
    transform: scale(0.95) translateY(-10px);
    opacity: 0;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.modal.show .modal-dialog {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* --- Mini Cart Styles --- */
.mini-cart-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
}

.mini-cart-item:last-child {
    border-bottom: none;
}

.mini-cart-item-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 0.25rem;
    margin-right: 1rem;
}

.mini-cart-item-details {
    flex-grow: 1;
}

.mini-cart-item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.2;
}

.mini-cart-item-price {
    color: #6c757d;
    font-size: 0.9rem;
}

.mini-cart-item-controls .btn-link {
    font-size: 0.9rem;
}

/* --- Undo Notification --- */
.list-group-item.text-center.text-muted {
    background-color: #f8f9fa;
    border: 1px dashed #dee2e6;
}

/* --- Account Page Empty States --- */
.empty-state {
    background-color: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --- Skeleton Loader Styles --- */
.skeleton {
    opacity: .7;
    animation: skeleton-loading 1s linear infinite alternate;
}

.skeleton-text {
    width: 100%;
    height: 0.7rem;
    margin-bottom: 0.5rem;
    border-radius: 0.25rem;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 80%;
}

.skeleton-img {
    width: 100px;
    height: 100px;
}

@keyframes skeleton-loading {
    0% { background-color: hsl(200, 20%, 80%); }
    100% { background-color: hsl(200, 20%, 95%); }
}

/* --- Custom Pagination Styles --- */
.pagination .page-link {
    color: var(--mycar-dark-text);
    background-color: #fff;
    border: 1px solid #dee2e6;
    transition: all 0.2s ease-in-out;
}

.pagination .page-link:hover {
    background-color: #e9ecef;
    color: #000;
}

.pagination .page-item.active .page-link {
    background-color: var(--mycar-primary);
    border-color: var(--mycar-primary-darker);
    color: #000; /* Black text on yellow background */
}

.pagination .page-item.disabled .page-link {
    color: #6c757d;
}
