/* ==========================================================================
   Datamotive Custom Vehicle Frontend Styles
   ========================================================================== */

/* --- Layout: Archive Container --- */
.vehicle-archive-container {
  display: flex;
  flex-wrap: nowrap;
  gap: 40px;
  width: 100%;
  max-width: 100%;
  margin: 20px 0;
  box-sizing: border-box;
  font-family: inherit;
}

/* --- Left Sidebar Filter --- */
.vehicle-sidebar {
  width: 20%;
  min-width: 240px;
  flex-shrink: 0;
  background: #fff;
  padding: 0;
}
.sidebar-title {
  font-size: 20px !important;
  font-weight: 800;
  margin-bottom: 25px;
}
.filter-group {
  border-bottom: 1px solid #eee;
  margin-bottom: 15px;
  padding-bottom: 15px;
}
.filter-group-title {
  font-size: 15px !important;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 15px 0;
}
.filter-group-title .toggle-icon svg {
  transition: transform 0.3s;
}
.filter-group-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-range {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.filter-range input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
}
.filter-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px !important;
  color: #666;
}
.filter-checkbox input {
  display: none;
}
.custom-chk {
  width: 18px;
  height: 18px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-right: 10px;
  display: inline-block;
  position: relative;
}
.filter-checkbox input:checked + .custom-chk {
  background: #000;
  border-color: #000;
}
.filter-checkbox input:checked + .custom-chk::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.filter-count {
  margin-left: auto;
  color: #999;
  font-size: 12px;
}

/* --- Right Main Grid --- */
.vehicle-main {
  width: 75%;
  flex-grow: 1;
}
.vehicle-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
}
.vehicle-count-display {
  font-size: 26px !important;
  font-weight: 800;
  margin: 0;
}
.vehicle-sort-dropdown select {
  padding: 10px 15px;
  border: 1px solid #000;
  border-radius: 4px;
  background: #fff;
  font-weight: bold;
  font-size: 16px !important;
  cursor: pointer;
}

/* Grid Wrapper & Loader */
.vehicle-grid-wrapper {
  position: relative;
}
.vehicle-loader {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
}
.vehicle-loader.active {
  display: flex;
}
.vehicle-loader::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #000;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* The Grid */
.vehicle-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* --- Vehicle Grid Card --- */
.vehicle-card {
  background: #fff;
  border: 1px solid #eef0f2;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.3s;
}
.vehicle-card:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}
.vehicle-card-image {
  width: 100%;
  height: 200px;
  background: #f8f8f8;
}
.vehicle-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.vehicle-card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}
.vehicle-card-title {
  font-size: 22px;
  font-weight: 900;
  margin: 0 0 5px 0;
  color: #000;
}
.vehicle-card-desc {
  font-size: 14px;
  color: #666;
  margin: 0 0 10px 0;
  line-height: 1.5;
  /* line clamp to 2 lines */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.vehicle-card-specs {
  font-size: 13px;
  color: #999;
  margin-bottom: 20px;
}
.vehicle-card-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  margin-bottom: 5px;
  margin-top: auto;
  border-bottom: 1px solid #eee;
}
.vehicle-card-finance {
  font-size: 13px;
  color: #333;
  margin-bottom: 15px;
  padding-top: 10px;
}
.finance-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}
.finance-row:first-child {
  font-weight: 800;
  color: #000;
  font-size: 14px;
  margin-bottom: 8px;
}
.finance-row .info-icon {
  color: #999;
  cursor: help;
}
.finance-row .finance-price {
  font-size: 14px;
}

.vehicle-card-actions {
  display: flex;
  justify-content: end;
  align-items: center;
  border-top: 1px solid #eee;
  padding-top: 15px;
}
.compare-checkbox {
  font-size: 14px;
  color: #666;
  cursor: pointer;
}
.btn-details {
  display: inline-block;
  padding: 10px 18px;
  border: 1px solid #000;
  border-radius: 4px;
  color: #000 !important;
  text-decoration: none !important;
  font-weight: 800;
  font-size: 14px;
  transition: all 0.3s;
}
.btn-details:hover {
  background: #000 !important;
  color: #fff !important;
  text-decoration: none !important;
}

