/* =======================================================================
   Variables & General Options
   [OPTIMIZED] Dynamic variables are now injected via PHP
   ======================================================================= */
:root {
  /* Static Design Tokens (Never change) */
  --oso-ink:     #1f2937;   /* Primary Text */
  --oso-muted:   #6b7280;   /* Secondary Text */
  --oso-line:    #e5e7eb;   /* Borders/Separators */
  --oso-soft:    #f8fafc;   /* Soft Backgrounds */
  --oso-card:    #ffffff;   /* Card Background */
  --oso-shadow:  0 10px 22px rgba(0,0,0,.06);

  /* Shipping Statuses (Static) */
  --oso-free-bg: #ecfdf5;  --oso-free-bd: #a7f3d0;  --oso-free-fg: #065f46;
  --oso-paid-bg: var(--oso-soft); --oso-paid-bd: var(--oso-line); --oso-paid-fg: var(--oso-ink);
  --oso-pending-bg: #f3f4f6; --oso-pending-bd: #e5e7eb; --oso-pending-fg: #6b7280;
  
  /* Master Height Variable for Perfect Alignment */
  --oso-h: 52px;
  
  /* Dynamic Variables (Set by PHP from settings) */
  /* These will be overridden by inline CSS in assets.php:
     --oso-accent, --oso-accent-hover, --oso-btn-text, --oso-btn-radius,
     --oso-field-height, --oso-field-radius, --oso-field-border, --oso-field-focus,
     --oso-container-radius, --oso-title-color, --oso-title-size, etc. */
}

/* Utility: Force Hide */
.oso-hidden { display: none !important; }


/* =======================================================================
   Universal Layout Enforcer (Isolation & Full Width)
   ======================================================================= */
.oso-universal-wrapper,
.oso-independent-form {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 100% !important;
  clear: both !important;
  float: none !important;
  flex: 0 0 100% !important;
  box-sizing: border-box !important;
  margin-top: 10px !important;
  margin-bottom: 10px !important;
}

/* Unified Card Container */
.oso-order-card {
  display: block !important;
  width: 100% !important;
  box-sizing: border-box !important;
  background: var(--oso-card);
  border: 1px solid var(--oso-line);
  border-radius: var(--oso-container-radius, 12px);
  box-shadow: var(--oso-shadow);
  overflow: hidden; 
}

/* Inner Box (Fields Area) */
.oso-quick-box {
  width: 100% !important;
  display: block !important;
  margin: 0 !important;
  padding: 20px !important; 
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  box-sizing: border-box;
}

/* =======================================================================
   Unified Field Heights & Sizes
   ======================================================================= */
.oso-note {
  margin: 0 0 15px;
  text-align: var(--oso-title-align, center);
  font-weight: 700;
  color: var(--oso-title-color, var(--oso-ink));
  font-size: var(--oso-title-size, 15px);
}

.oso-field {
  display: block !important;
  width: 100% !important;
  height: var(--oso-field-height, 50px) !important;        
  min-height: var(--oso-field-height, 50px) !important;    
  margin: 0 0 12px 0 !important; 
  padding: 0 14px !important;    
  
  background: #fff !important;
  color: var(--oso-ink) !important;
  border: 1px solid var(--oso-field-border, var(--oso-line)) !important;
  border-radius: var(--oso-field-radius, 8px) !important;
  text-align: var(--oso-field-align, right) !important;
  
  font-size: 14px !important;
  line-height: normal !important; 
  outline: 0;
  box-sizing: border-box !important;
  transition: border-color .15s, box-shadow .15s;
  
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
}

select.oso-field {
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236b7280%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px top 50% !important;
  background-size: 10px auto !important;
  padding-right: 30px !important;
}

.oso-field::placeholder { color: #9ca3af; opacity: 1; }

.oso-field:focus {
  border-color: var(--oso-field-focus, var(--oso-accent)) !important;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--oso-field-focus, var(--oso-accent)) 18%, transparent) !important;
}

.oso-independent-form input[name="oso_phone"] { 
    text-align: left; direction: ltr; 
}


/* =======================================================================
   [DEFENSIVE LAYOUT] FLEXBOX ACTION GRID 
   Replaces CSS Grid to avoid Divi pseudo-element conflicts.
   ======================================================================= */
.oso-actions-grid {
    display: flex !important;
    flex-wrap: nowrap !important; /* Forces single row */
    align-items: stretch !important;
    gap: 12px !important;
    margin-top: 15px !important;
    
    width: 100% !important; 
    box-sizing: border-box !important;
    float: none !important;
    clear: both !important;
    
    height: var(--oso-h) !important; 
    min-height: var(--oso-h) !important;
    max-height: var(--oso-h) !important;
}

/* Ensure Divi's pseudo-elements don't mess up Flex count */
.oso-actions-grid::before,
.oso-actions-grid::after {
    display: none !important;
    content: none !important;
    flex-basis: 0 !important;
    width: 0 !important;
}

