@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
    --clr-primary: #14397B;
    --clr-primary-hover: #0D2652;
    --clr-accent: #00A6FF; /* Geely Electric Blue */
    --clr-silver: #E2E8F0; /* Metallic Silver Light */
    --clr-silver-dark: #94A3B8; /* Metallic Silver Dark */
    --clr-dark: #222222;
    --clr-dark-bg: #1A1D24;
    --clr-text-main: #333333;
    --clr-text-muted: #777777;
    --clr-border: #E5E5E5;
    --clr-surface: #FFFFFF;
    --clr-bg-light: #F8F9FA;
    
    --font-primary: 'Inter', sans-serif;
    --wrap-max: 1400px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-pill: 50px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: var(--font-primary);
    font-size: 14px;
    color: var(--clr-text-main);
    background: var(--clr-surface);
    line-height: 1.5;
}

/* SMART IMAGE HANDLING - Anti-Crop Philosophy */
img {
    max-width: 100%;
    height: auto;
    object-fit: contain; /* Đảm bảo không bao giờ bị cắt mất nội dung */
    display: block;
}

a { color: var(--clr-text-main); text-decoration: none; transition: 0.2s; }
a:hover { color: var(--clr-primary); }
ul { list-style: none; }

/* LAYOUT TOKENS */
.container {
    width: 100%;
    max-width: var(--wrap-max);
    margin: 0 auto;
    padding: 0 15px;
}
.section-padding { padding: 40px 0; }
.bg-light { background: var(--clr-bg-light); }

/* GLOBAL UI PILLS */
.btn-red {
    background: var(--clr-primary);
    color: #fff;
    padding: 12px 24px;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: var(--radius-md);
    font-size: 13px;
    border: none; cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(20, 57, 123, 0.2);
}
.btn-red i { margin-right: 8px; }
.btn-red:hover { 
    background: var(--clr-primary-hover); 
    color: #fff; 
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(20, 57, 123, 0.3);
}

.section-title-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    position: relative;
    padding-bottom: 15px;
}
.section-title-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(to right, var(--clr-border) 0%, var(--clr-primary) 50%, var(--clr-border) 100%);
    z-index: 1;
}
.section-title {
    font-size: 24px;
    font-weight: 800;
    text-transform: uppercase;
    display: inline-block;
    padding-bottom: 12px;
    position: relative;
    z-index: 2;
}
.section-title::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, var(--clr-primary) 0%, var(--clr-accent) 100%);
    border-radius: 3px;
}

.product-tabs { display: flex; gap: 10px; flex-wrap: wrap; z-index: 2; position: relative;}
.product-tabs a {
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    padding: 8px 20px; border-radius: var(--radius-pill); background: var(--clr-bg-light); color: var(--clr-text-muted);
    transition: all 0.3s ease; border: 1px solid var(--clr-border);
}
.product-tabs a:hover { color: var(--clr-primary); border-color: var(--clr-primary); }
.product-tabs a.active { background: linear-gradient(135deg, var(--clr-primary) 0%, #1e52b5 100%); color: #ffffff; border-color: transparent; box-shadow: 0 4px 10px rgba(20, 57, 123, 0.25); }

.car-grid {
    display: grid;
    grid-template-columns: repeat(var(--cols-ds, 4), minmax(0, 1fr));
    gap: 20px;
}
.three-cols { 
    display: flex; 
    flex-wrap: wrap;
    gap: 30px; 
}
.three-cols > div {
    flex: 1;
    min-width: 300px;
}
.split-wrap { display: flex; gap: 30px; margin-top: 20px; }
.split-left { flex: 1; }
.split-right { flex: 1; }

.split-60-40 > .split-left { flex: 0 0 60%; }
.split-65-35 > .split-left { flex: 0 0 65%; }
.split-75-25 > .split-left { flex: 0 0 75%; }
.split-60-40 > .split-right, .split-65-35 > .split-right, .split-75-25 > .split-right { flex: 1; }

@media (max-width: 991px) {
    .car-grid { grid-template-columns: repeat(var(--cols-tb, 2), minmax(0, 1fr)); }
    .three-cols { grid-template-columns: 1fr; }
    .split-wrap { flex-direction: column; }
    .main-nav { display: none; }
}
@media (max-width: 575px) {
    .car-grid { grid-template-columns: repeat(var(--cols-mb, 1), minmax(0, 1fr)); }
}
.main-nav ul { display: flex; gap: 25px; }
.main-nav ul li a { font-weight: 700; font-size: 13px; text-transform: uppercase; display: flex; align-items: center; gap: 8px; transition: color 0.3s; }
.main-nav ul li a i { color: var(--clr-primary); font-size: 14px; transition: color 0.3s; }
.main-nav ul li a:hover { color: var(--clr-accent); }
.main-nav ul li a:hover i { color: var(--clr-accent); }

/* TOP BAR STYLING */
.top-bar {
    background: #ffffff;
    color: var(--clr-dark);
    padding: 8px 0;
    font-size: 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--clr-border);
}
.top-bar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.top-bar-left span { margin-right: 15px; }
.top-bar-right a { margin-left: 10px; color: var(--clr-dark); transition: color 0.3s; }
.top-bar-right a:hover { color: var(--clr-accent); }

/* MAIN HEADER */
.site-header {
    background: #ffffff;
}

/* HOME GRID SLIDERS - overflow clipping quan trọng */
.news-swiper, .delivery-swiper { padding-bottom: 45px; overflow: hidden; }
.news-swiper .swiper-pagination, .delivery-swiper .swiper-pagination { bottom: 5px; }
/* Ảnh thumbnail TIN TỨC không được vượt kích thước */
.news-item-mini img {
    width: 100px;
    height: 70px;
    max-width: 100px;
    object-fit: contain !important;
    background: #f0f0f0;
    border-radius: 4px;
    flex-shrink: 0;
}

.swiper-pagination-bullet {
    width: 20px;
    height: 4px;
    border-radius: 2px;
    background: #ccc;
    opacity: 0.6;
    transition: all 0.3s ease;
}
.swiper-pagination-bullet-active {
    width: 40px;
    opacity: 1;
    background: var(--clr-primary) !important;
}

.delivery-slide-item a { color: var(--clr-dark); display: block; transition: 0.2s; }
.delivery-slide-item a:hover { color: var(--clr-primary); }
.delivery-slide-item .img-wrap {
    overflow: hidden;
    border-radius: 4px;
    width: 100%;
    line-height: 0;
    aspect-ratio: 16/9;
    margin-bottom: 12px;
}
.delivery-slide-item img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    object-fit: contain !important; /* Đảm bảo hiển thị trọn vẹn tấm hình, không bị cắt */
    background: #f0f0f0; /* Thêm nền nhẹ để lấp đầy khoảng trống nếu ảnh không đúng tỷ lệ */
    display: block;
    transition: transform 0.3s ease;
}
.delivery-slide-item:hover img { transform: scale(1.05); }

