/**
 * Frontend Styles for WC Session Forms
 * RTL-compatible for Hebrew
 * Matches product-addons-custom styling
 */

.wcsf-form-wrapper {
    direction: rtl;
    font-family: "RAG Sans", sans-serif;
    color: white;
    margin: 20px 0;
    width: 100%;
}

/* Ensure proper stacking with custom addons */
.wcsf-form-wrapper + .custom-addons-container {
    margin-top: 15px;
}

.custom-addons-container + .wcsf-form-wrapper {
    margin-top: 15px;
}

.wcsf-session-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Date Selection */
.wcsf-date-selection {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.wcsf-date-selection h4 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    font-weight: bold;
    text-align: right;
    color: white;
}

.wcsf-date-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wcsf-date-option {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.wcsf-date-option:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.wcsf-date-option input[type="radio"] {
    margin-left: 10px;
    margin-right: 0;
    cursor: pointer;
    accent-color: #9d5d2c;
}

.wcsf-date-option label {
    flex: 1;
    cursor: pointer;
    text-align: right;
    margin: 0;
    color: white;
}

/* Booking sections expand/collapse animation (1s) */
.wcsf-ticket-qty-slot,
.wcsf-sessions-selection,
.wcsf-total-price {
    overflow: hidden;
    transition: max-height 1s ease, opacity 1s ease;
}

.wcsf-ticket-qty-slot.wcsf-collapsed,
.wcsf-sessions-selection.wcsf-collapsed,
.wcsf-total-price.wcsf-collapsed {
    max-height: 0;
    opacity: 0;
}

.wcsf-ticket-qty-slot.wcsf-expanded,
.wcsf-total-price.wcsf-expanded {
    max-height: 200px;
    opacity: 1;
}

.wcsf-sessions-selection.wcsf-expanded {
    max-height: 1200px;
    opacity: 1;
}

/* Sessions Selection */
.wcsf-sessions-selection {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.wcsf-sessions-selection h4 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
    font-weight: bold;
    text-align: right;
    color: white;
}

.wcsf-sessions-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}

.wcsf-session-group {
    background-color: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 4px;
    width: 100%;
}

.wcsf-session-group h5 {
    margin: 0 0 10px 0;
    text-align: right;
    font-size: 1em;
    font-weight: bold;
    color: white;
}

.wcsf-times-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Min-height fits quantity wrapper (32px) + padding so container doesn't grow when selector appears */
.wcsf-time-slot {
    display: flex;
    flex-direction: row;
    align-items: center;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 3px;
    padding: 6px 8px;
    gap: 8px;
    min-height: 44px;
}

.wcsf-time-header {
    flex: 1;
    display: flex;
    align-items: center;
    padding: 0;
}

/* RTL: checkbox right, time left of it, ticket selector left. Use LTR in label so row-reverse = checkbox right */
.wcsf-time-header label {
    display: flex;
    align-items: center;
    flex-direction: row-reverse;
    direction: ltr;
    cursor: pointer;
    user-select: none;
    color: white;
    margin: 0;
    flex: 1;
    gap: 8px;
}

.wcsf-time-header input[type="checkbox"] {
    margin-left: 8px;
    margin-right: 0;
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: #9d5d2c;
    flex-shrink: 0;
}

.wcsf-time-text {
    flex: 0 1 auto;
    font-size: 0.95em;
    text-align: right;
}

.wcsf-time-controls {
    display: none; /* Hidden - we'll use inline version */
}

/* Inline quantity wrapper - shown when checked, pushed to left in RTL */
.wcsf-time-header .wcsf-quantity-wrapper {
    display: none;
    flex-shrink: 0;
    margin-right: auto; /* push to left (label is LTR so right = end) */
}

.wcsf-time-slot.is-checked .wcsf-time-header .wcsf-quantity-wrapper {
    display: flex;
}

.wcsf-right-actions {
    margin-top: 16px;
}