/* Single Column when Qty Hidden */
.oso-actions-grid.oso-no-qty {
    display: block !important;
}
.oso-actions-grid.oso-no-qty .oso-col-btn {
    width: 100% !important;
    display: block !important;
}


/* --- Column 1: Quantity Wrapper --- */
.oso-col-qty {
    flex: 0 0 135px !important; /* Fixed width, won't shrink/grow */
    width: 135px !important;
    max-width: 135px !important;
    
    height: 100% !important; 
    display: block !important;
    padding: 0 !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* --- Column 2: Button Wrapper --- */
.oso-col-btn {
    flex: 1 1 auto !important; /* Takes remaining space */
    width: auto !important;
    min-width: 0 !important; /* Firefox flex fix */
    
    display: flex !important;        
    flex-direction: column !important;
    justify-content: stretch !important;
    align-items: stretch !important;
    
    height: 100% !important; 
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    box-sizing: border-box !important;
}


/* --- Internal Elements --- */

/* QUANTITY "CAPSULE" DESIGN */
.oso-qty-ctrl {
    display: flex !important; 
    align-items: center !important; 
    justify-content: space-between !important;
    width: 100% !important; 
    height: 100% !important; 
    min-height: 100% !important;
    
    border: 1px solid var(--oso-line) !important;
    border-radius: var(--oso-btn-radius, 99px) !important; 
    background-color: #ffffff !important;
    overflow: hidden !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.oso-qty-btn {
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    border: none !important;
    background-color: #f3f4f6 !important; 
    color: var(--oso-ink) !important;
    
    width: 44px !important; 
    height: 100% !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    transition: background-color 0.2s, transform 0.05s !important;
}

.oso-qty-btn:hover { background-color: #e5e7eb !important; color: #000000 !important; }
.oso-qty-btn:active { transform: scale(0.92) !important; }
.oso-qty-btn svg { pointer-events: none; width: 14px !important; height: 14px !important; stroke: currentColor !important; fill: none !important; }
.oso-qty-btn:focus, .oso-qty-btn:active { outline: none !important; box-shadow: none !important; border: none !important; }

.oso-qty-input {
    width: 100% !important;
    height: 100% !important;
    border: none !important;
    background: transparent !important;
    text-align: center !important;
    padding: 0 !important;
    margin: 0 !important;
    font-weight: 700 !important;
    font-size: 17px !important;
    color: var(--oso-ink) !important;
    -moz-appearance: textfield;
}
.oso-qty-input:focus { outline: none !important; box-shadow: none !important; border: none !important; background: transparent !important; }
.oso-qty-input::-webkit-outer-spin-button, .oso-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }


/* [UNIVERSAL FIX] THE BUTTON */
.oso-submit {
    /* 1. Force Full Layout */
    width: 100% !important;
    height: 100% !important; 
    min-height: 100% !important;
    max-height: 100% !important;
    
    /* 2. Strip Theme Styles */
    max-width: 100% !important;
    min-width: 100% !important; 
    margin: 0 !important;
    padding: 0 !important; 
    border: 0 !important; 
    
    /* 3. Style It Using Variables */
    border-radius: var(--oso-btn-radius, 8px) !important; 
    background: var(--oso-accent) !important; 
    color: var(--oso-btn-text, #fff) !important;
    font-weight: 800 !important; 
    font-size: 17px !important; 
    line-height: 1 !important;
    box-sizing: border-box !important;
    
    /* 4. Flex Center */
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important;
    
    box-shadow: 0 4px 12px color-mix(in srgb, var(--oso-accent) 25%, transparent) !important;
    cursor: pointer;
    text-transform: none !important; 
    white-space: nowrap !important;
    
    /* 5. Kill Divi Floats & Positioning */
    float: none !important;
    position: static !important;
    outline: none !important;
}

/* ===========================
   Button Animations & States
   =========================== */

/* Add transition for smooth animations */
.oso-submit {
    transition: all 0.2s ease !important;
}

/* Hover State: Scale + Shadow + Color Change */
.oso-submit:hover {
    transform: scale(1.015) !important;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--oso-accent) 35%, transparent) !important;
    background: var(--oso-accent-hover, var(--oso-accent)) !important;
    filter: brightness(1) !important;
}

/* Active/Click State: Push Down Effect */
.oso-submit:active {
    transform: scale(0.98) !important;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--oso-accent) 20%, transparent) !important;
    filter: brightness(0.95) !important;
}

/* Disabled State (Enhanced) */
.oso-submit:disabled, 
.oso-submit.disabled,
.oso-submit.oso-loading {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    box-shadow: none !important;
    pointer-events: none !important;
    transform: scale(1) !important;
}

/* Button Icon Layout */
.oso-submit {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}

.oso-button-icon {
    width: var(--oso-icon-size, 20px) !important;
    height: var(--oso-icon-size, 20px) !important;
    stroke: currentColor !important;
    fill: none !important;
    flex-shrink: 0 !important;
}

/* Loading Spinner (when button is submitting) */
.oso-loading-spinner {
    display: inline-block !important;
    width: 16px !important;
    height: 16px !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-top-color: #fff !important;
    border-radius: 50% !important;
    animation: oso-spin 0.6s linear infinite !important;
    flex-shrink: 0 !important;
}

