/* ==========================================================================
   COD Order Form - Frontend Styles (Arabic / RTL)
   ========================================================================== */

/* CSS Custom Properties */
:root {
    --cod-primary: #10b981;
    --cod-primary-dark: #059669;
    --cod-primary-light: #d1fae5;
    --cod-bg: #ffffff;
    --cod-bg-secondary: #f8fafc;
    --cod-bg-form: #f1f5f9;
    --cod-border: #e2e8f0;
    --cod-border-focus: #10b981;
    --cod-text: #1e293b;
    --cod-text-secondary: #64748b;
    --cod-text-muted: #94a3b8;
    --cod-error: #ef4444;
    --cod-error-bg: #fef2f2;
    --cod-success: #10b981;
    --cod-success-bg: #ecfdf5;
    --cod-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --cod-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --cod-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --cod-radius: 12px;
    --cod-radius-sm: 8px;
    --cod-radius-full: 9999px;
    --cod-transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --cod-font: 'Tajawal', 'Inter', sans-serif;
    /* Arabic Font */
}

/* Wrapper */
.cod-form-wrapper {
    font-family: var(--cod-font);
    margin-top: 30px;
    width: 100%;
    box-sizing: border-box;
    direction: rtl;
    /* Force RTL */
}

.cod-form-wrapper *,
.cod-form-wrapper *::before,
.cod-form-wrapper *::after {
    box-sizing: border-box;
}

/* Form Container */
.cod-form-container {
    background: var(--cod-bg);
    border: 1px solid var(--cod-border);
    border-radius: var(--cod-radius);
    padding: 28px;
    box-shadow: var(--cod-shadow);
    transition: var(--cod-transition);
    position: relative;
    overflow: hidden;
}

.cod-form-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--cod-primary), #34d399, var(--cod-primary));
    background-size: 200% 100%;
    animation: cod-gradient-slide 3s ease infinite;
}

@keyframes cod-gradient-slide {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

.cod-form-container:hover {
    box-shadow: var(--cod-shadow-lg);
}

/* Form Header */
.cod-form-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--cod-border);
}

.cod-form-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: var(--cod-radius-sm);
    background: var(--cod-primary-light);
    color: var(--cod-primary);
    flex-shrink: 0;
}

.cod-form-title-wrap {
    flex: 1;
}

.cod-form-title {
    font-family: var(--cod-font);
    font-size: 20px;
    font-weight: 700;
    color: var(--cod-text);
    margin: 0 0 4px 0;
    padding: 0;
    line-height: 1.3;
}

.cod-form-subtitle {
    font-family: var(--cod-font);
    font-size: 14px;
    color: var(--cod-text-secondary);
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* Product Summary */
.cod-product-summary {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--cod-bg-secondary);
    border: 1px solid var(--cod-border);
    border-radius: var(--cod-radius-sm);
    margin-bottom: 24px;
}

.cod-product-image {
    width: 56px;
    height: 56px;
    border-radius: var(--cod-radius-sm);
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid var(--cod-border);
}

.cod-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cod-product-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cod-product-name {
    font-family: var(--cod-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--cod-text);
    line-height: 1.3;
}

.cod-product-price {
    font-family: var(--cod-font);
    font-size: 18px;
    font-weight: 700;
    color: var(--cod-primary);
}

.cod-product-price del {
    color: var(--cod-text-muted);
    font-size: 14px;
    font-weight: 400;
}

.cod-product-price ins {
    text-decoration: none;
}

/* Form Sections */
.cod-form-section {
    margin-bottom: 20px;
}

.cod-form-section-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--cod-font);
    font-size: 13px;
    font-weight: 600;
    color: var(--cod-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--cod-border);
}

.cod-form-section-label svg {
    color: var(--cod-primary);
}

/* Form Groups */
.cod-form-group {
    margin-bottom: 16px;
}

.cod-form-group:last-child {
    margin-bottom: 0;
}

.cod-label {
    display: block;
    font-family: var(--cod-font);
    font-size: 14px;
    font-weight: 500;
    color: var(--cod-text);
    margin-bottom: 6px;
}

.cod-required {
    color: var(--cod-error);
    font-weight: 600;
}

/* Input Wrapper */
.cod-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.cod-input-icon {
    position: absolute;
    right: 12px;
    /* RTL */
    left: auto;
    /* RTL override */
    top: 50%;
    transform: translateY(-50%);
    color: var(--cod-text-muted);
    pointer-events: none;
    z-index: 1;
    transition: var(--cod-transition);
}

.cod-textarea-icon {
    top: 16px;
    transform: none;
}

/* Inputs */
.cod-input {
    width: 100%;
    padding: 11px 42px 11px 14px;
    /* RTL padding */
    font-family: var(--cod-font);
    font-size: 14px;
    color: var(--cod-text);
    background: var(--cod-bg);
    border: 1.5px solid var(--cod-border);
    border-radius: var(--cod-radius-sm);
    outline: none;
    transition: var(--cod-transition);
    appearance: none;
    -webkit-appearance: none;
}