/* Pagination */
.vehicle-pagination {
  margin-top: 40px;
  text-align: center;
  grid-column: 1 / -1;
}
.vehicle-pagination-list {
  display: inline-flex;
  list-style: none;
  padding: 0;
  margin: 0;
  gap: 5px;
}
.vehicle-pagination-list li a,
.vehicle-pagination-list li span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 40px;
  padding: 0 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #000;
  font-weight: bold;
  transition: all 0.2s;
}
.vehicle-pagination-list li a:hover {
  background: #000;
  color: #fff;
  border-color: #000;
}
.vehicle-pagination-list li span.current {
  background: #000;
  color: #fff;
  border-color: #000;
}
.vehicle-pagination-list li span.dots {
  border: none;
}

/* ==========================================================================
   Single Vehicle Template Styles
   ========================================================================== */

.vehicle-single-container {
  width: 100%;
  max-width: 1400px;
  margin: 50px auto;
  padding: 0 40px;
  display: flex;
  gap: 60px;
  font-family: inherit;
}

/* Left Grid */
.vehicle-single-left {
  width: 50%;
}
.vehicle-main-image {
  width: 100%;
  height: 400px;
  background: #f4f4f4;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 15px;
}
.vehicle-main-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.vehicle-gallery-thumbs {
  display: flex;
  gap: 10px;
  margin-bottom: 40px;
  overflow-x: auto;
  padding-bottom: 5px;
}
.v-thumb {
  width: 100px;
  height: 70px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border 0.3s;
}
.v-thumb:hover {
  border-color: #000;
}
.vehicle-content-full {
  font-size: 15px;
  line-height: 1.6;
  color: #444;
}

/* Right Grid */
.vehicle-single-right {
  width: 50%;
}
.vehicle-single-title {
  font-size: 42px;
  font-weight: 900;
  margin: 0 0 10px 0;
  line-height: 1.1;
}
.vehicle-single-specs {
  font-size: 14px;
  color: #666;
  margin: 0 0 15px 0;
}
.stock-status {
  color: #128c7e;
  font-weight: bold;
  font-size: 14px;
  margin-bottom: 30px;
}

/* Buy Box */
.vehicle-buy-box {
  margin-bottom: 20px;
}
.buy-expanded-content {
  max-height: 0;
  overflow: hidden;
  transition:
    max-height 0.4s ease,
    margin-top 0.4s ease;
  margin-top: 0;
}
.buy-option-container.is-active .buy-expanded-content {
  max-height: 500px;
  margin-top: 20px;
}
.buy-header {
  display: flex;
  justify-content: space-between;
  font-size: 20px;
  margin-bottom: 10px;
}
.buy-sub {
  font-size: 13px;
  color: #000;
  font-weight: bold;
  margin-bottom: 20px;
}
.btn-block {
  display: block;
  width: 100%;
  padding: 15px;
  text-align: center;
  border-radius: 4px;
  text-decoration: none;
  font-weight: bold;
  margin-bottom: 10px;
  font-size: 14px;
  transition: opacity 0.3s;
  color: #fff !important;
}
.btn-block:hover {
  opacity: 0.9;
}
.btn-green {
  background: #26c02c;
  color: #fff;
  border: none;
}
.btn-black {
  background: #222;
  color: #fff;
  border: none;
}
.btn-whatsapp {
  background: #25d366;
  color: #fff;
  border: none;
}

.vehicle-specs-table,
.vehicle-dealer-info {
  margin-top: 30px;
  background: #f8f9fa;
  padding: 25px;
  border-radius: 6px;
}
.vehicle-specs-table h3,
.vehicle-dealer-info h3 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 20px;
  font-weight: 900;
}
.specs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  row-gap: 12px;
  column-gap: 20px;
  margin: 0;
}
.specs-grid dt {
  font-weight: 600;
  color: #666;
  font-size: 14px;
}
.specs-grid dd {
  font-weight: 700;
  margin: 0;
  color: #000;
  font-size: 14px;
}
.specs-grid dd a {
  color: #000;
  text-decoration: underline;
}

