/**
 * BWG Waiver & Signature Capture Styles
 * 
 * Mobile-friendly responsive styles for waiver acceptance and signature pad.
 * 
 * @package BWG_Custom_Functions
 * @since 2.2.0
 */

/* ============================================
   WAIVER MODAL BUTTON & INDICATOR
   ============================================ */
.bwg-waiver-trigger-wrapper {
    background: #f0f6fc;
    border: 2px solid #2271b1;
    border-radius: 8px;
    padding: 20px;
    margin: 25px 0;
    text-align: center;
}

.bwg-waiver-trigger-button {
    display: inline-block;
    padding: 15px 40px;
    background: #2271b1;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bwg-waiver-trigger-button:hover {
    background: #135e96;
}

.bwg-waiver-trigger-button:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.bwg-waiver-signed-indicator {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 15px 30px;
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    color: #155724;
}

.bwg-waiver-signed-indicator-icon {
    font-size: 24px;
}

.bwg-waiver-view-button {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 20px;
    background: #fff;
    color: #155724;
    border: 1px solid #28a745;
    border-radius: 4px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bwg-waiver-view-button:hover {
    background: #f0f6fc;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.bwg-waiver-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999999;
    overflow: hidden;
}

.bwg-waiver-modal-overlay.bwg-waiver-modal-open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.bwg-waiver-modal {
    position: relative;
    width: 95%;
    max-width: 1000px;
    max-height: 95vh;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    animation: bwgWaiverModalFadeIn 0.3s ease;
}

@keyframes bwgWaiverModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.bwg-waiver-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: #fff;
    border: 2px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    color: #666;
    transition: all 0.2s;
    z-index: 10;
}

.bwg-waiver-modal-close:hover {
    background: #d63638;
    border-color: #d63638;
    color: #fff;
}

/* ============================================
   MAIN WAIVER CONTAINER (IN MODAL)
   ============================================ */
.bwg-waiver-wrapper {
    background: #fff;
    border-radius: 8px;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 90vh;
    /* Prevent global form.cart input CSS from affecting waiver inputs */
    --waiver-input-width: auto;
}

.bwg-waiver-modal-header {
    flex-shrink: 0;
    padding: 20px 25px 15px;
    border-bottom: 2px solid #e0e0e0;
    background: #f9f9f9;
}

.bwg-waiver-title {
    margin: 0 0 15px 0;
    padding: 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #000000;
}

.bwg-waiver-subtitle {
    margin: 8px 0 15px 0;
    padding: 0;
    color: #666;
    font-size: 13px;
}

/* Progress Bar */
.bwg-waiver-progress {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    position: relative;
}

.bwg-waiver-progress::before {
    content: '';
    position: absolute;
    top: 15px;
    left: 10%;
    right: 10%;
    height: 2px;
    background: #ddd;
    z-index: 0;
}

