/**
 * Frontend styles for WooCommerce One-Page COD
 */

/* COD Button Styles */
.woc-button-container {
    margin: 15px 0;
}

.woc-cod-button {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    min-height: 50px;
    width: 100%;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.woc-cod-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.woc-cod-button:active {
    transform: translateY(0);
}

.woc-button-icon {
    display: flex;
    align-items: center;
}

.woc-button-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.woc-button-text {
    font-size: 16px;
    font-weight: 600;
}

.woc-button-subtitle {
    font-size: 12px;
    opacity: 0.8;
    font-weight: normal;
}

/* Modal Styles */
.woc-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.woc-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.woc-modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
}

.woc-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
}

.woc-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.woc-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.woc-modal-close:hover {
    background-color: #f5f5f5;
}

.woc-modal-body {
    padding: 25px;
}

/* Product Summary */
.woc-product-summary {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.woc-product-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
}

.woc-product-details {
    flex: 1;
}

.woc-product-details h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.woc-product-price {
    font-size: 18px;
    font-weight: 600;
    color: #2c5282;
    margin-bottom: 10px;
}

.woc-product-quantity {
    display: flex;
    align-items: center;
    gap: 10px;
}

.woc-product-quantity label {
    font-weight: 500;
    margin: 0;
}

.woc-product-quantity input {
    width: 80px;
    padding: 5px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

/* Form Styles */
.woc-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.woc-form-section {
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 20px;
}

.woc-form-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.woc-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.woc-form-row:last-child {
    margin-bottom: 0;
}

.woc-form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.woc-form-field label {
    font-weight: 500;
    font-size: 14px;
    color: #333;
    margin: 0;
}

.woc-form-field .required {
    color: #e53e3e;
}

.woc-form-field input,
.woc-form-field select,
.woc-form-field textarea {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.woc-form-field input:focus,
.woc-form-field select:focus,
.woc-form-field textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.woc-form-field.error input,
.woc-form-field.error select,
.woc-form-field.error textarea {
    border-color: #e53e3e;
}

.woc-field-error {
    color: #e53e3e;
    font-size: 12px;
    margin-top: 2px;
}

/* Width classes */
.woc-width-full {
    grid-column: 1 / -1;
}

.woc-width-half {
    grid-column: span 1;
}

/* Order Summary */
.woc-order-summary {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
}

.woc-order-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.woc-order-line.woc-total {
    font-weight: 600;
    font-size: 16px;
    border-top: 1px solid #ddd;
    padding-top: 8px;
    margin-top: 8px;
    margin-bottom: 0;
}

/* Form Actions */
.woc-form-actions {
    margin-top: 20px;
}

.woc-submit-button {
    width: 100%;
    padding: 15px;
    background: #0073aa;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
}

.woc-submit-button:hover {
    background: #005a87;
}

.woc-submit-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.woc-submit-button.loading {
    position: relative;
    color: transparent;
}

.woc-submit-button.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #ffffff;
    border-top: 2px solid transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Form Messages */
.woc-form-messages {
    margin-top: 15px;
}

.woc-message {
    padding: 12px 15px;
    border-radius: 6px;
    margin-bottom: 10px;
}

.woc-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.woc-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Radio and Checkbox Styles */
.woc-radio-group,
.woc-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.woc-radio-option,
.woc-checkbox-option {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.woc-radio-option:hover,
.woc-checkbox-option:hover {
    background-color: #f5f5f5;
}

.woc-checkbox-single {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

/* Responsive Design */
@media (max-width: 768px) {
    .woc-modal-content {
        width: 95%;
        margin: 10px;
        max-height: 95vh;
    }
    
    .woc-modal-header,
    .woc-modal-body {
        padding: 15px;
    }
    
    .woc-form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .woc-product-summary {
        flex-direction: column;
        text-align: center;
    }
    
    .woc-product-image {
        align-self: center;
    }
    
    .woc-cod-button {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .woc-button-text {
        font-size: 14px;
    }
    
    .woc-button-subtitle {
        font-size: 11px;
    }
}

/* Embedded Form Mode */
.woc-form-embedded .woc-modal {
    position: static;
    width: auto;
    height: auto;
    z-index: auto;
}

.woc-form-embedded .woc-modal-overlay {
    display: none;
}

.woc-form-embedded .woc-modal-content {
    position: static;
    max-width: none;
    width: 100%;
    max-height: none;
    overflow: visible;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

/* Animations */
.woc-modal.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.woc-modal.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Sticky Mobile Button */
@media (max-width: 768px) {
    .woc-cod-button.woc-sticky-mobile {
        position: fixed;
        bottom: 20px;
        left: 20px;
        right: 20px;
        z-index: 9999;
        width: calc(100% - 40px) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3) !important;
        animation: none !important; /* Disable animations for sticky buttons */
    }
    
    .woc-cod-button.woc-sticky-mobile:hover {
        transform: none; /* Disable hover transforms for sticky buttons */
    }
}

/* Button Hover Effects */
.woc-cod-button:hover {
    background-color: var(--woc-button-hover-bg, #005a87);
}

/* Dynamic CSS Variables (will be set via PHP) */
.woc-cod-button {
    --woc-button-hover-bg: #005a87;
}

/* Shipping Rates Styles */
.woc-shipping-section {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.woc-shipping-section h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.woc-shipping-rates {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.woc-shipping-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    color: #666;
    font-size: 14px;
}

.woc-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: woc-spin 1s linear infinite;
}

@keyframes woc-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.woc-shipping-rate {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.woc-shipping-rate:hover {
    border-color: #0073aa;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.1);
}

.woc-shipping-rate.selected {
    border-color: #0073aa;
    background: #f0f8ff;
}

.woc-shipping-rate input[type="radio"] {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    margin: 0;
}

.woc-shipping-rate-content {
    margin-left: 30px;
}

.woc-shipping-rate-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.woc-shipping-rate-title {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.woc-shipping-rate-cost {
    font-weight: 600;
    color: #0073aa;
    font-size: 14px;
}

.woc-shipping-rate-cost.free {
    color: #00a32a;
}

.woc-shipping-rate-description {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.woc-no-shipping-rates {
    text-align: center;
    padding: 20px;
    color: #666;
    font-style: italic;
}

/* Mobile Shipping Styles */
@media (max-width: 768px) {
    .woc-shipping-section {
        margin: 15px 0;
        padding: 15px;
    }
    
    .woc-shipping-rate {
        padding: 12px;
    }
    
    .woc-shipping-rate-content {
        margin-left: 25px;
    }
    
    .woc-shipping-rate-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}