.vehicle-finance-options {
  margin-top: 30px;
}
.finance-radio {
  display: flex;
  align-items: center;
  padding: 15px 0;
  border-bottom: 1px solid #eee;
  color: #666;
}
.finance-radio input {
  margin-right: 15px;
}
.fr-left {
  flex-grow: 1;
  font-size: 14px;
}
.fr-right {
  font-weight: bold;
  color: #000;
}

/* Inline Extractions from template-parts/vehicle-card.php */
.vehicle-card-title-link {
  text-decoration: none !important;
  color: inherit !important;
}

/* Inline Extractions from single-vehicle.php */
.single-vehicle-main-img-relative {
  position: relative !important;
}
.hero-prev-arrow {
  position: absolute !important;
  left: 0 !important;
  z-index: 10 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  color: white !important;
  border: none !important;
  width: 50px !important;
  height: 100% !important;
  cursor: pointer !important;
  transition: 0.3s !important;
  font-size: 24px !important;
}
.vehicle-hero-img-transition {
  transition: opacity 0.3s !important;
}
.hero-next-arrow {
  position: absolute !important;
  right: 0 !important;
  z-index: 10 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  color: white !important;
  border: none !important;
  width: 50px !important;
  height: 100% !important;
  cursor: pointer !important;
  transition: 0.3s !important;
  font-size: 24px !important;
}
.gallery-wrapper-flexbox {
  position: relative !important;
  display: flex !important;
  align-items: center !important;
  margin-bottom: 40px !important;
  margin-top: 10px !important;
}
.gallery-prev-arrow {
  position: absolute !important;
  left: 0 !important;
  z-index: 10 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  color: white !important;
  border: none !important;
  width: 35px !important;
  height: 100% !important;
  cursor: pointer !important;
  transition: 0.2s !important;
}
.thumbs-scroll-container {
  display: flex !important;
  overflow-x: auto !important;
  scroll-behavior: smooth !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
  gap: 10px !important;
  width: 100% !important;
  margin-bottom: 0 !important;
  padding: 0 40px !important;
}
.v-thumb-shrink {
  flex-shrink: 0 !important;
}
.gallery-next-arrow {
  position: absolute !important;
  right: 0 !important;
  z-index: 10 !important;
  background: rgba(0, 0, 0, 0.6) !important;
  color: white !important;
  border: none !important;
  width: 35px !important;
  height: 100% !important;
  cursor: pointer !important;
  transition: 0.2s !important;
}

/* Extractions from functions.php */
.vehicle-grid-empty-state {
  grid-column: 1 / -1 !important;
  padding: 40px !important;
  text-align: center !important;
}

/* Mobile Filter Toggle Button */
.mobile-filter-toggle {
  display: none;
  width: 100%;
  padding: 15px;
  background: #000;
  color: #fff;
  border: none;
  font-weight: bold;
  font-size: 16px;
  border-radius: 6px;
  margin-bottom: 20px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.mobile-filter-toggle-icon {
  margin-right: 8px !important;
}

/* ==========================================================================
   Offcanvas Test Drive Modal
   ========================================================================== */
.test-drive-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 99998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}
.test-drive-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.test-drive-offcanvas {
  position: fixed;
  top: 0;
  right: 0;
  width: 900px;
  height: 100vh;
  background: #fff;
  z-index: 99999;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}
.test-drive-offcanvas.active {
  transform: translateX(0);
}

.test-drive-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 1px solid #eee;
}
.test-drive-close {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: #000;
}

.test-drive-content {
  display: flex;
  gap: 40px;
  padding: 40px;
}
.test-drive-form-area {
  flex: 1;
}
.test-drive-vehicle-area {
  flex: 0 0 320px;
}

.test-drive-title {
  font-size: 32px;
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 5px;
}
.test-drive-desc {
  color: #128c7e;
  font-weight: bold;
  margin-bottom: 40px;
  font-size: 14px;
}
.test-drive-desc strong {
  color: #128c7e;
}

