/**
 * CS Modal System
 * מערכת מודאלים - RTL support
 */

/* Modal Overlay */
.cs-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.cs-modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Modal Container */
.cs-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.9) translateY(-20px);
    transition: transform 0.3s ease;
    direction: rtl;
    text-align: right;
}

.cs-modal-overlay.show .cs-modal {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.cs-modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 15px;
}

.cs-modal-header.info {
    background: #e8f4fd;
    border-bottom-color: #b8daff;
}

.cs-modal-header.success {
    background: #e8f5e9;
    border-bottom-color: #c8e6c9;
}

.cs-modal-header.warning {
    background: #fff8e1;
    border-bottom-color: #ffecb3;
}

.cs-modal-header.error {
    background: #ffebee;
    border-bottom-color: #ffcdd2;
}

.cs-modal-header.confirm {
    background: #fff8e1;
    border-bottom-color: #ffecb3;
}

/* Modal Icon */
.cs-modal-icon {
    font-size: 28px;
    line-height: 1;
}

.cs-modal-header.info .cs-modal-icon {
    color: #0073aa;
}

.cs-modal-header.success .cs-modal-icon {
    color: #46b450;
}

.cs-modal-header.warning .cs-modal-icon,
.cs-modal-header.confirm .cs-modal-icon {
    color: #f0b849;
}

.cs-modal-header.error .cs-modal-icon {
    color: #dc3232;
}

/* Modal Title */
.cs-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #1e1e1e;
}

/* Modal Body */
.cs-modal-body {
    padding: 25px;
    max-height: calc(90vh - 180px);
    overflow-y: auto;
}

.cs-modal-message {
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    margin: 0 0 15px 0;
}

.cs-modal-message:last-child {
    margin-bottom: 0;
}

/* Modal Details */
.cs-modal-details {
    background: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
}

.cs-modal-details p {
    margin: 5px 0;
    font-size: 13px;
    color: #666;
}

.cs-modal-details strong {
    color: #333;
}

/* Modal Footer / Actions */
.cs-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-start;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Modal Buttons */
.cs-modal-btn {
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    min-width: 100px;
}

.cs-modal-btn-primary {
    background: #0073aa;
    color: #fff;
}

.cs-modal-btn-primary:hover {
    background: #005a87;
}

.cs-modal-btn-secondary {
    background: #f0f0f0;
    color: #444;
    border: 1px solid #ddd;
}

.cs-modal-btn-secondary:hover {
    background: #e0e0e0;
}

.cs-modal-btn-danger {
    background: #dc3232;
    color: #fff;
}

.cs-modal-btn-danger:hover {
    background: #b52727;
}

.cs-modal-btn-success {
    background: #46b450;
    color: #fff;
}

.cs-modal-btn-success:hover {
    background: #3a9a42;
}

.cs-modal-btn-warning {
    background: #f0b849;
    color: #333;
}

.cs-modal-btn-warning:hover {
    background: #d9a53e;
}

/* Close Button (X) in header */
.cs-modal-close-btn {
    margin-right: auto;
    margin-left: 0;
    background: none;
    border: none;
    font-size: 26px;
    color: #999;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s ease;
}

.cs-modal-close-btn:hover {
    color: #333;
}

/* Input in Modal */
.cs-modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
    margin-top: 10px;
    direction: ltr;
    text-align: left;
}

.cs-modal-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

/* Loading Spinner in Modal */
.cs-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 30px;
}

.cs-modal-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: cs-spin 1s linear infinite;
}

@keyframes cs-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 600px) {
    .cs-modal {
        width: 95%;
        margin: 10px;
    }

    .cs-modal-header {
        padding: 15px 20px;
    }

    .cs-modal-body {
        padding: 20px;
    }

    .cs-modal-actions {
        flex-direction: column;
    }

    .cs-modal-btn {
        width: 100%;
    }
}