.bwg-waiver-progress-step {
    flex: 1;
    text-align: center;
    position: relative;
    z-index: 1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bwg-waiver-progress-step:hover .bwg-waiver-progress-circle {
    transform: scale(1.05);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.bwg-waiver-progress-step:hover .bwg-waiver-progress-label {
    color: #2271b1;
}

.bwg-waiver-progress-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid #ddd;
    margin: 0 auto 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #999;
    transition: all 0.3s;
}

.bwg-waiver-progress-step.active .bwg-waiver-progress-circle {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

.bwg-waiver-progress-step.completed .bwg-waiver-progress-circle {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
}

.bwg-waiver-progress-label {
    font-size: 12px;
    color: #666;
    font-weight: 500;
}

.bwg-waiver-progress-step.active .bwg-waiver-progress-label {
    color: #2271b1;
    font-weight: 600;
}

.bwg-waiver-progress-step.completed .bwg-waiver-progress-label {
    color: #28a745;
}

.bwg-waiver-modal-body {
    flex: 1 1 auto;
    overflow-y: auto !important; /* Force body to scroll for all steps */
    overflow-x: hidden;
    padding: 20px 25px;
    min-height: 0; /* Important for flexbox scrolling */
    /* Let flex handle height - remove max-height constraint for proper scrolling */
}

/* ============================================
   WIZARD STEP CONTAINER
   ============================================ */
.bwg-waiver-step {
    display: none;
    animation: bwgWaiverStepFadeIn 0.3s ease;
}

.bwg-waiver-step.active {
    display: block;
}

@keyframes bwgWaiverStepFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   WAIVER TEXT CONTAINER (STEP 1 - FULL HEIGHT)
   ============================================ */
.bwg-waiver-text-container {
    border: 2px solid #ddd;
    border-radius: 4px;
    padding: 20px;
    background: #fafafa;
    position: relative;
}

.bwg-waiver-text-header {
    text-align: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 2px solid #2271b1;
}

.bwg-waiver-text-header h4 {
    margin: 0 0 3px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #000000;
}

.bwg-waiver-text-header p {
    margin: 0;
    font-size: 13px;
    color: #666;
}

.bwg-waiver-content {
    color: #1e1e1e;
    font-size: 13px;
    line-height: 1.5;
    text-align: left;
    direction: ltr;
}

.bwg-waiver-content h5 {
    margin: 15px 0 8px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #000000;
    border-bottom: 1px solid #ddd;
    padding-bottom: 4px;
}

.bwg-waiver-content h6 {
    margin: 12px 0 6px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #000000;
}

.bwg-waiver-content p {
    margin: 8px 0;
}

.bwg-waiver-content ol,
.bwg-waiver-content ul {
    margin: 8px 0;
    padding-left: 25px;
}

.bwg-waiver-content li {
    margin: 6px 0;
}

.bwg-waiver-content ul ul {
    margin: 5px 0;
    padding-left: 20px;
}

/* ============================================
   AGREEMENT CHECKBOX (Outside scrollable waiver)
   Note: Now located in modal footer (Step 1 only)
   ============================================ */
.bwg-waiver-agreement {
    background: #f0f6fc;
    border: 3px solid #2271b1;
    border-radius: 6px;
    padding: 20px;
    margin: 0;
    flex: 1;
}

.bwg-waiver-agreement-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
    margin: 0;
    font-size: 15px;
}

.bwg-waiver-checkbox {
    width: 20px !important;
    height: 20px !important;
    margin-right: 12px;
    margin-top: 2px;
    flex-shrink: 0;
    cursor: pointer;
    min-width: 20px !important;
    max-width: 20px !important;
}

.bwg-waiver-agreement-text {
    flex: 1;
    color: #1e1e1e;
    line-height: 1.5;
}

.bwg-waiver-agreement-text strong {
    font-weight: 700;
}

/* ============================================
   EVENT DETAILS FORM
   ============================================ */
.bwg-waiver-event-details {
    margin-bottom: 0;
}

.bwg-waiver-step-title {
    margin: 0 0 15px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #000000;
    border-bottom: 2px solid #000000;
    padding-bottom: 10px;
}

.bwg-waiver-step-description {
    margin: 0 0 20px 0;
    padding: 12px 15px;
    background: #f0f6fc;
    border-left: 4px solid #2271b1;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

.bwg-waiver-section-title {
    margin: 0 0 15px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #000000;
    border-bottom: 2px solid #000000;
    padding-bottom: 8px;
}

.bwg-waiver-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 12px;
}

.bwg-waiver-form-field {
    flex: 1;
    min-width: 0;
}

.bwg-waiver-form-field-full {
    flex: 1 1 100%;
}

.bwg-waiver-form-field label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 600;
    color: #1e1e1e;
}

.bwg-waiver-input {
    width: 100% !important; /* Override any global form.cart input styles */
    max-width: 100% !important;
    padding: 10px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    height: auto !important; /* Prevent height override */
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box !important;
}

.bwg-waiver-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* ============================================
   SIGNATURE PAD (FIXED AT BOTTOM)
   ============================================ */
.bwg-waiver-modal-footer {
    flex: 0 0 auto;
    padding: 15px 25px 20px;
    border-top: 2px solid #e0e0e0;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.bwg-waiver-nav-buttons {
    display: flex;
    gap: 10px;
    width: 100%;
}

