/* One Page Checkout Styles */

.one-page-checkout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 100%;
    box-sizing: border-box;
}

.checkout-section {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    margin-bottom: 24px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: box-shadow 0.3s ease;
}

.checkout-section:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.checkout-section h2 {
    color: #2c3e50;
    border-bottom: 3px solid #3498db;
    padding-bottom: 12px;
    margin-bottom: 24px;
    font-size: 1.5em;
    font-weight: 600;
}

.checkout-section h3 {
    color: #34495e;
    margin-bottom: 16px;
    font-size: 1.2em;
    font-weight: 500;
}

.checkout-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

.shipping-methods, .payment-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shipping-method, .payment-method {
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.shipping-method:hover, .payment-method:hover {
    border-color: #3498db;
    background-color: #f8f9fa;
    transform: translateY(-2px);
}

.shipping-method.selected, .payment-method.selected {
    border-color: #3498db;
    background-color: #e3f2fd;
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.2);
}

.shipping-method input[type="radio"], .payment-method input[type="radio"] {
    margin-right: 12px;
    transform: scale(1.2);
}

.shipping-method label, .payment-method label {
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
}

.order-summary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px;
    padding: 24px;
    position: sticky;
    top: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.order-summary h3 {
    color: white;
    margin-bottom: 20px;
    font-size: 1.4em;
    font-weight: 600;
    text-align: center;
}

.order-totals {
    border-top: 1px solid rgba(255,255,255,0.3);
    padding-top: 20px;
    margin-top: 20px;
}

.order-totals .total-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 8px 0;
    font-size: 1.1em;
}

.order-totals .total-line.final {
    border-top: 2px solid rgba(255,255,255,0.5);
    font-weight: bold;
    font-size: 1.3em;
    margin-top: 16px;
    padding-top: 16px;
    color: #fff;
}

.checkout-button {
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    padding: 16px 32px;
    font-size: 1.3em;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    width: 100%;
    margin-top: 24px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.checkout-button:hover {
    background: linear-gradient(135deg, #ee5a24, #ff6b6b);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(238, 90, 36, 0.4);
}

.checkout-button:disabled {
    background: #bdc3c7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.address-display {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #3498db;
}

.address-display address {
    font-style: normal;
    line-height: 1.6;
    color: #2c3e50;
}

.comments-section textarea {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    transition: border-color 0.3s ease;
}

.comments-section textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.conditions-section {
    margin-top: 24px;
    padding: 20px;
    background: linear-gradient(135deg, #ffeaa7, #fdcb6e);
    border: 1px solid #fdcb6e;
    border-radius: 8px;
}

.conditions-section h3 {
    color: #2d3436;
    margin-bottom: 12px;
}

/* Wallet payment buttons */
#wallet-payment-buttons {
    width: 100%;
}

.wallet-button-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.wallet-button-container {
    flex: 1;
    min-width: 240px;
    transition: opacity 0.25s ease, filter 0.25s ease;
}

.wallet-button-container .wallet-button {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.wallet-button-container .wallet-button svg {
    margin-right: 8px;
}

.wallet-button-container.wallet-disabled {
    opacity: 0.45;
    filter: grayscale(0.7);
}

.wallet-button-container.wallet-disabled .wallet-button {
    cursor: not-allowed;
    pointer-events: none;
}

.wallet-button-container:not(.wallet-disabled) .wallet-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.15);
}

.wallet-button.wallet-google {
    background: #000;
    color: #fff;
    font-weight: 500;
}

.wallet-button.wallet-apple {
    padding: 0;
}

.wallet-helper-text {
    text-align: center;
    color: #6c757d;
    font-size: 0.9em;
}

.conditions-section label {
    display: flex;
    align-items: center;
    font-weight: 500;
    color: #2d3436;
    cursor: pointer;
}

.conditions-section input[type="checkbox"] {
    margin-right: 12px;
    transform: scale(1.3);
}

.error-message {
    color: #e74c3c;
    background: #fdf2f2;
    border: 1px solid #fecaca;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-weight: 500;
}

.success-message {
    color: #27ae60;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-weight: 500;
}

.payment-fields {
    margin-top: 16px;
    padding: 16px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.payment-fields label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #495057;
}

.payment-fields input, .payment-fields select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
}

