/**
 * COD Order Form - Frontend Styles
 */

/* المتغيرات */
:root {
    --cod-primary: #0d6efd;
    --cod-primary-hover: #0b5ed7;
    --cod-whatsapp: #25D366;
    --cod-whatsapp-hover: #20bd5a;
    --cod-border: #dee2e6;
    --cod-text: #212529;
    --cod-text-muted: #6c757d;
    --cod-bg: #ffffff;
    --cod-bg-light: #f8f9fa;
    --cod-success: #198754;
    --cod-error: #dc3545;
    --cod-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.075);
    --cod-radius: 8px;
}

/* Container الرئيسي */
.cod-order-wrapper {
    max-width: 500px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--cod-text);
}

/* نموذج الطلب */
.cod-form-container {
    background: var(--cod-bg);
    border: 2px solid var(--cod-primary);
    border-radius: var(--cod-radius);
    padding: 20px;
    margin-bottom: 15px;
}

.cod-order-form {
    margin: 0;
    padding: 0;
}

.cod-form-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.cod-form-group {
    flex: 1;
}

.cod-form-group input,
.cod-form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--cod-border);
    border-radius: var(--cod-radius);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.cod-form-group input:focus,
.cod-form-group select:focus {
    outline: none;
    border-color: var(--cod-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15);
}

.cod-form-group input::placeholder {
    color: var(--cod-text-muted);
}

/* التحكم في الكمية */
.cod-quantity-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: stretch;
}

.cod-quantity-control {
    display: flex;
    border: 1px solid var(--cod-border);
    border-radius: var(--cod-radius);
    overflow: hidden;
    flex-shrink: 0;
}

.cod-qty-btn {
    width: 40px;
    height: 45px;
    border: none;
    background: var(--cod-bg-light);
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    color: var(--cod-text);
    transition: background 0.2s;
}

.cod-qty-btn:hover {
    background: var(--cod-border);
}

.cod-quantity-control input {
    width: 50px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--cod-border);
    border-right: 1px solid var(--cod-border);
    font-size: 16px;
    font-weight: bold;
    -moz-appearance: textfield;
}

.cod-quantity-control input::-webkit-outer-spin-button,
.cod-quantity-control input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* زر التأكيد */
.cod-submit-btn {
    flex: 1;
    padding: 12px 20px;
    background: var(--cod-primary);
    color: white;
    border: none;
    border-radius: var(--cod-radius);
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.cod-submit-btn:hover {
    background: var(--cod-primary-hover);
}

.cod-submit-btn:active {
    transform: scale(0.98);
}

.cod-submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* زر WhatsApp */
.cod-whatsapp-row {
    margin-top: 10px;
}

.cod-whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: transparent;
    color: var(--cod-whatsapp);
    border: 2px solid var(--cod-whatsapp);
    border-radius: var(--cod-radius);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.cod-whatsapp-btn:hover {
    background: var(--cod-whatsapp);
    color: white;
}

.cod-whatsapp-btn svg {
    flex-shrink: 0;
}

/* ملخص الطلب */
.cod-summary-container {
    background: var(--cod-bg);
    border: 1px solid var(--cod-border);
    border-radius: var(--cod-radius);
    overflow: hidden;
}

.cod-summary-header {
    display: flex;
    align-items: center;
    padding: 15px;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.cod-summary-container.open .cod-summary-header {
    border-bottom-color: var(--cod-border);
}

.cod-summary-icon {
    color: var(--cod-primary);
    margin-left: 10px;
    display: flex;
}

.cod-summary-title {
    flex: 1;
    font-weight: 500;
}

.cod-summary-arrow {
    color: var(--cod-text-muted);
    transition: transform 0.2s;
    display: flex;
}

.cod-summary-container.open .cod-summary-arrow {
    transform: rotate(180deg);
}

.cod-summary-content {
    display: none;
    padding: 15px;
}

.cod-summary-container.open .cod-summary-content {
    display: block;
}

/* صورة المنتج */
.cod-product-image {
    text-align: center;
    margin-bottom: 15px;
}

.cod-product-image img {
    max-width: 150px;
    max-height: 150px;
    object-fit: contain;
    border-radius: var(--cod-radius);
}

/* عناصر الملخص */
.cod-summary-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--cod-border);
}

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

.cod-product-name {
    flex: 1;
}

.cod-product-price {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cod-qty-badge {
    background: var(--cod-primary);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.cod-total-line {
    background: var(--cod-bg-light);
    margin: 10px -15px -15px;
    padding: 15px !important;
    border-bottom: none !important;
}

/* رسالة النجاح */
.cod-success-message {
    text-align: center;
    padding: 40px 20px;
    background: var(--cod-bg);
    border: 2px solid var(--cod-success);
    border-radius: var(--cod-radius);
}

.cod-success-icon {
    color: var(--cod-success);
    margin-bottom: 20px;
}

.cod-success-title {
    font-size: 24px;
    color: var(--cod-success);
    margin: 0 0 15px;
}

.cod-success-text {
    color: var(--cod-text);
    margin: 0 0 10px;
}

.cod-order-number {
    font-size: 18px;
    font-weight: bold;
    color: var(--cod-primary);
    margin: 0;
}

/* رسالة الخطأ */
.cod-error-message {
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    color: var(--cod-error);
    padding: 15px;
    border-radius: var(--cod-radius);
    margin-bottom: 15px;
}

.cod-error {
    background: #f8d7da;
    border: 1px solid #f5c2c7;
    color: var(--cod-error);
    padding: 15px;
    border-radius: var(--cod-radius);
    text-align: center;
}

/* Loading */
.cod-loading {
    text-align: center;
    padding: 40px 20px;
}

.cod-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--cod-border);
    border-top-color: var(--cod-primary);
    border-radius: 50%;
    animation: cod-spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes cod-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive */
@media (max-width: 500px) {
    .cod-form-row {
        flex-direction: column;
    }
    
    .cod-quantity-row {
        flex-direction: column;
    }
    
    .cod-quantity-control {
        justify-content: center;
    }
    
    .cod-submit-btn {
        width: 100%;
    }
}

/* RTL Support */
[dir="rtl"] .cod-order-wrapper,
.rtl .cod-order-wrapper {
    direction: rtl;
}

[dir="rtl"] .cod-summary-icon,
.rtl .cod-summary-icon {
    margin-left: 0;
    margin-right: 10px;
}

[dir="rtl"] .cod-whatsapp-btn,
.rtl .cod-whatsapp-btn {
    flex-direction: row-reverse;
}
