/**
 * BuddyBoss Groups WooCommerce Integration - Frontend Styles
 */

/* Package Selection Widget Styles */
.bb-package-selection-widget {
    width: 100%;
}

.packages-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
}

/* Package Card Styles */
.package-card {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 30px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.package-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.package-card.highlighted {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}

/* Best Value Badge */
.best-value-badge {
    position: absolute;
    top: -12px;
    right: 20px;
    background: #3b82f6;
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Package Header */
.package-header {
    text-align: center;
    margin-bottom: 25px;
}

.package-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0 0 10px 0;
}

.package-description {
    font-size: 16px;
    color: #6b7280;
    margin: 0;
    line-height: 1.5;
}

/* Package Price */
.package-price {
    text-align: center;
    font-size: 36px;
    font-weight: 700;
    color: #059669;
    margin-bottom: 25px;
}

.package-price .amount {
    color: #059669;
}

/* Package Features */
.package-features {
    margin-bottom: 30px;
    flex: 1;
}

.package-features ul,
.package-features-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.package-features li,
.package-feature-item {
    padding: 10px 0;
    color: #4b5563;
    display: flex;
    align-items: center;
    font-size: 15px;
}

.package-features i,
.feature-icon {
    color: #10b981;
    margin-right: 12px;
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    flex-shrink: 0;
}

.feature-icon i {
    margin: 0;
}

.feature-text {
    flex: 1;
}

/* Subscription Period Selector */
.subscription-period-selector {
    margin-bottom: 20px;
}

.subscription-period-selector label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 8px;
}

.subscription-dropdown {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background-color: #ffffff;
    color: #1f2937;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
}

.subscription-dropdown:hover {
    border-color: #d1d5db;
}

.subscription-dropdown:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Custom dropdown styling for better option display */
.subscription-dropdown option {
    padding: 15px 10px;
    line-height: 1.6;
}

/* Custom dropdown option container */
.custom-dropdown-container {
    position: relative;
    z-index: 100;
}

.custom-dropdown-display {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background-color: #ffffff;
    color: #1f2937;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 101;
}

.custom-dropdown-display:hover {
    border-color: #d1d5db;
}

.custom-dropdown-display.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.custom-dropdown-display .dropdown-arrow {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.custom-dropdown-display.active .dropdown-arrow {
    transform: rotate(180deg);
}

.custom-dropdown-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    z-index: 9999;
    overflow: hidden;
    display: none;
}

.custom-dropdown-options.show {
    display: block;
    z-index: 9999 !important;
}

/* Ensure package cards don't overflow and hide dropdowns */
.package-card {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    padding: 30px;
    position: relative;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: visible !important;
}

/* Ensure the packages container allows overflow */
.packages-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-bottom: 40px;
    overflow: visible !important;
}

/* Make sure widget wrapper doesn't clip content */
.bb-package-selection-widget {
    width: 100%;
    overflow: visible !important;
}

/* Elementor specific fixes */
.elementor-widget-bb_groups_packages {
    overflow: visible !important;
}

.elementor-widget-bb_groups_packages .elementor-widget-container {
    overflow: visible !important;
}

.custom-dropdown-option {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid #f3f4f6;
}

.custom-dropdown-option:last-child {
    border-bottom: none;
}

.custom-dropdown-option:hover {
    background-color: #f3f4f6;
}

.custom-dropdown-option.selected {
    background-color: #eff6ff;
    color: #3b82f6;
}

.dropdown-option-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.dropdown-option-left {
    flex: 1;
}

.dropdown-option-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
}

.dropdown-option-discount {
    font-size: 12px;
    color: #059669;
    font-weight: 500;
}

.dropdown-option-right {
    text-align: right;
}

.dropdown-option-price {
    font-weight: 700;
    color: #1f2937;
    font-size: 16px;
}

.dropdown-option-original-price {
    font-size: 12px;
    color: #9ca3af;
    text-decoration: line-through;
    margin-top: 2px;
}

/* Package Button */
.package-button {
    width: 100%;
    padding: 16px 24px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.package-button:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(59, 130, 246, 0.3);
}

.package-button:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

.package-card.highlighted .package-button:not(:disabled) {
    background: #059669;
}

.package-card.highlighted .package-button:hover:not(:disabled) {
    background: #047857;
    box-shadow: 0 5px 15px rgba(5, 150, 105, 0.3);
}

/* Modal Styles - DESKTOP */
.subject-selection-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999 !important;
    display: none;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999998 !important;
}

.modal-content {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh; /* Change this value - currently 90% of viewport height */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 600px; /* Optional: force exact height */
    z-index: 999999 !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}


.modal-header {
    padding: 24px 30px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
    color: #1f2937;
}

.modal-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.selection-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 16px 20px;
    margin-bottom: 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.selection-message {
    margin: 0;
    color: #0c4a6e;
    font-size: 15px;
}

.selection-counter {
    background: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    color: #0c4a6e;
}

.subjects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.subject-item {
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    gap: 15px;
}

.subject-item:hover {
    border-color: #d1d5db;
    background: #f9fafb;
}

.subject-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
}

.subject-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.subject-checkbox {
    flex-shrink: 0;
}

.subject-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.subject-info {
    flex: 1;
}

.subject-name {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 8px 0;
}