.payment-fields input:focus, .payment-fields select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Mobile-First Responsive Design */
@media (max-width: 768px) {
    .one-page-checkout {
        max-width: 100vw;
        width: 100vw;
        padding: 10px;
        margin: 0;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    
    .checkout-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .checkout-section {
        padding: 16px;
        margin-bottom: 16px;
        border-radius: 8px;
        box-sizing: border-box;
        width: 100%;
        overflow: hidden;
    }
    
    .order-summary {
        position: static;
        margin-top: 16px;
        padding: 16px;
    }
    
    .checkout-button {
        font-size: 1.1em;
        padding: 14px 20px;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix form grid to be single column on mobile */
    .form-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix form inputs to be full width */
    .form-group input,
    .form-group select,
    .form-group textarea,
    .payment-fields input,
    .payment-fields select,
    .comments-section textarea {
        width: 100%;
        box-sizing: border-box;
        max-width: 100%;
    }
    
    /* Ensure form groups take full width */
    .form-group {
        width: 100%;
        box-sizing: border-box;
    }
    
    .form-group.full-width {
        grid-column: 1 / -1;
        width: 100%;
    }
    
    /* Fix payment method containers */
    .payment-method-compact,
    .shipping-method {
        width: 100%;
        box-sizing: border-box;
        margin: 0 0 12px 0;
    }
    
    /* Fix wallet payment button containers */
    #wallet-payment-buttons {
        width: 100%;
        box-sizing: border-box;
    }
    
    #wallet-payment-buttons > div {
        flex-direction: column !important;
        gap: 10px !important;
    }
    
    #google-pay-direct-container,
    #apple-pay-direct-container {
        width: 100%;
        box-sizing: border-box;
    }
    
    #google-pay-button,
    #apple-pay-button {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Mobile cart summary adjustments */
    .cart-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .item-details {
        margin-right: 0;
        margin-bottom: 8px;
        width: 100%;
    }
    
    .item-quantity,
    .item-price {
        min-width: auto;
        text-align: left;
        margin-right: 0;
    }
    
    .cart-item > div:last-child {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }
    
    /* Mobile cart editing adjustments */
    .item-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 10px;
    }
    
    .quantity-controls {
        justify-content: center;
    }
    
    .item-total {
        text-align: center;
        min-width: auto;
    }
    
    .remove-item-btn {
        align-self: center;
    }
    
    /* Mobile modal adjustments */
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .search-result-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .add-to-cart-btn {
        align-self: center;
    }
}

@media (max-width: 480px) {
    .one-page-checkout {
        padding: 8px;
    }
    
    .checkout-section {
        padding: 12px;
        margin-bottom: 12px;
    }
    
    .checkout-section h2 {
        font-size: 1.2em;
        margin-bottom: 16px;
    }
    
    .checkout-section h3 {
        font-size: 1.1em;
        margin-bottom: 12px;
    }
    
    .shipping-method, 
    .payment-method,
    .payment-method-compact {
        padding: 12px;
        margin-bottom: 8px;
    }
    
    .order-summary {
        padding: 12px;
    }
    
    .checkout-button {
        font-size: 1em;
        padding: 12px 16px;
    }
    
    /* Ensure all text and elements fit within screen */
    .order-totals .total-line {
        font-size: 1em;
    }
    
    .order-totals .total-line.final {
        font-size: 1.1em;
    }
}

/* Fix for very small screens */
@media (max-width: 360px) {
    .one-page-checkout {
        padding: 4px;
        max-width: 100vw !important;
        width: 100vw !important;
    }
    
    .checkout-section {
        padding: 8px;
        max-width: calc(100vw - 8px) !important;
        width: calc(100vw - 8px) !important;
        margin: 0 4px !important;
    }
    
    .checkout-section h2 {
        font-size: 1.1em;
    }
    
    .checkout-button {
        font-size: 0.9em;
        padding: 10px 12px;
    }
    
    /* Extreme Order Summary fix for tiny screens */
    .order-summary {
        max-width: calc(100vw - 8px) !important;
        width: calc(100vw - 8px) !important;
        margin: 0 4px !important;
        padding: 8px !important;
    }
    
    /* Force all elements to fit */
    * {
        max-width: 100vw !important;
    }
}

/* Prevent horizontal overflow */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

.one-page-checkout,
.checkout-section,
.checkout-grid,
.payment-methods,
.shipping-methods {
    max-width: 100%;
    overflow-x: hidden;
}

/* Ensure main page container doesn't exceed viewport */
#mainWrapper,
#contentMainWrapper,
.content,
.main-content,
.container,
.wrapper,
.page-wrapper {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
    width: 100% !important;
}

