/**
 * Box Builder Page Styles
 * 
 * Modern, clean styling for the subscription box builder page
 * Optimized for Gutenberg block editor
 * 
 * @package ReorderePro
 * @subpackage BoxSubscriptions
 */

/* ========================================
   Page Container
   ======================================== */
body.rorder-cart-open {
    overflow: hidden;
}

.rorder-box-builder-page {
    padding: 0;
    background: #fff;
}

.rorder-box-builder-page .container {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* ========================================
   Page Header - Compact
   ======================================== */
.rorder-box-header {
    text-align: left;
    margin-bottom: 0;
    padding: 20px 40px;
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.rorder-box-header h1 {
    margin: 0 0 10px;
    font-size: 28px;
    color: #2c3e50;
}

.rorder-box-meta {
    display: flex;
    justify-content: flex-start;
    gap: 30px;
    font-size: 14px;
    color: #666;
}

.rorder-box-meta strong {
    color: #2c3e50;
    margin-right: 5px;
}

/* ========================================
   Layout - Full Width Products
   ======================================== */
.rorder-products-section {
    width: 100%;
    margin: 0;
    padding: 40px;
}

.rorder-mini-cart-section {
    display: none; /* Hidden by default, shown as slide-in */
}

/* ========================================
   Products Grid Block - Full Width
   ======================================== */
.rorder-products-grid-block {
    background: transparent;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
}

.rorder-products-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    align-items: center;
}

.rorder-product-search {
    flex: 0 0 400px;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.rorder-product-search:focus {
    outline: none;
    border-color: #3498db;
}

.rorder-quick-actions .button {
    padding: 12px 24px;
    white-space: nowrap;
}

/* Products Grid - Optimized Spacing */
.rorder-products-grid {
    display: grid;
    gap: 20px;
}

.rorder-grid-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.rorder-grid-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.rorder-grid-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Default to 4 columns for better space usage */
.rorder-products-grid:not([class*="rorder-grid-columns-"]) {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

@media (max-width: 1400px) {
    .rorder-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 991px) {
    .rorder-products-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}

@media (max-width: 576px) {
    .rorder-products-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .rorder-product-search {
        flex: 1;
    }
}

/* Loading State */
.rorder-loading {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.rorder-loading .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Product Card - Compact Design */
.rorder-product-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.rorder-product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #3498db;
}

.rorder-product-card .product-image {
    height: 200px;
    background: #f8f8f8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.rorder-product-card .product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rorder-product-card .product-info {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.rorder-product-card .product-name {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: #2c3e50;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rorder-product-card .product-description {
    display: none; /* Hide to save space */
}

.rorder-product-card .product-price {
    font-size: 18px;
    font-weight: bold;
    color: #27ae60;
    margin-bottom: auto;
    margin-top: 5px;
}

.rorder-product-card .product-actions {
    margin-top: 12px;
}

.rorder-product-card .add-to-box-btn {
    width: 100%;
    padding: 12px 20px;
    background: var(--rorder-box-primary-color, #96588a);
    color: var(--rorder-box-button-text-color, #fff);
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.rorder-product-card .add-to-box-btn:hover {
    opacity: 0.85;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rorder-product-card .added-btn {
    width: 100%;
    padding: 12px 20px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: not-allowed;
    opacity: 0.8;
}

/* Quantity Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.qty-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #3498db;
    background: #fff;
    color: #3498db;
    border-radius: 8px;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
}

.qty-btn:hover {
    background: #3498db;
    color: #fff;
}

.qty-input {
    width: 60px;
    height: 40px;
    text-align: center;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
}

/* ========================================
   Mini Cart Block - Slide-in Side Cart
   ======================================== */
.rorder-mini-cart-block {
    position: fixed !important;
    top: 0 !important;
    right: -420px !important;
    width: 420px;
    height: 100vh !important;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    z-index: 9999 !important;
    transition: right 0.3s ease;
    display: flex !important;
    flex-direction: column;
}

.rorder-mini-cart-block.active {
    right: 0 !important;
}

/* Cart Overlay */
.rorder-cart-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0,0,0,0.5);
    z-index: 9998 !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.rorder-cart-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* Floating Cart Toggle Button */
.rorder-cart-toggle {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    width: 70px;
    height: 70px;
    background: var(--rorder-box-primary-color, #96588a);
    color: var(--rorder-box-button-text-color, #fff);
    border: 3px solid #fff;
    border-radius: 50%;
    font-size: 24px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    cursor: pointer;
    z-index: 9997 !important;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.rorder-cart-toggle:hover {
    opacity: 0.85;
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.rorder-cart-toggle svg {
    position: relative;
    z-index: 1;
}

.rorder-cart-toggle .cart-count-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff6b6b;
    color: #fff;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
    border: 3px solid #fff;
}

.rorder-mini-cart-sticky {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.rorder-cart-header {
    padding: 20px 25px;
    background: var(--rorder-box-primary-color, #96588a);
    color: var(--rorder-box-button-text-color, #fff);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.rorder-cart-header h3 {
    margin: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--rorder-box-button-text-color, #fff);
}

.rorder-cart-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: var(--rorder-box-button-text-color, #fff);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.rorder-cart-close:hover {
    background: rgba(255,255,255,0.3);
    transform: rotate(90deg);
}

.rorder-box-counter {
    background: rgba(255,255,255,0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--rorder-box-button-text-color, #fff);
}

.rorder-cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 20px 25px;
}

.rorder-empty-message {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 60px 20px;
}

/* Cart Items List */
.cart-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cart-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 15px;
    margin-bottom: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.3s;
}

.cart-item:hover {
    background: #e9ecef;
}

.cart-item .item-image {
    width: 50px;
    height: 50px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
}

.cart-item .item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cart-item .item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cart-item .item-name {
    display: block;
    font-weight: 500;
    color: #333;
    font-size: 14px;
    line-height: 1.3;
}

.cart-item .item-price {
    font-size: 13px;
    color: var(--rorder-box-primary-color, #96588a);
    font-weight: 600;
}

.cart-item .remove-cart-item {
    width: 32px;
    height: 32px;
    background: #fff;
    color: #e74c3c;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    padding: 0;
}

.cart-item .remove-cart-item svg {
    display: block;
}

.cart-item .remove-cart-item:hover {
    background: #fee;
    border-color: #e74c3c;
    transform: scale(1.1);
}

/* Cart Footer */
.rorder-cart-footer {
    padding: 20px 25px;
    border-top: 2px solid #e0e0e0;
    background: #f8f9fa;
    flex-shrink: 0;
}

.rorder-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 15px;
}

.rorder-cart-total .label {
    color: #2c3e50;
}

.rorder-cart-total .amount {
    color: var(--rorder-box-primary-color, #96588a);
    font-weight: 700;
}

.rorder-cart-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rorder-cart-actions .button {
    width: 100%;
    padding: 14px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.rorder-add-to-cart-btn:not(:disabled) {
    background: var(--rorder-box-primary-color, #96588a);
    color: var(--rorder-box-button-text-color, #fff);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.rorder-add-to-cart-btn:not(:disabled):hover {
    opacity: 0.85;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

.rorder-clear-box {
    background: #fff;
    color: #666;
    border: 2px solid #e0e0e0 !important;
}

.rorder-clear-box:hover {
    background: #f8f9fa;
    border-color: #999 !important;
}

.rorder-add-to-cart-btn {
    background: #27ae60;
    color: #fff;
}

.rorder-add-to-cart-btn:hover:not(:disabled) {
    background: #229954;
}

.rorder-add-to-cart-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Messages */
.rorder-cart-messages {
    margin-top: 12px;
}

.rorder-cart-messages .message {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13px;
}

.rorder-cart-messages .error {
    background: #fee;
    color: #c0392b;
    border: 1px solid #e74c3c;
}

.rorder-cart-messages .success {
    background: #efe;
    color: #229954;
    border: 1px solid #27ae60;
}

/* ========================================
   Scrollbar Styling
   ======================================== */
.rorder-cart-items::-webkit-scrollbar {
    width: 6px;
}

.rorder-cart-items::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.rorder-cart-items::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.rorder-cart-items::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ========================================
   Responsive Adjustments
   ======================================== */
@media (max-width: 576px) {
    .rorder-box-header {
        padding: 15px 20px;
    }
    
    .rorder-box-header h1 {
        font-size: 22px;
    }
    
    .rorder-box-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .rorder-products-section {
        padding: 20px;
    }
    
    .rorder-products-filters {
        flex-direction: column;
    }
    
    .rorder-mini-cart-block {
        width: 100%;
        right: -100%;
    }
    
    .rorder-cart-toggle {
        width: 60px;
        height: 60px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }
}
