/* Comparison Card Block Styles */

/* Editor Preview Styles */
.ctm-card-block-preview {
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.ctm-card-block-header {
  background: #f0f0f1;
  padding: 10px 15px;
  font-weight: 600;
  border-bottom: 1px solid #ddd;
}

.ctm-card-block-header .dashicons {
  margin-right: 5px;
  color: #666;
}

.ctm-card-no-selection {
  padding: 20px;
  text-align: center;
  color: #666;
}

/* Card Grid */
.ctm-card-wrapper {
  margin: 1.5rem 0;
}

.ctm-card-unified {
  width: 100%;
  background-color: #fff;
  overflow-x: auto;
}

.ctm-card-header-row {
  background-color: #1e3a5f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ctm-card-header-row .ctm-header-cell {
  padding: 0.75rem 1rem;
}

.ctm-header-cell-image {
  width: 100px;
  text-align: center;
}

.ctm-header-cell-title {
  width: 200px;
}

.ctm-header-cell-rating {
  width: 90px;
}

.ctm-card-row {
  border-bottom: 1px solid #d1d5db;
  border-right: 1px solid #d1d5db;
  border-left: 1px solid #d1d5db;
  background-color: #fff;
}

.ctm-card-mobile-header {
  background-color: #1e3a5f;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  padding: 0.5rem 1rem;
}

.ctm-card-mobile-header-left {
  flex: 0 0 40%;
}

.ctm-card-mobile-header-right {
  flex: 1;
  padding-left: 1rem;
}

.ctm-card-body {
  display: flex;
  padding: 1rem;
  gap: 1rem;
}

.ctm-card-left {
  flex: 0 0 40%;
  max-width: 40%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ctm-card-right {
  flex: 1;
  font-size: 0.75rem;
}

.ctm-cell {
  padding: 0.5rem;
}

.ctm-cell-image {
  width: 100px;
  text-align: center;
}

.ctm-cell-title {
  width: 200px;
  text-align: left;
}

.ctm-cell-title .ctm-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.3;
}

.ctm-cell-title .ctm-desc {
  font-size: 0.75rem;
  margin-top: 0.25rem;
  line-height: 1.1;
}

.ctm-cell-rating {
  font-size: 0.75rem;
  text-align: left;
  width: 90px;
}

.ctm-cell-cta {
  text-align: center;
}

.ctm-detail-label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.125rem;
  font-size: 0.625rem;
}

.ctm-detail-value {
  color: #4b5563;
  line-height: 1.2;
}

.ctm-card-grid {
  display: grid;
  gap: 1rem;
}

/* Card Item */
.ctm-card-item {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  overflow: hidden;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s ease;
}