.bwg-waiver-nav-button {
    flex: 1;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.bwg-waiver-back-button {
    background: #f0f0f0;
    color: #333;
}

.bwg-waiver-back-button:hover {
    background: #e0e0e0;
}

.bwg-waiver-next-button {
    background: #2271b1;
    color: #fff;
}

.bwg-waiver-next-button:hover {
    background: #135e96;
}

.bwg-waiver-next-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.bwg-waiver-signature-section {
    margin-bottom: 0;
}

.bwg-waiver-signature-agreement-header {
    background: #f0f6fc;
    border: 2px solid #2271b1;
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 25px;
}

.bwg-waiver-signature-agreement-header h5 {
    margin: 0 0 12px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #000000;
    border-bottom: 2px solid #000000;
    padding-bottom: 8px;
}

.bwg-waiver-signature-agreement-header p {
    margin: 0;
    font-size: 14px;
    line-height: 1.6;
    color: #1e1e1e;
}

.bwg-waiver-signature-pad-wrapper {
    position: relative;
}

.bwg-waiver-signature-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #1e1e1e;
}

.bwg-waiver-signature-instructions {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

.bwg-waiver-signature-canvas {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: 180px !important;
    border: 2px solid #2271b1 !important;
    border-radius: 4px !important;
    cursor: crosshair;
    touch-action: none;
    background: #fff !important;
    margin-bottom: 15px;
    box-sizing: border-box !important;
}

.bwg-waiver-clear-signature {
    display: inline-block;
    padding: 8px 16px;
    background: #d63638;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.bwg-waiver-clear-signature:hover {
    background: #b32d2e;
}

/* ============================================
   STATUS MESSAGES
   ============================================ */
.bwg-waiver-status {
    display: none;
    padding: 10px 15px;
    margin-top: 12px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

.bwg-waiver-status-error {
    background: #f8d7da;
    border-left: 4px solid #d63638;
    color: #721c24;
}

.bwg-waiver-status-success {
    background: #d4edda;
    border-left: 4px solid #28a745;
    color: #155724;
}

.bwg-waiver-status-info {
    background: #d1ecf1;
    border-left: 4px solid #2271b1;
    color: #0c5460;
}

/* ============================================
   SIGNED CONFIRMATION
   ============================================ */
.bwg-waiver-signed-confirmation {
    background: #d4edda;
    border: 2px solid #28a745;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    margin: 25px 0;
}

/* Compact version for checkout page */
.bwg-waiver-signed-confirmation.bwg-waiver-signed-compact {
    background: #d4edda;
    border: 1px solid #28a745;
    border-radius: 4px;
    padding: 0;
    text-align: left;
    margin: 15px 0;
    display: block;
    overflow: hidden;
}

/* Header (always visible) */
.bwg-waiver-signed-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
}

.bwg-waiver-signed-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.bwg-waiver-signed-compact .bwg-waiver-signed-icon {
    font-size: 20px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.bwg-waiver-signed-compact .bwg-waiver-signed-text {
    font-size: 14px;
    color: #155724;
    line-height: 1.4;
    flex: 1;
}

/* Toggle details button */
.bwg-waiver-toggle-details {
    background: rgba(21, 87, 36, 0.1);
    border: 1px solid #28a745;
    border-radius: 3px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    color: #155724;
    transition: all 0.2s ease;
    margin-left: auto;
}

.bwg-waiver-toggle-details:hover {
    background: rgba(21, 87, 36, 0.2);
}

.bwg-waiver-toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
}

.bwg-waiver-signed-confirmation.details-expanded .bwg-waiver-toggle-icon {
    transform: rotate(180deg);
}

/* Edit button */
.bwg-waiver-edit-btn {
    background: #fff;
    border: 1px solid #28a745;
    border-radius: 3px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    color: #155724;
    font-weight: 600;
    transition: all 0.2s ease;
}

.bwg-waiver-edit-btn:hover {
    background: #28a745;
    color: #fff;
}

/* Expandable details section */
.bwg-waiver-signed-details {
    padding: 0 16px 16px 16px;
    border-top: 1px solid rgba(40, 167, 69, 0.2);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 1000px;
    }
}

/* Details grid layout */
.bwg-waiver-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.bwg-waiver-detail-item {
    font-size: 13px;
    color: #155724;
    line-height: 1.4;
}

.bwg-waiver-detail-item strong {
    color: #0d3d1a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bwg-waiver-detail-wide {
    grid-column: 1 / -1;
}

/* Signature preview */
.bwg-waiver-signature-preview {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(40, 167, 69, 0.2);
}

.bwg-waiver-signature-preview strong {
    display: block;
    margin-bottom: 8px;
    color: #0d3d1a;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.bwg-waiver-signature-img {
    max-width: 300px;
    height: auto;
    border: 1px solid #28a745;
    border-radius: 4px;
    padding: 8px;
    background: #fff;
    display: block;
}