.test-drive-step {
  font-size: 11px;
  text-transform: uppercase;
  color: #666;
  display: flex;
  align-items: center;
  margin-bottom: 20px;
}
.step-indicator {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #eeffeb;
  border: 1px solid #26c02c;
  border-radius: 50%;
  margin-right: 10px;
}

.test-drive-form {
  display: flex;
  flex-direction: column;
}
.td-form-row {
  display: flex;
  gap: 15px;
  width: 100%;
  margin-bottom: 20px;
}
.td-form-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-bottom: 20px;
}
.td-form-row .td-form-group {
  margin-bottom: 0;
}

.td-form-group input,
.td-form-group select {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
}
.td-form-group input:focus,
.td-form-group select:focus {
  border-color: #000;
}
.td-form-group input.error,
.td-form-group select.error {
  border-color: #ffcccc;
}
.td-error {
  color: #ff8888;
  font-size: 12px;
  margin-top: 5px;
  display: none;
}
.td-form-group .td-error.active {
  display: block;
}
form .td-error.active {
  display: block;
}

.td-form-group small {
  font-size: 11px;
  color: #888;
  margin-top: 5px;
  font-style: italic;
}
.td-checkbox {
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  color: #000;
}
.td-checkbox a {
  color: #ff8888;
  text-decoration: none;
}

.td-btn-submit {
  background: #333;
  color: #fff;
  padding: 15px 30px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  width: fit-content;
  margin-top: 10px;
}

.td-vehicle-card {
  background: #fdfdfd;
  border: 1px solid #eee;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
  padding: 30px;
  text-align: left;
}
.td-vehicle-card img {
  width: 100%;
  border-radius: 4px;
  margin-bottom: 20px;
}
.td-vehicle-card h3 {
  font-size: 24px;
  font-weight: 900;
  margin-top: 0;
  margin-bottom: 15px;
}
.td-vehicle-card p {
  font-size: 14px;
  color: #555;
  line-height: 1.6;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .vehicle-archive-container,
  .vehicle-single-container {
    flex-direction: column;
  }

  /* Mobile Filter Rules */
  .mobile-filter-toggle {
    display: flex;
  }
  .vehicle-sidebar {
    display: none; /* Hidden by default on mobile */
    width: 100%;
  }
  .vehicle-sidebar.mobile-open {
    display: block; /* Toggled via JS */
  }

  /* Mobile Single Vehicle Order Refactoring */
  .vehicle-single-left,
  .vehicle-single-right {
    display: contents; /* Unpack wrappers to allow flex-order flat sorting */
  }
  .vehicle-single-container {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 20px;
    margin: 20px auto;
  }
  .vehicle-main-image {
    order: 1;
  }
  .vehicle-gallery-wrapper {
    order: 2;
    margin-bottom: 20px !important;
  }

  .vehicle-single-title {
    order: 3;
    margin-top: 10px;
  }
  .vehicle-single-specs {
    order: 4;
  }
  .stock-status {
    order: 5;
  }
  .vehicle-buy-box {
    order: 6;
  }

  .vehicle-specs-table {
    order: 7;
  }
  .vehicle-finance-options {
    order: 8;
  }
  .vehicle-dealer-info {
    order: 9;
  }

  .vehicle-content-full {
    order: 10;
    margin-top: 20px;
  }

  /* Archive Header Layout */
  .vehicle-main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  .vehicle-count-display {
    font-size: 20px;
  }

  /* Offcanvas Responsive */
  .test-drive-offcanvas {
    width: 100vw;
  }
  .test-drive-content {
    flex-direction: column;
    padding: 20px;
  }
  .test-drive-vehicle-area {
    flex: auto;
    width: 100%;
    order: -1;
    margin-bottom: 30px;
  }
  .td-form-row {
    flex-direction: column;
    gap: 20px;
  }
  .test-drive-header {
    padding: 15px 20px;
  }

  .vehicle-main {
    width: 100%;
  }
  .vehicle-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 600px) {
  .vehicle-grid {
    grid-template-columns: 1fr;
  }
}
