/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 15, 15, 0.7);
    /* Deeper, more modern overlay */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050;
    /* Ensure it's on top */
    padding: 40px;
    backdrop-filter: blur(4px);
}

/* Modal Content */
.modal-content {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 600px;
    /* Compact width */
    height: auto;
    /* Auto height for better fit */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Prevent content from spilling before it's ready */
    position: relative;
    animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Modal Close Button */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 34px;
    height: 34px;
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 10;
}

.modal-close:hover {
    background: #e0e0e0;
    color: #000;
    transform: rotate(90deg);
}

/* Modal Body */
#modalBody {
    padding: 0;
    flex-grow: 1;
    overflow-y: auto;
}

/* Tabs inside the modal */
.modal-tabs {
    display: flex;
    padding: 20px 30px 0;
    border-bottom: 1px solid #eee;
}

.modal-tab-btn {
    background: none;
    border: none;
    padding: 10px 15px;
    margin-bottom: -1px;
    cursor: pointer;
    color: #666;
    font-weight: 600;
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.modal-tab-btn:hover {
    color: #000;
}

.modal-tab-btn.active {
    color: #1dbf73;
    /* Main brand color */
    border-bottom-color: #1dbf73;
}

.modal-tab-btn i {
    margin-right: 8px;
}

/* Content for each tab */
.modal-tab-content {
    padding: 30px;
}

.modal-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* New styles for modal content */
.modal-header-section {
    padding: 25px 30px;
    border-bottom: 1px solid #eee;
}

.modal-main-title {
    font-size: 1.7rem;
    font-weight: 700;
    margin: 0;
}

.modal-category-badge {
    background-color: #f0f0f0;
    color: #555;
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-block;
    margin-top: 10px;
}

.modal-body-content {
    flex-grow: 1;
    overflow-y: auto;
    display: grid;
    grid-template-columns: 2fr 1fr;
    /* Main content and a sidebar */
    gap: 30px;
    padding: 30px;
}

.main-modal-content {
    width: 100%;
}

.sidebar-modal-content {
    /* Takes up 1fr */
    background-color: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
}

.section-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 15px;
    text-transform: uppercase;
    color: #555;
}

.action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s ease;
    margin-bottom: 10px;
}

.action-btn.primary {
    background-color: #007bff;
    color: #fff;
    border: 1px solid #007bff;
}

.action-btn.primary:hover {
    background-color: #0056b3;
}

.action-btn.success {
    background-color: #28a745;
    color: #fff;
    border: 1px solid #28a745;
}

.action-btn.success:hover {
    background-color: #1e7e34;
}

.details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.detail-item {
    background-color: #fafafa;
    padding: 15px;
    border-radius: 8px;
}

.detail-item.detail-full-width {
    grid-column: 1 / -1;
}

.detail-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: #777;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.detail-title i {
    margin-right: 6px;
    color: #999;
}

.detail-value {
    font-size: 1.1rem;
    /* Larger font size */
    font-weight: 600;
    /* Bolder text */
    color: #333;
    margin: 0;
}

.detail-value.price {
    font-size: 1.4rem;
    /* Even larger for the price */
    font-weight: 700;
    color: #1dbf73;
}

.payment-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    align-items: center;
}

.qr-code-wrapper {
    padding: 15px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

/* CSS-based Tab Logic for Sidebars */
.modal-body-content[data-active-tab="payment"] {
    grid-template-columns: 1fr;
    /* Full width */
    overflow-y: hidden;
    /* static page without scrolling */
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 10px 30px !important;
    /* Reduced vertical padding */
}

.modal-body-content[data-active-tab="payment"] .sidebar-modal-content {
    display: none !important;
}

.modal-body-content[data-active-tab="payment"] .main-modal-content {
    grid-column: 1 / -1;
    width: 100%;
}

/* Compact styles for payment tab elements to prevent scrolling */
.modal-body-content[data-active-tab="payment"] .mb-4 {
    margin-bottom: 0.8rem !important;
    /* Reduce margins significantly */
}

.modal-body-content[data-active-tab="payment"] .payment-code {
    font-size: 20px !important;
    /* Smaller code font */
    margin: 5px 0 !important;
}

.modal-body-content[data-active-tab="payment"] img[alt="QR-код для оплаты"] {
    width: 140px !important;
    /* Smaller QR code */
    height: 140px !important;
}

.modal-body-content[data-active-tab="payment"] .d-flex.gap-4 {
    gap: 1rem !important;
    /* Tighter logos */
    margin-bottom: 0.5rem !important;
}

.modal-body-content[data-active-tab="payment"] .mt-4 {
    margin-top: 0.5rem !important;
    /* Reduced top margin for footer */
    padding-top: 0.5rem !important;
}

.modal-body-content[data-active-tab="payment"] .alert {
    padding: 5px 10px !important;
    /* Smaller alert padding */
    font-size: 0.9rem !important;
}