@keyframes oso-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hide original button content when loading */
.oso-submit.oso-loading .oso-button-icon,
.oso-submit.oso-loading .oso-button-text {
    opacity: 0 !important;
    width: 0 !important;
    overflow: hidden !important;
}


/* =======================================================================
   "Order Summary" Box
   ======================================================================= */
.oso-summary {
  margin: 0 !important; 
  background: transparent !important;
  direction: var(--oso-sum-dir, ltr) !important;
  text-align: var(--oso-sum-align, left) !important; 
  border: none !important; 
  border-radius: 0 !important;
  box-shadow: none !important; 
  overflow: hidden;
  width: 100% !important;
}

.oso-sum-head {
  position: relative;
  display: flex; align-items: center; gap: 8px;
  justify-content: flex-start;
  padding: 12px 14px;
  padding-inline-start: 42px;  
  padding-inline-end: 14px;
  font-weight: 700;
  color: var(--oso-sum-head-color, var(--oso-ink));
  font-size: var(--oso-sum-head-size, 14px);
  border-top: 1px solid var(--oso-line) !important; 
  border-bottom: 1px solid var(--oso-line);
  background: var(--oso-sum-head-bg, linear-gradient(to left, var(--oso-soft), #fff));
  user-select: none; cursor: pointer;
  min-height: 44px;
  line-height: 1.4;
}

.oso-icon.oso-cart {
  position: absolute;
  inset-inline-start: 10px;
  top: 50%; transform: translateY(-50%);
  width: 24px; height: 24px; border-radius: 6px;
  background: #fff;
  border: 1px solid #e5e7eb;
  color: #0b66ff;
  display: flex; align-items: center; justify-content: center;
}

.oso-icon.oso-chevron {
  position: absolute;
  inset-inline-end: 14px;
  top: 50%; transform: translateY(-50%);
  color: var(--oso-muted);
  transition: transform .2s ease;
}
.oso-summary.is-collapsed .oso-icon.oso-chevron svg { transform: translateY(0) rotate(180deg); }

.oso-sum-head .oso-title {
  margin: 0 !important;
  font-weight: 700;
  color: inherit;
  font-size: inherit;
  flex: 1 1 auto; max-width: 65%;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}

.oso-sum-body {
  overflow: hidden;
  max-height: 1000px;
  opacity: 1;
  transition: max-height .25s ease, opacity .2s ease;
}
.oso-summary.is-collapsed .oso-sum-body { max-height: 0; opacity: 0; pointer-events: none; }

.oso-sum-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px dashed var(--oso-line);
  font-size: 14px;
}
.oso-sum-row:first-of-type { border-top: 0; }

.oso-sum-label { color: var(--oso-muted); font-weight: 400; }
.oso-sum-value { font-weight: 600; color: var(--oso-ink); text-align: right; }

/* Price Row (First Child) */
.oso-sum-row:first-child .oso-sum-label { color: var(--oso-price-label-color, var(--oso-muted)); }
.oso-sum-row:first-child .oso-sum-value { color: var(--oso-price-value-color, var(--oso-ink)); }

/* Shipping Row (Second Child) */
.oso-sum-row:nth-child(2) .oso-sum-label { color: var(--oso-ship-label-color, var(--oso-muted)); }
.oso-sum-row:nth-child(2) .oso-sum-value .oso-ship:not(.is-free) { color: var(--oso-ship-value-color, var(--oso-ink)); }

/* Total Row (Last Child) */
.oso-sum-total { background-color: #fcfcfc; }
.oso-sum-total .oso-sum-label { font-weight: 800; color: var(--oso-total-label-color, var(--oso-ink)); }
.oso-sum-total .oso-sum-value { font-weight: 800; font-size: 16px; color: var(--oso-total-value-color, var(--oso-ink)); }

.oso-qty-badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 1.15rem; min-width: 1.15rem; padding: 0 .4rem;
  border-radius: 99px;
  background: var(--oso-qty-badge-bg, var(--oso-badge-bg)); 
  color: var(--oso-qty-badge-text, #ffffff);
  font-weight: 700; font-size: 11px;
  margin: 0 4px; 
}

.oso-ship {
  display: inline-block;
  padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 600;
  background: var(--oso-paid-bg); border: 1px solid var(--oso-paid-bd); color: var(--oso-paid-fg);
}
.oso-ship.is-free { 
  background: var(--oso-ship-free-bg, var(--oso-free-bg)); 
  border-color: var(--oso-ship-free-border, var(--oso-free-bd)); 
  color: var(--oso-ship-free-text, var(--oso-free-fg));
  font-size: var(--oso-ship-free-size, 12px);
}
.oso-ship.is-error { background: #fee2e2; border-color: #fca5a5; color: #b91c1c; }

/* Mobile */
@media (max-width: 480px) {
  .oso-actions-grid { grid-template-columns: 110px 1fr !important; gap: 10px !important; }
}