/* Quantity Wrapper */
.wcsf-quantity-wrapper {
    display: flex;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 32px;
    align-items: center;
    min-width: 100px;
}

.wcsf-qty-minus,
.wcsf-qty-plus {
    background-color: #9d5d2c !important;
    border: none;
    color: white;
    cursor: pointer;
    width: 35px;
    height: 100%;
    font-size: 1.4em;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
}

.wcsf-ticket-qty {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.wcsf-ticket-qty-label {
    font-weight: bold;
    text-align: right;
    margin-bottom: 10px;
    color: white;
}

.wcsf-ticket-qty-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    height: 45px;
    overflow: hidden;
}

.wcsf-ticket-plus,
.wcsf-ticket-minus,
.ticket-quantity-plus,
.ticket-quantity-minus,
.wva-plus,
.wva-minus {
    background-color: #9d5d2c !important;
    border: none !important;
    color: #fff !important;
    width: 45px !important;
    height: 100% !important;
    font-size: 1.4em !important;
    line-height: 1 !important;
    cursor: pointer !important;
}

.wcsf-ticket-plus:hover,
.wcsf-ticket-minus:hover,
.ticket-quantity-plus:hover,
.ticket-quantity-minus:hover,
.wva-plus:hover,
.wva-minus:hover {
    background-color: #7f4b22 !important;
}

.wcsf-ticket-value {
    flex: 1;
    text-align: center;
    font-weight: 800;
    color: #fff;
    font-size: 1.2em;
}

.wcsf-submit-button {
    background-color: #9d5d2c !important;
    border-color: #9d5d2c !important;
    color: #fff !important;
    padding: 14px 26px !important;
    border-radius: 6px !important;
    font-weight: 800 !important;
    letter-spacing: 1px;
    width: 100%;
    max-width: 520px;
}

.wcsf-submit-button:hover {
    background-color: #7f4b22 !important;
    border-color: #7f4b22 !important;
}

.wcsf-qty-minus:hover,
.wcsf-qty-plus:hover {
    background-color: #7f4b22 !important;
}

.wcsf-qty-minus:active,
.wcsf-qty-plus:active {
    background-color: rgba(255, 255, 255, 0.15);
}

.wcsf-qty-input {
    flex: 1;
    padding: 0 10px 0 0;
    font-weight: 800;
    height: 100%;
    text-align: center;
    border: none;
    background-color: transparent;
    color: white;
    font-family: "RAG Sans", sans-serif;
    font-size: 1em;
    -moz-appearance: textfield;
    appearance: textfield;
}

.wcsf-qty-input::-webkit-outer-spin-button,
.wcsf-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

/* Total Price Display */
.wcsf-total-price {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 15px;
    border-radius: 5px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
}

.wcsf-price-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #fff;
}

.wcsf-price-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 0.95em;
    text-align: right;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.wcsf-price-line span,
.wcsf-price-line .wcsf-base-price,
.wcsf-price-line .wcsf-sessions-total,
.wcsf-price-line .wcsf-total-amount {
    color: #fff !important;
}

.wcsf-price-line:last-child {
    border-bottom: none;
}

.wcsf-grand-total {
    font-size: 1.3em;
    font-weight: bold;
    padding: 12px 0 !important;
    border-top: 2px solid rgba(255, 255, 255, 0.3) !important;
    border-bottom: none !important;
    margin-top: 5px;
}

/* Validation Error */
.wcsf-validation-error {
    background-color: rgba(220, 53, 69, 0.2);
    border: 1px solid rgba(220, 53, 69, 0.5);
    color: #ffcccc;
    padding: 12px;
    border-radius: 4px;
    text-align: right;
    font-weight: 500;
}

