/**
 * Ozzyglenn WC Distance Sales Agreement Frontend Styles
 * ------------------------------------------------------
 * Includes styles for the agreement display on checkout and the modal popup.
 * Uses 'owcdsa-' prefix for selectors.
 */

/* == Agreement Display on Checkout == */

#owcdsa-wrapper { /* Updated ID */
    margin-top: 2em;
    margin-bottom: 1.5em;
    padding-top: 1em;
    border-top: 1px solid #e0e0e0;
}

#owcdsa-wrapper h2 {
    margin-bottom: 0.8em;
    font-size: 1.5em; /* Make title slightly larger */
}

.owcdsa-agreement-section { /* Updated class */
    width: 100% !important; /* Keep important if needed for theme overrides */
    margin-bottom: 15px; /* Slightly reduce margin */
    clear: both;
}

.owcdsa-agreement-section h4 {
    margin-bottom: 0.5em;
    font-size: 1.1em;
    font-weight: 600; /* Slightly bolder */
}

.owcdsa-agreement-section h4 a.owcdsa-open-modal { /* Updated class */
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-bottom: 1px dotted #888;
    transition: color 0.2s ease, border-bottom-color 0.2s ease; /* Smooth transition */
}
.owcdsa-agreement-section h4 a.owcdsa-open-modal:hover {
    color: #0073aa; /* Standard WP blue */
    border-bottom-style: solid;
    border-bottom-color: #0073aa;
}

/* Hidden content area on checkout (shown in modal) */
.owcdsa-agreement-content { /* Updated class */
    display: none; /* Content is hidden until modal opens */
}


/* Acceptance Checkbox Area */
p.form-row.owcdsa-acceptance-checkbox { /* Updated class */
    margin-top: 1.5em;
    padding-top: 1.5em; /* Match margin */
    border-top: 1px solid #e0e0e0;
    /* Using flex for better alignment, allow wrapping on small screens */
    display: flex;
    align-items: flex-start; /* Align items to the top */
    flex-wrap: wrap; /* Allow wrap */
    gap: 0.5em; /* Gap between checkbox and label */
}
p.form-row.owcdsa-acceptance-checkbox label.checkbox {
    display: inline; /* Let it flow naturally */
    margin-bottom: 0;
    cursor: pointer;
    flex-grow: 1; /* Allow label to take available space */
    order: 2; /* Put label after checkbox visually */
}
p.form-row.owcdsa-acceptance-checkbox input.input-checkbox {
    margin: 0.2em 0 0 0 !important; /* Adjust top margin for alignment */
    flex-shrink: 0; /* Prevent checkbox from shrinking */
    order: 1; /* Put checkbox first visually */
}
p.form-row.owcdsa-acceptance-checkbox label.checkbox span.required {
    margin-left: 0.3em;
    color: red; /* Make required indicator more obvious */
    font-weight: bold;
}


/* == Product Table Base Styles (Used in Shortcodes) == */
.owcdsa-product-table { /* Updated class */
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    border: 1px solid #e0e0e0; /* Lighter border */
    font-size: 0.95em; /* Slightly smaller font */
}
.owcdsa-product-table th {
    background-color: #f7f7f7; /* Lighter background */
    padding: 8px 12px;
    text-align: left;
    border: 1px solid #e0e0e0;
    font-weight: 600; /* Slightly bolder */
    color: #444;
}
.owcdsa-product-table td {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    vertical-align: middle; /* Better alignment */
    line-height: 1.5;
}
.owcdsa-product-table td:last-child {
    text-align: right; /* Align price column right */
}
.owcdsa-product-table td:nth-child(2) { /* Quantity column */
    text-align: center;
    width: 80px; /* Keep fixed width */
}