@keyframes ripple {
    to { transform: scale(30); opacity: 0; }
}

/* BRAND STYLING */
.brand-red { color: var(--clr-primary); font-weight: 700; }

/* Phần bên trái ảnh tin tức - không co giãn */
.news-item-mini a { flex-shrink: 0; overflow: hidden; display: block; border-radius: 4px; }

.premium-card { border-radius: 40px 0 40px 0 !important; overflow: hidden; transition: 0.3s; }

/* FORM VALIDATION & STATUS */
.input-status-wrapper { position: relative; width: 100%; display: block; }
.field-status-icon { 
    position: absolute; right: 12px; top: 50%; transform: translateY(-50%); 
    font-size: 14px; transition: 0.3s; opacity: 0; pointer-events: none; z-index: 5;
}
.field-status-icon.is-error { opacity: 1 !important; color: #dc3545; }
.field-status-icon.is-success { opacity: 1 !important; color: #28a745; }

.dieptv-form .form-group { position: relative; margin-bottom: 20px; }
.dieptv-form .field-error-msg { 
    font-size: 11px; color: #dc3545; margin-top: 5px; font-weight: 600; 
    display: none; align-items: center; gap: 5px; 
}

.dieptv-form input.is-invalid, 
.dieptv-form select.is-invalid {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
}

.dieptv-form .premium-input, 
.dieptv-form .form-control {
    width: 100%;
    transition: 0.3s;
    border: 1px solid #ddd;
    padding-right: 35px !important; /* Reserve space for icon */
}
.dieptv-form .premium-input:focus, 
.dieptv-form .form-control:focus {
    border-color: var(--clr-primary);
    box-shadow: 0 0 0 3px rgba(0,52,120,0.1);
    outline: none;
}

@media (max-width: 768px) {
    .dieptv-form .form-control,
    .dieptv-form .premium-input {
        font-size: 12.5px !important;
        height: auto !important;
        padding: 8px 6px !important;
    }
    .dieptv-form select.form-control {
        padding-right: 18px !important;
    }
    .dieptv-form label {
        font-size: 9.5px !important;
        margin-bottom: 4px !important;
        letter-spacing: 0.2px !important;
    }
}

/* SMART IMAGE HANDLING - Global Anti-Crop Rules for Articles & Widgets */
.entry-content img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Related articles and delivered vehicle widgets thumbnails */
.wp-post-image,
.attachment-thumbnail {
    object-fit: contain !important;
}

/* MOBILE RESPONSIVE: 2 Columns Per Row for Related Cars Segment */
@media (max-width: 768px) {
    .related-car-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
        padding: 0 5px;
    }
    
    .related-car-grid .car-card {
        padding: 8px !important;
    }
    
    .related-car-grid .car-title {
        font-size: 13px !important;
        margin-bottom: 8px !important;
        line-height: 1.3 !important;
    }
    
    .related-car-grid .car-specs-bar {
        display: none !important; /* Hide spec bar to prevent clutter on small screens */
    }
    
    .related-car-grid .car-badge {
        top: 8px !important;
        left: 8px !important;
        font-size: 8px !important;
        padding: 2px 6px !important;
    }
    
    .related-car-grid .car-versions {
        margin-bottom: 8px !important;
        padding-top: 8px !important;
        gap: 4px !important;
    }
    
    .related-car-grid .version-row {
        font-size: 10px !important;
    }
    
    .related-car-grid .v-price {
        font-size: 10px !important;
    }

    .related-car-grid .car-actions {
        flex-direction: column !important; /* Stack action buttons vertically */
        gap: 6px !important;
        padding-top: 8px !important;
    }
    
    .related-car-grid .btn-card-primary,
    .related-car-grid .btn-card-outline {
        width: 100% !important;
        padding: 8px 4px !important;
        font-size: 9.5px !important;
        height: auto !important;
        line-height: 1.2 !important;
    }
    
    .related-car-grid .btn-card-hotline {
        display: none !important; /* Hide extra phone icon as agent hotline is prominently displayed above */
    }
}

/* MOBILE RESPONSIVE: Agent info header layout (Avatar on the right, Quote on the left, same row) */
@media (max-width: 768px) {
    .agent-info-header {
        flex-direction: row-reverse !important;
        gap: 15px !important;
        align-items: flex-start !important;
    }
    
    .agent-info-header > div:first-child {
        flex-shrink: 0 !important;
    }
    
    .agent-info-header img {
        width: 90px !important;
        height: 90px !important;
        border-width: 3px !important;
    }
    
    .agent-info-header div[title="Đang trực tuyến"] {
        width: 16px !important;
        height: 16px !important;
        bottom: 5px !important;
        right: 5px !important;
        border-width: 2px !important;
    }
    
    .agent-info-header h2 {
        font-size: 20px !important;
    }
    
    .agent-info-header div:last-child > div:nth-child(2) {
        font-size: 11px !important;
    }
    
    .agent-info-header p {
        font-size: 12px !important;
        line-height: 1.4 !important;
        margin-top: 8px !important;
    }
}

/* MOBILE RESPONSIVE: Section Title and Wrap styling (Fluid adjustment to prevent overflow & wrapping) */
@media (max-width: 768px) {
    .section-title-wrap {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 10px !important;
        border-bottom: none !important;
        margin-bottom: 20px !important;
    }
    
    .section-title {
        font-size: 18px !important; /* Scale down title safely on mobile */
        width: 100% !important;
        border-bottom: 3px solid var(--clr-primary) !important;
        padding-bottom: 8px !important;
        line-height: 1.3 !important;
    }
    
    .section-subtitle {
        font-size: 11px !important;
        margin-top: 4px !important;
    }
    
    .view-all {
        font-size: 11.5px !important;
        margin-top: 2px !important;
    }
}

/* MOBILE RESPONSIVE: Loan Calculator Year Selector Padding adjustment */
@media (max-width: 768px) {
    .loan-calc-widget .year-selector {
        padding: 5px !important;
        font-size: 11px !important; /* Slightly scale font to fit nicely on mobile screens */
        text-align: center !important;
    }
}

/* MOBILE FIRST: Display the Loan Calculator first and Quote Form second on mobile screens */
@media (max-width: 991px) {
    .loan-quote-wrap {
        flex-direction: column-reverse !important;
    }
}

/* MOBILE RESPONSIVE: Stacking loan inputs vertically to make range slider larger & easier to touch */
@media (max-width: 768px) {
    .loan-flex-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    
    .loan-flex-row > div:last-child {
        width: 100% !important;
    }
    
    .loan-flex-row label {
        display: none !important;
    }
    
    /* Force 2 fields per row on mobile with small gap */
    .quote-form-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px 8px !important;
    }
    
    /* Styling placeholders and paddings to fit and look highly aesthetic on mobile */
    .dieptv-form .form-control::placeholder {
        font-size: 11.5px !important;
        opacity: 0.65 !important;
    }
    
    .quote-form-widget {
        padding: 15px !important;
    }

    #home-calc-loan-amount {
        background: rgba(255, 255, 255, 0.05) !important;
        color: #00A6FF !important;
        border-color: #00A6FF !important;
        text-align: center !important;
        font-size: 15px !important;
        font-weight: 800 !important;
    }
}

/* Make all container on homepage 86% width on Desktop only */
@media (min-width: 992px) {
    body.home {
        --wrap-max: 86%;
    }
}
