/**
 * Frontend CSS for B-Tech WhatsApp Checkout
 */

/* Commander Button Styles */
.btech-commander-btn {
    background-color: #fff; /* Bright yellow from Elementor globals */
    color: #FFB300; /* Darker yellow/orange from Elementor globals */
    border: none;
    padding: 12px 24px;
    border-radius: 100px; /* Pill shape from Elementor */
    font-family: 'Roboto', sans-serif; /* From Elementor typography */
    font-size: 13px; /* From Elementor typography */
    font-weight: 600; /* From Elementor typography */
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    box-shadow: none;
    text-shadow: 0px 0px 10px rgba(0,0,0,0.3); /* From Elementor text shadow */
    min-height: 40px; /* Ensure consistent height */
    white-space: nowrap; /* Prevent text wrapping */
}

.btech-commander-btn:hover {
    background-color: #fff; /* Slightly lighter yellow on hover */
    color: #FF8F00; /* Darker text on hover */
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.btech-commander-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

.btech-commander-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.3);
}

.btech-commander-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    pointer-events: none;
}

@keyframes btech-wa-spinner {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Popup Styles */
.btech-wa-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    padding: 0;
    margin: 0;
}

.btech-wa-popup.show {
    opacity: 1;
    visibility: visible;
}

/* Disable background scrolling when popup is open */
body.btech-wa-popup-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.btech-wa-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.btech-wa-popup-content {
    position: relative;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
}

.btech-wa-popup.show .btech-wa-popup-content {
    transform: scale(1) translateY(0);
}

.btech-wa-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.btech-wa-popup-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.btech-wa-popup-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.btech-wa-popup-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.btech-wa-popup-body {
    padding: 0 24px 24px;
}

/* Product Preview */
.btech-wa-product-preview {
    display: flex;
    gap: 16px;
    padding: 20px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid #e5e7eb;
}

.btech-wa-product-image {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btech-wa-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.btech-wa-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.btech-wa-product-info h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.4;
}

.btech-wa-product-price {
    font-size: 20px;
    font-weight: 700;
    color: #25D366;
    margin-bottom: 4px;
}

.btech-wa-product-stock {
    font-size: 14px;
    color: #6b7280;
}

/* Form Styles */
.btech-wa-order-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.btech-wa-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.btech-wa-form-group {
    display: flex;
    flex-direction: column;
}

/* Quantity field specific styles */
.btech-wa-quantity-group {
    display: flex;
    flex-direction: column;
}

.btech-wa-quantity-input {
    display: flex;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 120px; /* Smaller width for quantity */
}

.btech-wa-quantity-input:focus-within {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.btech-wa-quantity-btn {
    background: #f3f4f6;
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #374151;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
}

.btech-wa-quantity-btn:hover {
    background: #e5e7eb;
    color: #1f2937;
}

.btech-wa-quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btech-wa-quantity-btn:first-child {
    border-radius: 6px 0 0 6px;
    border-right: 1px solid #e5e7eb;
}

.btech-wa-quantity-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: 1px solid #e5e7eb;
}

.btech-wa-quantity-input input {
    flex: 1;
    border: none;
    padding: 8px 4px;
    font-size: 16px;
    background: transparent;
    outline: none;
    text-align: center;
    font-weight: 600;
    color: #374151;
}

.btech-wa-quantity-input input:focus {
    box-shadow: none;
}

.btech-wa-quantity-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.btech-wa-form-group label {
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
    font-size: 14px;
}

.btech-wa-form-group input,
.btech-wa-form-group textarea {
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: white;
    width: 100%;
    box-sizing: border-box;
}