.ctm-card-item:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Card Header */
.ctm-card-header {
  background-color: #1e3a8a;
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ctm-card-header-left,
.ctm-card-header-right {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Card Body */
.ctm-card-body {
  display: flex;
  padding: 1rem;
  gap: 1rem;
}

/* Card Left Column */
.ctm-card-left {
  flex: 0 0 40%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.ctm-card-image {
  margin-bottom: 0.75rem;
}

.ctm-card-image img {
  max-width: 100%;
  max-height: 120px;
  height: auto;
  object-fit: contain;
}

.ctm-card-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: #1e40af;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.ctm-card-title a {
  color: #1e40af;
  text-decoration: none;
}

.ctm-card-title a:hover {
  text-decoration: underline;
}

.ctm-card-description {
  font-size: 0.75rem;
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.ctm-card-cta {
  margin-top: auto;
}

.ctm-card-cta a:not(.ctm-button-anchor) {
  display: inline-block;
  background-color: #16a34a;
  color: #fff;
  padding: 0.5rem 1.25rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.ctm-card-cta a:not(.ctm-button-anchor):hover {
  background-color: #15803d;
}

/* Card Right Column */
.ctm-card-right {
  flex: 1;
  font-size: 0.75rem;
}

.ctm-card-rating {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
}

.ctm-card-rating img {
  max-height: 1.5rem;
  width: auto;
}

/* Card Details */
.ctm-card-details {
  /* Container for detail items */
}

.ctm-card-detail-item {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e5e7eb;
}

.ctm-card-detail-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.ctm-card-detail-label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 0.125rem;
}

.ctm-card-detail-value {
  color: #4b5563;
  line-height: 1.4;
}

.ctm-card-detail-value p {
  margin: 0;
}

.ctm-card-detail-value ul,
.ctm-card-detail-value ol {
  margin: 0;
  padding-left: 1.25em;
}

/* Responsive adjustments */
@media (max-width: 640px) {
  .ctm-card-body {
    flex-direction: column;
  }

  .ctm-card-left {
    flex: none;
    width: 100%;
  }

  .ctm-card-right {
    width: 100%;
  }
}

/* Inspector Controls */
.ctm-card-row-selection {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

/* Unified (PC/Mobile) layout styles for comparison-card */
.ctm-card-wrapper .ctm-card-unified p {
  margin: 0 !important;
  font-size: 0.75rem !important;
  line-height: 1.1rem !important;
}

.ctm-card-wrapper .ctm-cell-image {
  text-align: center !important;
}

.ctm-card-wrapper .ctm-card-image-wrapper {
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  width: 80px;
}

.ctm-card-wrapper .ctm-card-image-wrapper img {
  display: block;
  height: auto !important;
  margin-left: auto;
  margin-right: auto;
  max-width: 100% !important;
  object-fit: contain;
  width: 100% !important;
}

.ctm-card-wrapper .ctm-card-mobile-body {
  display: none;
}

/* PC layout */
@media (min-width: 769px) {
  .ctm-card-wrapper .ctm-card-header-row {
    display: grid;
    align-items: center;
    column-gap: 0 !important;
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
  }

  .ctm-card-wrapper.has-image.has-rating .ctm-card-header-row {
    grid-template-columns: 100px 200px 90px;
  }

  .ctm-card-wrapper.has-image:not(.has-rating) .ctm-card-header-row {
    grid-template-columns: 100px 200px;
  }

  .ctm-card-wrapper.no-image.has-rating .ctm-card-header-row {
    grid-template-columns: 200px 90px;
  }

  .ctm-card-wrapper.no-image:not(.has-rating) .ctm-card-header-row {
    grid-template-columns: 200px;
  }

  .ctm-card-wrapper .ctm-card-row {
    display: grid;
    align-items: center;
    column-gap: 0 !important;
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    overflow: visible;
    padding: 0 !important;
    background-color: #fff !important;
  }

  .ctm-card-wrapper.has-image.has-rating .ctm-card-row {
    grid-template-columns: 100px 200px 90px;
  }

  .ctm-card-wrapper.has-image:not(.has-rating) .ctm-card-row {
    grid-template-columns: 100px 200px;
  }

  .ctm-card-wrapper.no-image.has-rating .ctm-card-row {
    grid-template-columns: 200px 90px;
  }

  .ctm-card-wrapper.no-image:not(.has-rating) .ctm-card-row {
    grid-template-columns: 200px;
  }

  .ctm-card-wrapper .ctm-card-mobile-header {
    display: none !important;
  }

  .ctm-card-wrapper .ctm-card-body,
  .ctm-card-wrapper .ctm-card-left,
  .ctm-card-wrapper .ctm-card-right {
    display: contents !important;
  }

  .ctm-card-wrapper .ctm-card-header-row > div,
  .ctm-card-wrapper .ctm-card-row .ctm-cell {
    min-width: 0 !important;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .ctm-card-wrapper .ctm-card-left,
  .ctm-card-wrapper .ctm-card-right {
    flex: none !important;
    width: auto !important;
    max-width: none !important;
    min-width: 0 !important;
    text-align: initial !important;
    align-items: stretch !important;
  }

  .ctm-card-wrapper .ctm-cell-desc {
    display: none !important;
  }

  .ctm-card-wrapper .ctm-cell-detail .ctm-detail-label {
    display: none !important;
  }

  .ctm-card-wrapper .ctm-cell-detail .ctm-detail-value {
    color: #374151 !important;
    line-height: 1.1 !important;
    font-size: 0.75rem !important;
  }

  .ctm-card-wrapper .ctm-card-image-wrapper img {
    margin-bottom: 0 !important;
  }

  .ctm-card-wrapper .ctm-cell-image {
    order: 1;
  }

  .ctm-card-wrapper .ctm-cell-title {
    order: 2;
  }

  .ctm-card-wrapper .ctm-cell-rating {
    order: 3;
  }

  .ctm-card-wrapper .ctm-cell-detail {
    order: 4;
  }

  .ctm-card-wrapper .ctm-cell-cta {
    order: 5;
  }
}

/* Mobile layout */
@media (max-width: 768px) {
  .ctm-card-wrapper .ctm-card-header-row {
    display: none;
  }

  .ctm-card-wrapper .ctm-card-mobile-header {
    display: none !important;
  }

  .ctm-card-wrapper .ctm-card-row {
    display: block;
    margin-bottom: 0 !important;
    border-radius: 0 !important;
  }

  .ctm-card-wrapper .ctm-card-header-row + .ctm-card-row {
    border-top: 1px solid #d1d5db;
  }

  .ctm-card-wrapper br {
    display: none;
  }

  .ctm-card-wrapper .ctm-card-desktop-body {
    display: none !important;
  }

  .ctm-card-wrapper .ctm-card-mobile-body {
    display: block;
    padding: 1rem;
  }

  .ctm-card-wrapper .ctm-card-mobile-top {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
  }

  .ctm-card-wrapper .ctm-card-mobile-image {
    flex: 0 0 min(100px, 40%);
    max-width: min(100px, 40%);
    min-width: 0;
  }

  .ctm-card-wrapper .ctm-card-mobile-summary {
    flex: 1 1 auto;
    min-width: 0;
  }

  .ctm-card-wrapper .ctm-card-mobile-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.3;
    overflow-wrap: anywhere;
  }

  .ctm-card-wrapper .ctm-card-mobile-title p,
  .ctm-card-wrapper .ctm-card-mobile-description p {
    margin: 0 !important;
    font-size: inherit !important;
    line-height: inherit !important;
  }

  .ctm-card-wrapper .ctm-card-mobile-description {
    margin-top: 0.35rem;
    color: #4b5563;
    font-size: 0.75rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .ctm-card-wrapper .ctm-card-mobile-bottom {
    margin-top: 0.25rem;
    padding-top: 0.25rem;
  }

  .ctm-card-wrapper .ctm-card-mobile-details {
    color: #4b5563;
    font-size: 0.75rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
  }

  .ctm-card-wrapper .ctm-card-mobile-detail {
    display: inline;
  }

  .ctm-card-wrapper .ctm-card-mobile-detail:not(:last-child)::after {
    content: "｜";
    color: #9ca3af;
  }

  .ctm-card-wrapper .ctm-card-mobile-detail-label {
    color: #374151;
    font-weight: 600;
  }

  .ctm-card-wrapper .ctm-card-mobile-detail-value,
  .ctm-card-wrapper .ctm-card-mobile-detail-value p {
    display: inline;
    margin: 0 !important;
    font-size: inherit !important;
    line-height: inherit !important;
  }

  .ctm-card-wrapper .ctm-card-mobile-detail-value img {
    display: inline-block;
    width: auto !important;
    max-height: 1.5rem;
    vertical-align: middle;
  }

  .ctm-card-wrapper .ctm-card-mobile-cta {
    margin-top: 0.75rem;
    text-align: center;
  }

  .ctm-card-wrapper .ctm-card-mobile-cta .ctm-button-anchor,
  .ctm-card-wrapper .ctm-card-mobile-cta button {
    max-width: 100%;
  }

  .ctm-card-wrapper .ctm-card-image-wrapper {
    width: min(100px, 100%) !important;
  }

  .ctm-card-wrapper .ctm-card-image-wrapper img {
    max-height: none !important;
  }
}

.ctm-card-details-mapping {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #e0e0e0;
}

.ctm-card-details-mapping .components-select-control {
  flex: 1;
}