/* Force mobile viewport constraints */
@media (max-width: 768px) {
    * {
        max-width: 100vw !important;
    }
    
    .one-page-checkout,
    .checkout-section,
    .checkout-grid,
    .form-grid,
    .payment-methods,
    .shipping-methods {
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Specific fix for Order Summary card */
    .order-summary {
        max-width: calc(100vw - 20px) !important;
        width: calc(100vw - 20px) !important;
        margin: 0 10px !important;
        padding: 16px !important;
        box-sizing: border-box !important;
    }
    
    .order-summary .order-totals {
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    .order-summary .total-line {
        max-width: 100% !important;
        width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Fix for any remaining container issues */
    .checkout-container,
    .checkout-main,
    .checkout-sidebar {
        max-width: 100vw !important;
        width: 100% !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        box-sizing: border-box !important;
    }
}

/* Form styling fixes */
.form-group {
    width: 100%;
    margin-bottom: 16px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1em;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #495057;
}

/* Contact information and account creation sections */
.contact-info-section,
.account-creation-section {
    width: 100%;
    box-sizing: border-box;
}

.contact-info-section .form-group,
.account-creation-section .form-group {
    width: 100%;
}

/* Test mode banner */
.test-mode-banner {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 16px;
}

/* Order summary fixes */
.order-summary {
    width: 100%;
    box-sizing: border-box;
}

.order-summary .order-totals {
    width: 100%;
}

.order-summary .total-line {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Security badges */
.security-badges {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 16px;
}

.security-badges .badge {
    flex: 1;
    min-width: 80px;
    text-align: center;
    font-size: 0.8em;
}

/* Complete order button */
.complete-order-btn {
    width: 100%;
    box-sizing: border-box;
    margin-top: 16px;
}

/* Cart Summary Styles */
.cart-summary {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.cart-items {
    margin-bottom: 20px;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px 0;
    border-bottom: 1px solid #e9ecef;
    transition: opacity 0.3s ease;
}

.cart-item:last-child {
    border-bottom: none;
}

.item-details {
    flex: 1;
    margin-right: 15px;
}

.item-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.item-attributes {
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 4px;
}

.item-attribute {
    margin-bottom: 2px;
}

.item-price-per {
    font-size: 0.9em;
    color: #6c757d;
    font-style: italic;
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.quantity-form,
.remove-form {
    display: inline-block;
    margin: 0;
}

.quantity-controls {
    display: flex;
    align-items: center;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}

.qty-btn {
    background: #f8f9fa;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-weight: bold;
    color: #495057;
    transition: background-color 0.2s ease;
}

.qty-btn:hover {
    background: #e9ecef;
}

.qty-decrease {
    border-right: 1px solid #e9ecef;
}

.qty-increase {
    border-left: 1px solid #e9ecef;
}

.qty-input {
    border: none;
    padding: 8px 12px;
    width: 60px;
    text-align: center;
    font-weight: 600;
    background: white;
}

.qty-input:focus {
    outline: none;
    background: #f8f9fa;
}

.item-total {
    font-weight: 600;
    color: #2c3e50;
    min-width: 80px;
    text-align: right;
}

.remove-item-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.remove-item-btn:hover {
    background: #c82333;
}

.cart-totals {
    border-top: 2px solid #e9ecef;
    padding-top: 15px;
    margin-top: 15px;
}

.cart-totals .total-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    padding: 4px 0;
}

.cart-totals .total-line.final {
    border-top: 1px solid #dee2e6;
    font-weight: bold;
    font-size: 1.1em;
    margin-top: 12px;
    padding-top: 12px;
    color: #2c3e50;
}

.cart-actions {
    margin-top: 20px;
    text-align: center;
}

.add-more-items-btn {
    display: inline-block;
    padding: 12px 24px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    font-size: 16px;
}

.add-more-items-btn:hover {
    background: #218838;
}

.empty-cart {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px 20px;
}

/* Product Search Modal */
.product-search-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.modal-header h3 {
    margin: 0;
    color: #2c3e50;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #6c757d;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    color: #dc3545;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.search-results-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    background: #f8f9fa;
}

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.product-price {
    color: #28a745;
    font-weight: 600;
}

.add-to-cart-btn {
    background: #007bff;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.add-to-cart-btn:hover {
    background: #0056b3;
}

/* Additional mobile fixes */
@media (max-width: 768px) {
    /* Ensure all containers are full width */
    .checkout-main,
    .checkout-sidebar,
    .checkout-container {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix any remaining width constraints */
    .checkout-section > * {
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure test mode banner is full width */
    .test-mode-banner,
    .test-mode-indicator {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Fix order summary container */
    .order-summary-container {
        width: 100%;
        box-sizing: border-box;
    }
    
    /* Ensure all buttons are full width */
    .checkout-button,
    .complete-order-btn,
    #checkoutButton {
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
}

/* Fix for very small screens - ensure no horizontal scroll */
@media (max-width: 480px) {
    html, body {
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    .one-page-checkout {
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
        padding: 6px;
        margin: 0;
    }
    
    /* Ensure all parent containers are constrained */
    .content,
    .main-content,
    #contentMainWrapper,
    #mainWrapper {
        max-width: 100vw;
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Ultra-aggressive Order Summary fix */
    .order-summary {
        max-width: calc(100vw - 12px) !important;
        width: calc(100vw - 12px) !important;
        margin: 0 6px !important;
        padding: 12px !important;
        box-sizing: border-box !important;
    }
    
    /* Fix bottom navigation overflow */
    .bottom-nav,
    .mobile-nav,
    .navigation-bar,
    nav[role="navigation"] {
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* Ensure all text fits within containers */
    .order-summary *,
    .checkout-section * {
        max-width: 100% !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }
    
    /* Ensure all text wraps properly */
    .checkout-section h2,
    .checkout-section h3,
    .order-summary h3 {
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
    
    /* Fix any long text that might cause overflow */
    .order-totals .total-line {
        flex-wrap: wrap;
        word-break: break-word;
    }
}

/* Animation for loading states */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Button styles for shopping cart */
.one-page-checkout-btn, .traditional-checkout-btn {
    display: inline-block;
    padding: 12px 24px;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.one-page-checkout-btn:hover, .traditional-checkout-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    text-decoration: none;
}

.one-page-checkout-btn {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.traditional-checkout-btn {
    background: #6c757d;
    color: white;
}