/* == Modal Styles == */
#owcdsa_modal { /* Updated ID */
  display: none; /* Hidden by default */
  position: fixed;
  z-index: 10001; /* Ensure it's above most elements, including WC notices */
  left: 0; top: 0; width: 100%; height: 100%;
  overflow: auto; /* Enable scroll if needed */
  background-color: rgba(0,0,0,0.65); /* Slightly darker overlay */
}
#owcdsa_modal > div.owcdsa-modal-content-box { /* Updated class */
  background-color: #ffffff;
  margin: 8% auto; /* Adjust vertical margin */
  padding: 30px; /* More padding */
  border: none; /* Remove border, rely on shadow */
  border-radius: 6px; /* Slightly larger radius */
  width: 85%;
  max-width: 800px; /* Slightly wider max-width */
  position: relative;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35); /* Stronger shadow */
  box-sizing: border-box;
}
#owcdsa_modal .owcdsa-modal-title { /* Updated class */
    margin-top: 0; margin-bottom: 20px; padding-bottom: 15px;
    border-bottom: 1px solid #eee; font-size: 1.5em; color: #333; /* Larger title */
    font-weight: 600;
}
#owcdsa_modal .owcdsa-modal-content-area { /* Updated class */
    max-height: 65vh; /* Max height relative to viewport */
    overflow-y: auto; /* Scroll only if needed */
    padding-right: 15px; /* Space for scrollbar */
    line-height: 1.65; /* More line spacing */
    font-size: 1em;
    color: #444;
}
/* Style links inside modal content */
#owcdsa_modal .owcdsa-modal-content-area a {
    color: #0073aa;
    text-decoration: underline;
}
#owcdsa_modal .owcdsa-modal-content-area a:hover {
    color: #005a87;
}
/* Style tables inside modal */
#owcdsa_modal .owcdsa-modal-content-area .owcdsa-product-table {
    margin: 1.5em 0; /* More margin around tables */
}

#owcdsa_modal button.owcdsa-close-modal { /* Updated class */
  position: absolute; top: 12px; right: 15px; color: #999; /* Slightly darker */
  font-size: 30px; font-weight: bold; line-height: 1;
  padding: 0; background: none; border: none; cursor: pointer;
  transition: color 0.2s ease;
}
#owcdsa_modal button.owcdsa-close-modal:hover,
#owcdsa_modal button.owcdsa-close-modal:focus {
  color: #000; text-decoration: none; outline: none;
}

/* == Responsive Adjustments == */
@media screen and (max-width: 768px) {
  #owcdsa_modal > div.owcdsa-modal-content-box { /* Updated class */
      width: 92%; margin: 5% auto; padding: 20px;
  }
  #owcdsa_modal .owcdsa-modal-title { /* Updated class */
      font-size: 1.3em; margin-bottom: 15px; padding-bottom: 10px;
  }
  #owcdsa_modal .owcdsa-modal-content-area { /* Updated class */
      max-height: 75vh; font-size: 0.95em;
  }
  #owcdsa_modal button.owcdsa-close-modal { /* Updated class */
      font-size: 28px; top: 8px; right: 12px;
  }
}

/* == Fix for WC Block Theme Checkbox Alignment (May need adjustment based on theme) == */
.woocommerce-checkout p.form-row.owcdsa-acceptance-checkbox { /* Updated class */
    /* Re-apply flex rules from above to ensure consistency */
    display: flex; align-items: flex-start; flex-wrap: nowrap; gap: 0.5em;
}
.woocommerce-checkout p.form-row.owcdsa-acceptance-checkbox .woocommerce-input-wrapper { display: contents; } /* Helps with some block themes */
.woocommerce-checkout p.form-row.owcdsa-acceptance-checkbox label.checkbox { order: 2; flex-grow: 1; }
.woocommerce-checkout p.form-row.owcdsa-acceptance-checkbox input[type="checkbox"] { order: 1; flex-shrink: 0; margin: 0.2em 0 0 0 !important; }


/* Ensure placeholder spans generated by shortcodes are inline */
span[class^="owcdsa-"] { /* Updated prefix */
    display: inline;
}

/* Debug highlight classes (optional - remove for production) */
.owcdsa-debug-highlight-green { /* Updated class */
    background-color: rgba(0, 255, 0, 0.15) !important;
    outline: 1px solid green !important;
    padding: 0 2px !important;
    display: inline !important; /* Ensure inline */
}
.owcdsa-debug-highlight-red { /* Updated class */
    background-color: rgba(255, 0, 0, 0.15) !important;
    outline: 1px solid red !important;
    padding: 0 2px !important;
     display: inline !important; /* Ensure inline */
}

/* Seller Info Block Styling (from PHP helper) */
.owcdsa-vendor-section h5 {
    margin-bottom: 5px !important;
    margin-top: 15px !important;
    font-size: 1.1em !important;
    border-bottom: 1px solid #eee !important;
    padding-bottom: 5px !important;
    font-weight: 600 !important;
}
.owcdsa-vendor-section > div:first-of-type { /* Target the info div */
    margin: 0 0 15px 0 !important;
    padding-left: 10px !important;
    border-left: 3px solid #0073aa !important;
    font-size: 0.95em !important;
    line-height: 1.7 !important;
}
.owcdsa-vendor-section > div:first-of-type strong {
    font-weight: 600;
}