/* --- Form Container --- */
.cod-direct-form {
    background: #f9f9f9;
    padding: 25px;
    border-radius: 8px;
    margin: 20px auto;
    border: 1px solid #e5e5e5;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    max-width: 700px;
}

.cod-direct-form h3,
.cod-direct-form h4 {
    text-align: center;
    margin-bottom: 20px;
    color: #333;
}

.cod-divider {
    height: 3px;
    border-radius: 2px;
    width: 90%;
    margin: 0 auto 20px auto;
    background-color: var(--cod-btn-bg, #8e44ad);
}

/* --- Input Fields --- */
.cod-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.cod-form-field {
    flex: 1;
    margin-bottom: 15px;
}

.cod-form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #444;
}

.cod-form-field input,
.cod-form-field textarea,
.cod-form-field select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    background: #fff;
    transition: all 0.3s;
}

/* Fix select dropdown text alignment issues on WooCommerce checkout page */
.cod-form-field select,
#cod-direct-checkout-form select,
#cod-direct-checkout-form .cod-form-field select {
    height: auto !important;
    min-height: 45px !important;
    line-height: 1.4 !important;
    padding: 10px 12px !important;
    vertical-align: middle !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 12px !important;
    padding-right: 35px !important;
}

/* Fix Focus Color */
.cod-form-field input:focus,
.cod-form-field select:focus,
.cod-form-field textarea:focus {
    border-color: var(--cod-btn-bg, #8e44ad) !important;
    outline: none;
    box-shadow: 0 0 0 1px var(--cod-btn-bg, #8e44ad);
}

/* --- Quantity Selector --- */
.quantity-selector {
    display: flex;
    align-items: center;
    max-width: 150px;
}

.qty-btn {
    background-color: var(--cod-btn-bg, #8e44ad) !important;
    color: var(--cod-btn-text, #ffffff) !important;
    border: none !important;
    width: 40px;
    height: 40px;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.qty-btn:hover {
    opacity: 0.9;
}

.qty-btn.minus {
    border-radius: 4px 0 0 4px;
}

.qty-btn.plus {
    border-radius: 0 4px 4px 0;
}

.quantity-selector input,
.quantity-selector input[type="number"],
#cod-direct-checkout-form .quantity-selector input {
    width: 50px !important;
    min-width: 50px !important;
    text-align: center !important;
    border: 1px solid #ccc !important;
    border-left: none !important;
    border-right: none !important;
    height: 40px !important;
    margin: 0 !important;
    padding: 0 5px !important;
    border-radius: 0 !important;
    font-weight: bold !important;
    font-size: 16px !important;
    line-height: 40px !important;
    color: #333 !important;
    background-color: #fff !important;
    -moz-appearance: textfield !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
}

/* Hide number input spinners */
.quantity-selector input::-webkit-outer-spin-button,
.quantity-selector input::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}

/* Ensure input is visible on focus too */
.quantity-selector input:focus {
    color: #333 !important;
    background-color: #fff !important;
    outline: none !important;
}

/* --- Order Summary Box --- */
.cod-order-summary {
    background: #fff;
    padding: 20px;
    border-radius: 6px;
    margin: 20px 0;
    border: 1px solid #eee;
}

.summary-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    color: #555;
}

.summary-line.total {
    font-weight: bold;
    font-size: 1.3em;
    border-top: 2px solid #eee;
    padding-top: 15px;
    color: #000;
}

/* --- Submit Button --- */
.cod-submit-btn {
    width: 100% !important;
    max-width: 100% !important;
    margin-top: 20px;
    display: block !important;
    box-sizing: border-box !important;

    /* Force Custom Colors over Theme Defaults */
    background-color: var(--cod-btn-bg, #8e44ad) !important;
    color: var(--cod-btn-text, #ffffff) !important;
    border: none !important;

    /* Old Style: Dimensions and Typography */
    padding: 15px 25px !important;
    font-size: 16px !important;
    font-weight: 700;
    font-family: inherit;
    border-radius: 4px !important;
    cursor: pointer;
    text-transform: none !important;
    letter-spacing: 0.3px;
    line-height: 1.4;
    text-align: center !important;
    transition: box-shadow 0.2s ease, filter 0.2s ease;

    /* For marquee effect */
    overflow: hidden;
    position: relative;
}

/* Button text wrapper for marquee effect */
.cod-submit-btn .btn-text {
    display: inline-block;
    white-space: nowrap;
    padding-right: 30px;
    /* Space at end when scrolling */
}

/* Active marquee animation */
.cod-submit-btn.marquee-active .btn-text {
    animation: cod-marquee var(--marquee-duration, 8s) ease-in-out infinite;
}

/* Marquee animation - smooth scroll left then back */
@keyframes cod-marquee {

    0%,
    15% {
        transform: translateX(0);
    }

    50% {
        transform: translateX(var(--marquee-offset, -50%));
    }

    85%,
    100% {
        transform: translateX(0);
    }
}

/* For buttons with short text that doesn't need scrolling */
.cod-submit-btn.no-marquee .btn-text {
    animation: none;
    padding-right: 0;
}

/* Responsive button text for smaller screens */
@media (max-width: 480px) {
    .cod-submit-btn {
        font-size: 14px !important;
        padding: 12px 15px !important;
    }
}

.cod-submit-btn:hover {
    filter: brightness(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: var(--cod-btn-bg, #8e44ad) !important;
    color: var(--cod-btn-text, #ffffff) !important;
}

.cod-submit-btn:disabled {
    background: #ccc !important;
    cursor: not-allowed;
    opacity: 0.7;
}

/* --- Messages --- */
.cod-messages .cod-message {
    padding: 12px;
    border-radius: 4px;
    margin-top: 10px;
    text-align: center;
    font-weight: 500;
}

.cod-messages .cod-message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.cod-messages .cod-message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@media (max-width: 768px) {
    .cod-form-row {
        flex-direction: column;
        gap: 0;
        margin-bottom: 0;
    }
}

/* --- Shipping Button Styles --- */
#shipping-method-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.shipping-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    background-color: #fff;
    flex-grow: 1;
    text-align: center;
    min-width: 120px;
}

.shipping-button input[type="radio"] {
    display: none;
}

.shipping-button.active {
    border-color: var(--cod-btn-bg, #8e44ad) !important;
    background-color: #f9f9f9;
    color: var(--cod-btn-bg, #8e44ad);
}

.shipping-button-title {
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 4px;
}

.shipping-button-price {
    font-size: 0.9em;
    color: #666;
}

/* --- Custom Thank You Page Styles --- */
.cod-direct-thank-you-shortcode-wrapper {
    background: #ffffff;
    border: 1px solid #e7e7e7;
    padding: 30px;
    border-radius: 8px;
    text-align: center;
    margin: 2em auto;
    max-width: 800px;
}

.cod-ty-icon-wrapper {
    margin: 0 auto 25px auto;
}

.cod-ty-icon {
    width: 90px;
    height: 90px;
    margin: auto;
    border-radius: 50%;
    background-color: var(--cod-ty-icon-bg, #4CAF50);
    position: relative;
}

.cod-ty-icon::after {
    content: '';
    position: absolute;
    left: 30px;
    top: 15px;
    width: 20px;
    height: 40px;
    border: solid #fff;
    border-width: 0 8px 8px 0;
    transform: rotate(45deg);
}

.cod-ty-title {
    font-size: 2.4em;
    font-weight: 700;
    color: #333;
}

.cod-ty-subtitle {
    display: inline-block;
    background-color: var(--cod-ty-icon-bg, #4CAF50);
    color: #fff;
    padding: 10px 25px;
    border-radius: 50px;
}

.cod-ty-next-steps {
    margin: 40px 0;
    text-align: right;
}

.cod-ty-next-steps-title {
    display: inline-block;
    background-color: var(--cod-ty-step-bg, #d9534f);
    color: #fff;
    padding: 10px 25px;
    border-radius: 6px;
}

.cod-ty-next-steps ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cod-ty-next-steps li {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 18px;
    margin-bottom: 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    text-align: right;
    gap: 15px;
}

.cod-ty-next-steps li .dashicons {
    font-size: 32px;
    width: 32px;
    height: 32px;
    color: var(--cod-ty-icon-bg, #4CAF50);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cod-ty-contact {
    margin: 40px 0;
    font-size: 1.2em;
}

.cod-ty-phone-number {
    font-weight: 800;
    font-size: 1.4em;
    color: #333;
}

.cod-ty-footer {
    font-size: 1.1em;
    font-weight: bold;
    color: #444;
    margin-top: 30px;
}

.cod-ty-summary-shortcode-wrapper {
    margin-top: 40px;
    border-top: 2px dashed #eee;
    padding-top: 30px;
}

.cod-ty-summary-title {
    text-align: right;
    font-size: 1.6em;
}

.cod-ty-summary-shortcode-wrapper table.shop_table {
    width: 100%;
    text-align: right;
    border-collapse: collapse;
}

.cod-ty-summary-shortcode-wrapper table.shop_table th,
.cod-ty-summary-shortcode-wrapper table.shop_table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    text-align: right;
}

/* --- Loading Overlay --- */
.cod-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    border-radius: 8px;
}

.cod-loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top-color: var(--cod-btn-bg, #8e44ad);
    border-radius: 50%;
    animation: cod-spin 0.8s linear infinite;
}

@keyframes cod-spin {
    to {
        transform: rotate(360deg);
    }
}

.cod-loading-text {
    margin-top: 15px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.cod-direct-form {
    position: relative;
}

/* --- Phone Validation Error --- */
.cod-field-error {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
}

.cod-form-field.has-error input {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 1px #dc3545 !important;
}

.cod-form-field.has-error .cod-field-error {
    display: block;
}

/* --- Custom Order Summary Styles --- */
.cod-order-summary-custom {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    padding: 25px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.cod-os-title {
    font-size: 22px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.cod-os-order-number {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 12px 15px;
    margin-bottom: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cod-os-order-number .cod-os-label {
    color: #6c757d;
    font-size: 14px;
}

.cod-os-order-number .cod-os-value {
    font-weight: 700;
    color: #1a1a1a;
    font-size: 16px;
}

.cod-os-products {
    margin-bottom: 20px;
}

.cod-os-product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cod-os-product-item:last-child {
    border-bottom: none;
}

.cod-os-product-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cod-os-product-name {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 15px;
}

.cod-os-product-qty {
    color: #6c757d;
    font-size: 13px;
}

.cod-os-product-price {
    font-weight: 600;
    color: #1a1a1a;
    font-size: 15px;
}

.cod-os-totals {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 20px;
}

.cod-os-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.cod-os-row .cod-os-label {
    color: #6c757d;
    font-size: 14px;
}

.cod-os-row .cod-os-value {
    font-weight: 600;
    color: #1a1a1a;
}

.cod-os-row.cod-os-total {
    border-top: 2px solid #dee2e6;
    margin-top: 8px;
    padding-top: 12px;
}

.cod-os-row.cod-os-total .cod-os-label {
    font-weight: 700;
    color: #1a1a1a;
    font-size: 16px;
}

.cod-os-row.cod-os-total .cod-os-value {
    font-size: 18px;
    color: #28a745;
}

.cod-os-payment-method {
    text-align: center;
    margin-bottom: 20px;
}

.cod-os-payment-badge {
    display: inline-block;
    padding: 8px 20px;
    border-radius: 20px;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cod-os-delivery-info {
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    border-radius: 8px;
    padding: 15px;
    border-left: 4px solid #4CAF50;
}

.cod-os-delivery-title {
    font-weight: 700;
    color: #2e7d32;
    font-size: 14px;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cod-os-delivery-details {
    color: #1a1a1a;
    font-size: 15px;
    margin-bottom: 5px;
}

.cod-os-delivery-phone a {
    color: #2e7d32;
    font-weight: 600;
    text-decoration: none;
}

.cod-os-delivery-phone a:hover {
    text-decoration: underline;
}

/* RTL Support */
[dir="rtl"] .cod-os-order-number,
[dir="rtl"] .cod-os-product-item,
[dir="rtl"] .cod-os-row {
    flex-direction: row-reverse;
}

[dir="rtl"] .cod-os-delivery-info {
    border-left: none;
    border-right: 4px solid #4CAF50;
}

/* Custom Truck Icon (WordPress dashicons doesn't have a truck) */
/* Uses CSS mask so icon inherits color from parent like other dashicons */
.dashicons.dashicons-truck {
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 8h-3V4H3c-1.1 0-2 .9-2 2v11h2c0 1.66 1.34 3 3 3s3-1.34 3-3h6c0 1.66 1.34 3 3 3s3-1.34 3-3h2v-5l-3-4zM6 18.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm13.5-9l1.96 2.5H17V9.5h2.5zm-1.5 9c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M20 8h-3V4H3c-1.1 0-2 .9-2 2v11h2c0 1.66 1.34 3 3 3s3-1.34 3-3h6c0 1.66 1.34 3 3 3s3-1.34 3-3h2v-5l-3-4zM6 18.5c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5zm13.5-9l1.96 2.5H17V9.5h2.5zm-1.5 9c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5z'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background-color: currentColor;
    display: inline-block;
    vertical-align: middle;
}

.dashicons.dashicons-truck::before {
    content: "" !important;
    display: none;
}