/**
 * Ava Pricing Table Styles
 * -- FULLY REBUILT & ENHANCED VERSION --
 * Includes RTL support.
 */

:root {
  --pt-brand-color: #6a5acd; /* Purple */
  --pt-highlight-color: #0073aa; /* Blue */
  --pt-success-color: #28a745; /* Green */
  --pt-danger-color: #dc3545; /* Red */
  --pt-disabled-color: #a0a5aa; /* Gray */
  --pt-text-color: #3c434a;
  --pt-light-text-color: #646970;
  --pt-border-color: #e0e0e0;
}

.ava-pricing-group-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 30px;
  margin: 2em 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  align-items: start;
}

.ava-pricing-table {
  position: relative;
  border: 1px solid var(--pt-border-color);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  text-align: center;
  background: #fff;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s, box-shadow 0.3s;
  overflow: hidden;
}

.ava-pricing-table:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.ava-pricing-table--highlighted {
  border: 2px solid var(--pt-highlight-color);
}

/* --- Header --- */
.ava-pricing-table__header {
  padding: 30px 20px;
}

.ava-pricing-table__icon {
  font-size: 2.5em;
  color: var(--pt-brand-color);
  margin-bottom: 15px;
  line-height: 1;
}

.ava-pricing-table__title {
  font-size: 1.6em;
  font-weight: 600;
  margin: 0 0 8px;
  color: var(--pt-text-color);
}

.ava-pricing-table__subtitle {
  font-size: 0.95em;
  color: var(--pt-light-text-color);
  margin: 0;
}

/* --- Price --- */
.ava-pricing-table__price {
  background-color: var(--pt-brand-color);
  color: #fff;
  padding: 25px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.ava-pricing-table__price-currency {
  font-size: 1.5em;
  font-weight: 500;
  align-self: flex-start;
  margin-top: 5px;
}

.ava-pricing-table__price-major {
  font-size: 4em;
  font-weight: 700;
  margin: 0 2px;
}

.ava-pricing-table__price-minor {
  font-size: 1.5em;
  font-weight: 500;
  align-self: flex-start;
  margin-top: 5px;
}

.ava-pricing-table__price-period {
  font-size: 1em;
  font-weight: 400;
  align-self: flex-end;
  margin-left: 8px;
}

/* --- Features --- */
.ava-pricing-table__features {
  padding: 20px 30px;
  flex-grow: 1;
}

.ava-pricing-table__features ul {
  list-style: none;
  padding: 0;
  margin: 0;
  text-align: left;
}

.ava-pricing-table__features li {
  padding: 12px 0;
  border-top: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  color: var(--pt-text-color);
  position: relative; /* <-- add this line */
}

.ava-pricing-table__features li:first-child {
  border-top: none;
}

.ava-pricing-table__features li::before {
  font-weight: bold;
  font-family: "dashicons";
  margin-right: 12px;
  font-size: 1.2em;
}

/* Feature Statuses */
.ava-pricing-table__features li.feature--enabled {
  color: var(--pt-text-color);
}
.ava-pricing-table__features li.feature--enabled::before {
  content: "\f147"; /* Dashicon checkmark */
  color: var(--pt-success-color);
}

.ava-pricing-table__features li.feature--strikethrough {
  color: var(--pt-text-color);
}
.ava-pricing-table__features li.feature--strikethrough .feature-text {
  text-decoration: line-through;
  opacity: 0.7;
}
.ava-pricing-table__features li.feature--strikethrough::before {
  content: "\f147"; /* Dashicon checkmark */
  color: var(--pt-success-color);
}

.ava-pricing-table__features li.feature--disabled {
  color: var(--pt-disabled-color);
  text-decoration: line-through;
}
.ava-pricing-table__features li.feature--disabled::before {
  content: "\f158"; /* Dashicon no/cross */
  color: var(--pt-danger-color);
}

/**
 * Ava Pricing Table Tooltip Styles -- CORRECTED VERSION
 */

/* Step 1: Set the positioning context on the list item */
.ava-pricing-table__features li {
  position: relative; /* This is the MOST IMPORTANT FIX */
}

/* Step 2: Basic tooltip wrapper styles */
.feature-tooltip {
  display: inline-flex; /* Use flex for better alignment */
  align-items: center;
  margin-left: 8px;
  cursor: help;
}

.tooltip-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: #ccc;
  color: #fff;
  font-size: 12px;
  font-weight: bold;
}

/* Step 3: Tooltip content box with proper centering */
.tooltip-content {
  visibility: hidden;
  width: 220px;
  background-color: rgba(0, 0, 0, 0.85);
  color: #fff;
  text-align: left;
  border-radius: 6px;
  padding: 10px 12px;
  position: absolute;
  z-index: 10;

  /* --- The Universal Centering Solution --- */
  bottom: 100%; /* Position above the feature line */
  left: 50%; /* Start from the horizontal center of the li */
  transform: translateX(
    -50%
  ); /* Pull back by half of its own width to be perfectly centered */
  margin-bottom: 8px;
  /* --- End of Solution --- */

  opacity: 0;
  transition: opacity 0.3s, visibility 0.3s;
  font-size: 0.85em;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  white-space: normal;
  overflow-wrap: break-word;
}

.feature-tooltip:hover .tooltip-content {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* The small arrow below the tooltip */
.tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.85) transparent transparent transparent;
}

/* Step 4: RTL specific adjustments */
.rtl .feature-tooltip {
  margin-left: 0;
  margin-right: 8px;
}
/* No RTL rule is needed for .tooltip-content anymore because the centering logic is universal */

/* --- Footer --- */
.ava-pricing-table__footer {
  padding: 30px;
  background: #fcfcfc;
  border-top: 1px solid #f0f0f0;
  margin-top: auto;
}

.ava-pricing-table__footer .button {
  width: 100%;
  padding: 15px !important;
  font-size: 1.1em !important;
  font-weight: 600 !important;
}

.ava-pricing-table__footer-text {
  margin: 15px 0 0;
  font-size: 0.85em;
  color: var(--pt-light-text-color);
}

/* --- Ribbon --- */
.ava-pricing-table__ribbon {
  position: absolute;
  top: 0; /* More precise position than above */
  right: 0; /* More precise position than right */
  width: 100px; /* Reduce width */
  height: 100px; /* Reduce height */
  overflow: hidden;
  z-index: 2; /* Make sure it goes on the header */
}
.ava-pricing-table__ribbon span {
  position: absolute;
  display: block;
  width: 150px; /* Reduce width to prevent clipping */
  padding: 8px 0; /* Reduce padding */
  background-color: var(--pt-danger-color);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1); /* Smaller shadow */
  color: #fff;
  font-size: 0.9em; /* Slightly smaller font */
  font-weight: bold;
  text-align: center;
  top: 15px; /* Slightly lower than the top */
  right: -35px; /* More precise position than right */
  transform: rotate(45deg); /* Just rotation */
  transform-origin: 50% 50%; /* Rotation from center */
}

/* --- RTL Styles --- */
/* Ribbon for RTL */
.rtl .ava-pricing-table__ribbon {
  right: auto;
  left: 0; /* Move to the left */
}
.rtl .ava-pricing-table__ribbon span {
  right: auto;
  left: -35px; /* More precise position than left */
  transform: rotate(-45deg); /* Reverse rotation for RTL */
}