.cod-textarea-wrapper .cod-input {
    min-height: auto;
    resize: vertical;
}

.cod-input::placeholder {
    color: var(--cod-text-muted);
    font-size: 13px;
}

.cod-input:hover {
    border-color: #cbd5e1;
}

.cod-input:focus {
    border-color: var(--cod-border-focus);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.cod-input:focus+.cod-input-icon,
.cod-input:focus~.cod-input-icon {
    color: var(--cod-primary);
}

/* Select */
.cod-select {
    padding-left: 40px;
    /* RTL */
    padding-right: 42px;
    /* RTL */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    /* RTL */
    background-size: 18px;
    cursor: pointer;
}

/* Error Messages */
.cod-error-message {
    display: none;
    font-family: var(--cod-font);
    font-size: 12px;
    color: var(--cod-error);
    margin-top: 4px;
    padding-right: 4px;
    /* RTL */
    animation: cod-shake 0.4s ease;
}

.cod-error-message.active {
    display: block;
}

.cod-input.cod-input-error {
    border-color: var(--cod-error);
    background: var(--cod-error-bg);
}

.cod-input.cod-input-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

@keyframes cod-shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(4px);
    }

    /* RTL Shake direction flipped */
    50% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}

/* Order Total */
.cod-order-total {
    margin: 24px 0 20px;
    padding: 18px;
    background: linear-gradient(135deg, #f0fdf4 0%, #ecfdf5 50%, #d1fae5 100%);
    border: 1px solid #a7f3d0;
    border-radius: var(--cod-radius-sm);
}

.cod-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cod-total-label {
    font-family: var(--cod-font);
    font-size: 15px;
    font-weight: 600;
    color: var(--cod-text);
}

.cod-total-value {
    font-family: var(--cod-font);
    font-size: 22px;
    font-weight: 700;
    color: var(--cod-primary-dark);
}

.cod-total-value del {
    font-size: 14px;
    color: var(--cod-text-muted);
    font-weight: 400;
}

.cod-total-value ins {
    text-decoration: none;
}

.cod-payment-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--cod-font);
    font-size: 12px;
    font-weight: 500;
    color: var(--cod-primary-dark);
    background: rgba(16, 185, 129, 0.12);
    padding: 5px 12px;
    border-radius: var(--cod-radius-full);
}

/* Submit Button */
.cod-submit-btn {
    width: 100%;
    padding: 16px 24px;
    font-family: var(--cod-font);
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    background: linear-gradient(135deg, var(--btn-color, var(--cod-primary)), color-mix(in srgb, var(--btn-color, var(--cod-primary)), #000 15%));
    border: none;
    border-radius: var(--cod-radius-sm);
    cursor: pointer;
    transition: var(--cod-transition);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.cod-submit-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, transparent 50%);
    transition: var(--cod-transition);
}

.cod-submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.cod-submit-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.cod-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.cod-btn-text,
.cod-btn-loading {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Spinner */
.cod-spinner {
    animation: cod-spin 1s linear infinite;
}

@keyframes cod-spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* Security Note */
.cod-security-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 14px;
    font-family: var(--cod-font);
    font-size: 12px;
    color: var(--cod-text-muted);
}

.cod-security-note svg {
    color: var(--cod-primary);
    flex-shrink: 0;
}

/* Success Message */
.cod-success-message {
    text-align: center;
    padding: 40px 20px;
    animation: cod-fade-in 0.5s ease;
}

@keyframes cod-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cod-success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--cod-success-bg);
    color: var(--cod-success);
    margin-bottom: 20px;
    animation: cod-bounce 0.6s ease;
}

@keyframes cod-bounce {
    0% {
        transform: scale(0);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

.cod-success-title {
    font-family: var(--cod-font);
    font-size: 24px;
    font-weight: 700;
    color: var(--cod-text);
    margin: 0 0 10px 0;
}

.cod-success-text {
    font-family: var(--cod-font);
    font-size: 15px;
    color: var(--cod-text-secondary);
    margin: 0 0 18px 0;
    line-height: 1.6;
}

.cod-order-number {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--cod-font);
    font-size: 14px;
    font-weight: 600;
    color: var(--cod-primary-dark);
    background: var(--cod-primary-light);
    padding: 10px 20px;
    border-radius: var(--cod-radius-full);
}

/* Responsive */
@media (max-width: 600px) {
    .cod-form-container {
        padding: 20px 16px;
    }

    .cod-form-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .cod-form-title {
        font-size: 18px;
    }

    .cod-product-summary {
        flex-direction: column;
        text-align: center;
    }

    .cod-product-image {
        width: 64px;
        height: 64px;
    }

    .cod-total-value {
        font-size: 20px;
    }

    .cod-submit-btn {
        padding: 14px 20px;
        font-size: 15px;
    }
}