/* Responsive Design - Tablet */
@media (max-width: 1024px) {
    .wcsf-sessions-container {
        grid-template-columns: 1fr 1fr;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 768px) {
    .wcsf-form-wrapper {
        margin: 15px 0;
    }

    .wcsf-date-selection,
    .wcsf-sessions-selection,
    .wcsf-total-price {
        padding: 12px;
        border-radius: 3px;
    }

    .wcsf-date-selection h4,
    .wcsf-sessions-selection h4 {
        font-size: 0.95em;
        margin-bottom: 10px;
    }

    .wcsf-sessions-container {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .wcsf-session-group {
        padding: 10px;
    }

    .wcsf-session-group h5 {
        font-size: 0.95em;
        margin-bottom: 8px;
    }

    .wcsf-time-slot {
        padding: 5px 6px;
        gap: 6px;
        min-height: 40px;
        margin-bottom: 8px;
    }

    .wcsf-time-header {
        padding: 0;
    }

    .wcsf-time-header label {
        font-size: 0.9em;
        gap: 6px;
    }

    .wcsf-time-header input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }

    .wcsf-quantity-wrapper {
        height: 30px;
        min-width: 90px;
    }

    .wcsf-qty-minus,
    .wcsf-qty-plus {
        width: 36px;
        font-size: 1.2em;
    }

    .wcsf-qty-input {
        font-size: 0.9em;
    }

    .wcsf-price-breakdown {
        gap: 6px;
    }

    .wcsf-price-line {
        font-size: 0.85em;
        padding: 6px 0;
    }

    .wcsf-grand-total {
        font-size: 1em;
        padding: 10px 0 !important;
    }

    .wcsf-validation-error {
        font-size: 0.9em;
        padding: 10px;
    }
}

/* Responsive Design - Small Mobile */
@media (max-width: 480px) {
    .wcsf-date-option {
        padding: 8px;
    }

    .wcsf-date-option label {
        font-size: 0.9em;
    }

    .wcsf-time-slot {
        padding: 4px 5px;
        gap: 5px;
        min-height: 36px;
    }

    .wcsf-time-header label {
        font-size: 0.85em;
        gap: 5px;
    }

    .wcsf-quantity-wrapper {
        height: 28px;
        min-width: 80px;
    }

    .wcsf-qty-minus,
    .wcsf-qty-plus {
        width: 28px;
        font-size: 1em;
    }

    .wcsf-price-line {
        font-size: 0.8em;
    }

    .wcsf-grand-total {
        font-size: 0.95em;
    }
}

/* Additional styles for integration with existing plugin */
.wcsf-form-wrapper + .custom-addons-container {
    margin-top: 20px;
}

/* Hide WooCommerce default elements when session form is active */
body.wcsf-has-session-form .woocommerce div.product form.cart .variations,
body.wcsf-has-session-form .woocommerce div.product form.cart .quantity,
body.wcsf-has-session-form .woocommerce-variation,
body.wcsf-has-session-form .woocommerce-variation-price,
body.wcsf-has-session-form .woocommerce-variation-description,
body.wcsf-has-session-form .woocommerce-variation-availability,
body.wcsf-has-session-form table.variations {
    display: none !important;
}

/* Hide Elementor/OceanWP add-to-cart qty UI (we render our own) */
body.wcsf-has-session-form .e-atc-qty-button-holder {
    display: none !important;
}

/* Hide the legacy total-price container from extras plugin when session form is active */
body.wcsf-has-session-form #total-price-container {
    display: none !important;
}

/* Hide legacy ticket quantity block when session form is active */
body.wcsf-has-session-form .my-custom-ticket-quantity-field {
    display: none !important;
}

/* Ensure session form is visible */
.wcsf-form-wrapper {
    display: block !important;
    width: 100% !important;
    margin: 20px 0 !important;
}

.wcsf-session-form {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    gap: 20px !important;
}

/* Two-column layout wrapper (form + extras) */
.wcsf-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    align-items: start;
    width: 100%;
}

/* RTL: visually put addons on the left, form on the right */
body.rtl .wcsf-layout,
body.wcsf-has-session-form .wcsf-layout {
    direction: rtl;
}

@media (max-width: 900px) {
    .wcsf-layout {
        grid-template-columns: 1fr;
    }
}