.bwg-waiver-signed-confirmation h4 {
    margin: 0 0 10px 0;
    font-family: 'Quicksand', sans-serif;
    font-size: 20px;
    font-weight: 700;
    color: #000000;
}

.bwg-waiver-signed-confirmation p {
    margin: 8px 0;
    font-size: 15px;
    color: #155724;
}

.bwg-waiver-signed-timestamp {
    font-size: 14px;
    color: #155724;
    font-style: italic;
}

/* ============================================
   SUBMIT BUTTON STATE
   ============================================ */
.bwg-waiver-incomplete {
    opacity: 0.6;
    position: relative;
}

.bwg-waiver-incomplete::after {
    content: '⚠ Complete waiver first';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 8px;
    padding: 6px 12px;
    background: #d63638;
    color: #fff;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
}

.bwg-waiver-incomplete:hover::after {
    opacity: 1;
}

/* ============================================
   REQUIRED FIELD INDICATOR
   ============================================ */
.required,
abbr.required {
    color: #d63638;
    text-decoration: none;
    border: none;
    font-weight: 700;
}

/* ============================================
   SUBMIT BUTTON (IN MODAL FOOTER)
   ============================================ */
.bwg-waiver-submit-button {
    display: block;
    width: 100%;
    padding: 12px 20px;
    background: #2271b1;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 12px;
}

.bwg-waiver-submit-button:hover {
    background: #135e96;
}

.bwg-waiver-submit-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   PREVENT BODY SCROLL WHEN MODAL OPEN
   ============================================ */
body.bwg-waiver-modal-open {
    overflow: hidden;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    .bwg-waiver-modal {
        width: 95%;
        max-height: 95vh;
    }
    
    .bwg-waiver-modal-header {
        padding: 15px;
    }
    
    .bwg-waiver-modal-body {
        padding: 15px;
    }
    
    .bwg-waiver-modal-footer {
        padding: 12px 15px 15px;
    }
    
    .bwg-waiver-title {
        font-size: 18px;
    }
    
    .bwg-waiver-subtitle {
        font-size: 13px;
    }
    
    .bwg-waiver-text-container {
        max-height: calc(95vh - 220px);
        padding: 12px;
    }
    
    .bwg-waiver-form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .bwg-waiver-signature-canvas {
        height: 100px !important;
    }
    
    .bwg-waiver-signed-confirmation {
        padding: 20px;
    }
    
    .bwg-waiver-signed-icon {
        font-size: 36px;
    }
    
    /* Responsive collapsible details on mobile */
    .bwg-waiver-signed-header {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .bwg-waiver-toggle-details,
    .bwg-waiver-edit-btn {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    .bwg-waiver-details-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .bwg-waiver-signature-img {
        max-width: 100%;
    }
    
    /* Adjust checkbox for tablets (now in footer) */
    .bwg-waiver-agreement {
        padding: 15px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .bwg-waiver-modal {
        width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .bwg-waiver-title {
        font-size: 18px;
    }
    
    .bwg-waiver-text-container {
        max-height: calc(100vh - 240px);
        padding: 10px;
    }
    
    .bwg-waiver-signature-canvas {
        height: 100px !important;
    }
    
    .bwg-waiver-form-row {
        gap: 10px;
    }
    
    /* Adjust checkbox for mobile (now in footer) */
    .bwg-waiver-agreement {
        padding: 12px;
        font-size: 13px;
        border-radius: 4px;
    }
    
    .bwg-waiver-checkbox {
        width: 18px !important;
        height: 18px !important;
        min-width: 18px !important;
        max-width: 18px !important;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .bwg-waiver-clear-signature {
        display: none;
    }
    
    .bwg-waiver-text-container {
        max-height: none;
        overflow: visible;
        border: 1px solid #000;
    }
    
    .bwg-waiver-text-container::after {
        display: none;
    }
    
    .bwg-waiver-signature-canvas {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.bwg-waiver-checkbox:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.bwg-waiver-clear-signature:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bwg-waiver-wrapper {
        border-width: 3px;
    }
    
    .bwg-waiver-text-container {
        border-width: 3px;
    }
    
    .bwg-waiver-signature-canvas {
        border-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .bwg-waiver-input,
    .bwg-waiver-clear-signature,
    .bwg-waiver-status {
        transition: none;
    }
}