.btech-wa-form-group input:focus,
.btech-wa-form-group textarea:focus {
    outline: none;
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.btech-wa-form-group input.error,
.btech-wa-form-group textarea.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.btech-wa-form-group input[readonly] {
    background: #f3f4f6;
    color: #6b7280;
    cursor: not-allowed;
}

.btech-wa-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Phone input with country code */
.btech-wa-phone-input {
    display: flex;
    align-items: center;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    transition: all 0.2s ease;
    width: 100%;
    min-width: 0; /* Prevents flex overflow */
}

.btech-wa-phone-input:focus-within {
    border-color: #25D366;
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.btech-wa-country-code {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f3f4f6;
    border-right: 1px solid #e5e7eb;
    font-weight: 600;
    color: #374151;
    font-size: 14px;
    white-space: nowrap;
    border-radius: 6px 0 0 6px;
}

.btech-wa-phone-input input {
    flex: 1;
    border: none;
    padding: 12px 16px;
    font-size: 16px;
    background: transparent;
    outline: none;
    border-radius: 0 6px 6px 0;
}

.btech-wa-phone-input input:focus {
    box-shadow: none;
}

.btech-wa-phone-input.error {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Form Actions */
.btech-wa-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
}

.btech-wa-btn {
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
    min-height: 48px; /* Fixed height to prevent shifting */
    position: relative;
}

.btech-wa-btn-primary {
    background: linear-gradient(135deg, #25D366, #128C7E);
    color: white;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btech-wa-btn-primary:hover {
    background: linear-gradient(135deg, #128C7E, #25D366);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btech-wa-btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Loading state - just disable button */
.btech-wa-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
}

.btech-wa-btn-secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btech-wa-btn-secondary:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Messages */
.btech-wa-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin: 16px 0;
    font-weight: 500;
    animation: slideDown 0.3s ease;
}

.btech-wa-message-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.btech-wa-message-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Commander Button Mobile Styles */
    .btech-commander-btn {
        font-size: 11px;
        padding: 8px 16px;
        min-height: 32px;
    }
    
    .btech-wa-popup {
        padding: 0;
        align-items: center;
        justify-content: center;
    }
    
    .btech-wa-popup-content {
        width: calc(100vw - 30px);
        max-width: 500px;
        margin: 15px;
        max-height: calc(100vh - 30px);
        overflow-y: auto;
        border-radius: 12px;
    }
    
    .btech-wa-popup-header {
        padding: 15px 20px 0;
        position: sticky;
        top: 0;
        background: white;
        z-index: 10;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .btech-wa-popup-header h3 {
        font-size: 18px;
        margin-bottom: 5px;
    }
    
    .btech-wa-popup-close {
        font-size: 24px;
        width: 28px;
        height: 28px;
    }
    
    .btech-wa-popup-body {
        padding: 0 20px 20px;
    }
    
    .btech-wa-form-row {
        display: flex;
        gap: 8px;
        width: 100%;
    }
    
    .btech-wa-form-row .btech-wa-form-group,
    .btech-wa-form-row .btech-wa-quantity-group {
        flex: 1;
        min-width: 0; /* Prevents flex items from overflowing */
    }
    
    .btech-wa-quantity-input {
        max-width: 100px; /* Smaller on mobile */
    }
    
    .btech-wa-quantity-btn {
        padding: 6px 10px;
        font-size: 14px;
        min-width: 32px;
    }
    
    .btech-wa-quantity-input input {
        padding: 6px 2px;
        font-size: 14px;
    }
    
    .btech-wa-product-preview {
        flex-direction: row;
        text-align: left;
        padding: 15px;
        margin-bottom: 20px;
    }
    
    .btech-wa-product-image {
        width: 60px;
        height: 60px;
        margin-right: 15px;
        flex-shrink: 0;
    }
    
    .btech-wa-product-info h4 {
        font-size: 16px;
        margin-bottom: 5px;
    }
    
    .btech-wa-product-price {
        font-size: 18px;
        margin-bottom: 2px;
    }
    
    .btech-wa-product-stock {
        font-size: 12px;
    }
    
    .btech-wa-order-form {
        gap: 15px;
    }
    
    .btech-wa-form-group input,
    .btech-wa-form-group textarea {
        padding: 10px 12px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btech-wa-country-code {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .btech-wa-phone-input input {
        padding: 10px 12px;
        font-size: 16px;
    }
    
    .btech-wa-form-actions {
        flex-direction: column;
        gap: 10px;
        position: sticky;
        bottom: 0;
        background: white;
        padding: 15px 0;
        margin: 0 -20px;
        padding-left: 20px;
        padding-right: 20px;
        border-top: 1px solid #e5e7eb;
    }
    
    .btech-wa-btn {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
        font-size: 15px;
    }
}

@media (max-width: 480px) {
    /* Commander Button Small Mobile Styles */
    .btech-commander-btn {
        font-size: 10px;
        padding: 6px 12px;
        min-height: 28px;
        border-radius: 50px; /* Slightly less rounded on very small screens */
    }
    
    .btech-wa-popup {
        padding: 0;
        align-items: center;
        justify-content: center;
    }
    
    .btech-wa-popup-content {
        width: calc(100vw - 20px);
        max-width: 100%;
        margin: 10px;
        max-height: calc(100vh - 20px);
        border-radius: 8px;
    }
    
    .btech-wa-popup-header {
        padding: 12px 16px 0;
    }
    
    .btech-wa-popup-header h3 {
        font-size: 16px;
    }
    
    .btech-wa-popup-close {
        font-size: 20px;
        width: 24px;
        height: 24px;
    }
    
    .btech-wa-popup-body {
        padding: 0 16px 16px;
    }
    
    .btech-wa-product-preview {
        padding: 12px;
        margin-bottom: 15px;
    }
    
    .btech-wa-product-image {
        width: 50px;
        height: 50px;
        margin-right: 12px;
    }
    
    .btech-wa-product-info h4 {
        font-size: 14px;
    }
    
    .btech-wa-product-price {
        font-size: 16px;
    }
    
    .btech-wa-order-form {
        gap: 12px;
    }
    
    .btech-wa-form-row {
        display: flex;
        gap: 6px;
        width: 100%;
    }
    
    .btech-wa-form-row .btech-wa-form-group,
    .btech-wa-form-row .btech-wa-quantity-group {
        flex: 1;
        min-width: 0; /* Prevents flex items from overflowing */
    }
    
    .btech-wa-quantity-input {
        max-width: 90px; /* Even smaller on very small mobile */
    }
    
    .btech-wa-quantity-btn {
        padding: 5px 8px;
        font-size: 12px;
        min-width: 28px;
    }
    
    .btech-wa-quantity-input input {
        padding: 5px 1px;
        font-size: 12px;
    }
    
    .btech-wa-form-group input,
    .btech-wa-form-group textarea {
        padding: 8px 10px;
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btech-wa-country-code {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .btech-wa-phone-input input {
        padding: 8px 10px;
        font-size: 16px;
    }
    
    .btech-wa-form-actions {
        padding: 12px 0;
        margin: 0 -16px;
        padding-left: 16px;
        padding-right: 16px;
    }
    
    .btech-wa-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* Loading States */
.btech-wa-popup-content.loading {
    pointer-events: none;
}

.btech-wa-popup-content.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #25D366;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Accessibility */
.btech-wa-popup:focus-within {
    outline: none;
}

.btech-wa-popup-content:focus {
    outline: 2px solid #25D366;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btech-wa-popup-content {
        border: 2px solid #000;
    }
    
    .btech-wa-form-group input,
    .btech-wa-form-group textarea {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .btech-wa-popup,
    .btech-wa-popup-content,
    .btech-wa-btn,
    .btech-wa-message {
        transition: none;
    }
    
    .btech-wa-popup.show .btech-wa-popup-content {
        transform: none;
    }
}