.subject-description {
    font-size: 14px;
    color: #6b7280;
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.subject-members {
    font-size: 13px;
    color: #9ca3af;
}

.modal-footer {
    padding: 20px 30px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.modal-cancel-btn,
.modal-confirm-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-cancel-btn {
    background: #f3f4f6;
    color: #4b5563;
}

.modal-cancel-btn:hover {
    background: #e5e7eb;
}

.modal-confirm-btn {
    background: #3b82f6;
    color: white;
}

.modal-confirm-btn:hover:not(:disabled) {
    background: #2563eb;
}

.modal-confirm-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading State */
.package-button.loading {
    position: relative;
    color: transparent;
}

.package-button.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid #f3f3f3;
    border-radius: 50%;
    border-top: 2px solid #333;
    animation: bb-spin 1s linear infinite;
}

@keyframes bb-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Notification Styles */
.bb-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
    z-index: 9999;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 300px;
}

.bb-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.bb-notification-success {
    background: #28a745;
}

.bb-notification-error {
    background: #dc3545;
}

.bb-notification-info {
    background: #17a2b8;
}

/* MOBILE RESPONSIVE - STRICT FIT TO SCREEN */
@media (max-width: 768px) {
    .packages-container {
        grid-template-columns: 1fr;
    }
    
    /* Ensure dropdowns work properly on mobile */
    .custom-dropdown-options {
        position: fixed !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-height: 60vh;
        overflow-y: auto;
    }
    
    .custom-dropdown-option {
        padding: 16px;
    }
    
    /* Mobile Modal - Full Screen with Safe Areas */
    .subject-selection-modal {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
    }
    
    .modal-content {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        transform: none;
        border-radius: 0;
        display: flex;
        flex-direction: column;
    }
    
    /* Fixed header that doesn't scroll */
    .modal-header {
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        padding: 16px 20px;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    /* Scrollable body with proper padding */
    .modal-body {
        flex: 1;
        overflow-y: auto;
        padding: 20px;
        padding-bottom: 100px; /* Space for fixed footer */
        -webkit-overflow-scrolling: touch;
    }
    
    /* Fixed footer that doesn't scroll */
    .modal-footer {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        padding: 16px 20px;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -2px 4px rgba(0,0,0,0.1);
        z-index: 10;
        display: flex;
        justify-content: space-between;
        gap: 10px;
    }
    
    .modal-cancel-btn,
    .modal-confirm-btn {
        flex: 1;
        padding: 12px 16px;
        font-size: 15px;
    }
    
    /* Mobile optimized selection info */
    .selection-info {
        padding: 12px 16px;
        margin-bottom: 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .selection-message {
        font-size: 14px;
        flex: 1 1 100%;
    }
    
    .selection-counter {
        padding: 4px 12px;
        font-size: 14px;
    }
    
    /* Single column subjects on mobile */
    .subjects-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding-bottom: 20px; /* Extra padding at bottom */
    }
    
    .subject-item {
        padding: 16px;
    }
    
    .subject-name {
        font-size: 15px;
    }
    
    .subject-description {
        font-size: 13px;
    }
    
    .package-card {
        padding: 20px;
    }
    
    .package-title {
        font-size: 20px;
    }
    
    .package-price {
        font-size: 28px;
    }
    
    .subscription-dropdown {
        font-size: 14px;
        padding: 10px 14px;
    }
}

/* Small Mobile Devices */
@media (max-width: 480px) {
    /* Even more compact for very small screens */
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .modal-body {
        padding: 16px;
        padding-bottom: 100px;
    }
    
    .modal-footer {
        padding: 12px 16px;
    }
    
    .modal-cancel-btn,
    .modal-confirm-btn {
        padding: 10px 12px;
        font-size: 14px;
    }
    
    .subjects-grid {
        gap: 10px;
    }
    
    .subject-item {
        padding: 12px;
        gap: 10px;
    }
    
    .subject-checkbox input[type="checkbox"] {
        width: 18px;
        height: 18px;
    }
    
    .subject-name {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .subject-description {
        font-size: 12px;
        margin-bottom: 4px;
    }
    
    .subject-members {
        font-size: 11px;
    }
    
    .bb-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* iPhone X and newer - Safe Area Support */
@supports (padding: max(0px)) {
    @media (max-width: 768px) {
        .modal-header {
            padding-top: max(16px, env(safe-area-inset-top));
        }
        
        .modal-footer {
            padding-bottom: max(16px, env(safe-area-inset-bottom));
        }
        
        .modal-body {
            padding-bottom: calc(100px + env(safe-area-inset-bottom));
        }
    }
}

/* Landscape Mode on Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .modal-body {
        padding: 16px;
        padding-bottom: 90px;
    }
    
    .modal-header {
        padding: 12px 20px;
    }
    
    .modal-footer {
        padding: 12px 20px;
    }
    
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .subject-item {
        padding: 12px;
    }
}

/* RTL Support */
.rtl .package-card {
    direction: rtl;
    text-align: right;
}

.rtl .package-features li {
    flex-direction: row-reverse;
}

.rtl .package-features i {
    margin-right: 0;
    margin-left: 12px;
}

.rtl .modal-header {
    flex-direction: row-reverse;
}

.rtl .subject-item {
    flex-direction: row-reverse;
}

.rtl .subscription-dropdown {
    background-position: left 12px center;
    padding-right: 16px;
    padding-left: 40px;
}

/* Z-Index Fix for Common Conflicts */
/* Ensure dropdowns and modals appear above everything */
.custom-dropdown-options,
.subject-selection-modal {
    isolation: isolate;
}



/* Our elements should be higher */
.custom-dropdown-options {
    z-index: 99999 !important;
}

.subject-selection-modal,
.subject-selection-modal .modal-overlay,
.subject-selection-modal .modal-content {
    z-index: 999999 !important;
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
}

/* Mobile Icon Display Fix */
@media (max-width: 768px) {
    .feature-icon,
    .feature-icon i {
        display: inline-block !important;
        min-width: 20px;
        min-height: 20px;
    }
}