/* ===============================================
   Content Switcher Pro for Elementor - Main CSS
   =============================================== */

/* Base Wrapper */
.cs-wrapper {
    max-width: 100%;
    margin: 0 auto;
    position: relative;
}

/* ===============================================
   Switcher Container
   =============================================== */
.cs-switcher-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%);
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    flex-wrap: wrap;
}

/* ===============================================
   STYLE 1: Toggle Switch (Original)
   =============================================== */
.cs-style-toggle .cs-switcher-label {
    font-size: 22px;
    font-weight: 700;
    transition: all 0.3s ease;
    cursor: pointer;
    user-select: none;
    color: #9e9e9e;
}

.cs-style-toggle .cs-switcher-label.active {
    color: #2c5234;
}

.cs-style-toggle .cs-switcher-label:hover {
    transform: scale(1.05);
}

.cs-toggle {
    position: relative;
    display: inline-block;
    width: 80px;
    height: 40px;
    cursor: pointer;
}

.cs-toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.cs-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #ffd54f 0%, #ffb300 100%);
    border-radius: 34px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* الدائرة البيضاء = عنصر حقيقي يحتوي الأيقونة (لا تخرج من الإطار) */
.cs-toggle-thumb {
    position: absolute;
    height: 32px;
    width: 32px;
    left: 4px;
    bottom: 4px;
    top: auto;
    background-color: white;
    border-radius: 50%;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
    transform: translateX(40px);
}

/* الأيقونات داخل الدائرة البيضاء فقط */
.cs-toggle-thumb .cs-toggle-icon {
    position: absolute;
    inset: 0;
    font-size: 16px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    overflow: hidden;
}

.cs-toggle-thumb .cs-toggle-icon-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    font-size: inherit;
    line-height: 1;
}

.cs-toggle-thumb .cs-toggle-icon-1 {
    opacity: 1;
    visibility: visible;
}
.cs-toggle-thumb .cs-toggle-icon-2 {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb .cs-toggle-icon-1 {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    display: none !important;
}
.cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb .cs-toggle-icon-2 {
    opacity: 1;
    visibility: visible;
    display: flex !important;
    transform: rotate(180deg);
}

.cs-toggle-input:checked + .cs-toggle-slider {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
}

.cs-toggle:hover .cs-toggle-slider {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

/* ===============================================
   STYLE 2: Buttons
   =============================================== */
.cs-switcher-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.cs-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 25px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 30px;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    white-space: nowrap;
}

.cs-switcher-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.cs-switcher-btn.active {
    background: linear-gradient(135deg, #66bb6a 0%, #43a047 100%);
    border-color: #43a047;
    color: white;
    box-shadow: 0 5px 15px rgba(67, 160, 71, 0.3);
}

.cs-btn-icon {
    font-size: 20px;
    line-height: 1;
}

/* ===============================================
   STYLE 3: Pills
   =============================================== */
.cs-style-pills .cs-switcher-buttons {
    background: #f5f5f5;
    padding: 5px;
    border-radius: 50px;
    gap: 5px;
}

.cs-style-pills .cs-switcher-btn {
    background: transparent;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
}

.cs-style-pills .cs-switcher-btn.active {
    background: white;
    color: #2c5234;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* ===============================================
   STYLE 4: Tabs
   =============================================== */
.cs-style-tabs .cs-switcher-container {
    background: transparent;
    padding: 0;
    box-shadow: none;
    border-bottom: 2px solid #e0e0e0;
    border-radius: 0;
}

.cs-style-tabs .cs-switcher-buttons {
    gap: 0;
}

.cs-style-tabs .cs-switcher-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    padding: 15px 25px;
    position: relative;
}

.cs-style-tabs .cs-switcher-btn:hover {
    transform: none;
    background: #f5f5f5;
}

.cs-style-tabs .cs-switcher-btn.active {
    background: transparent;
    border-bottom-color: #43a047;
    color: #43a047;
    box-shadow: none;
}

/* ===============================================
   STYLE 5: Radio Buttons
   =============================================== */
.cs-switcher-radio {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.cs-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    color: #666;
    user-select: none;
}

.cs-radio-label input[type="radio"] {
    appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.cs-radio-label input[type="radio"]:checked {
    border-color: #43a047;
}

.cs-radio-label input[type="radio"]:checked:after {
    content: '';
    position: absolute;
    width: 10px;
    height: 10px;
    background: #43a047;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.cs-radio-label input[type="radio"]:checked ~ span {
    color: #43a047;
}

/* ===============================================
   STYLE 6: Dropdown
   =============================================== */
.cs-switcher-dropdown {
    width: 100%;
    max-width: 300px;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
}

.cs-switcher-dropdown:hover {
    border-color: #43a047;
}

.cs-switcher-dropdown:focus {
    border-color: #43a047;
    box-shadow: 0 0 0 3px rgba(67, 160, 71, 0.1);
}

/* ===============================================
   Content Area
   =============================================== */
.cs-content-wrapper {
    position: relative;
    min-height: 200px;
    margin-top: 30px;
    overflow: hidden; /* Prevent content overflow during transition */
    transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cs-content {
    opacity: 0;
    visibility: hidden;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

.cs-content.active {
    opacity: 1;
    visibility: visible;
    position: relative;
}

/* Content Styling */
.cs-content h2,
.cs-content h3 {
    color: #2c5234;
    margin-bottom: 15px;
    margin-top: 0;
}

.cs-content h2 {
    font-size: 28px;
}

.cs-content h3 {
    font-size: 22px;
}

.cs-content p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 10px;
}

.cs-content ul {
    list-style: none;
    padding: 0;
    margin: 15px 0;
}

.cs-content ul li {
    padding: 10px 0;
    border-bottom: 1px solid #e0e0e0;
}

.cs-content ul li:last-child {
    border-bottom: none;
}

/* ===============================================
   Responsive Design
   =============================================== */
@media (max-width: 768px) {
    .cs-switcher-container {
        gap: 10px;
        padding: 12px 20px;
    }
    
    .cs-style-toggle .cs-switcher-label {
        font-size: 18px;
    }
    
    .cs-toggle {
        width: 70px;
        height: 35px;
    }
    
    .cs-toggle-thumb {
        height: 28px;
        width: 28px;
        left: 3px;
        bottom: 3px;
    }
    
    .cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
        transform: translateX(35px);
    }
    
    .cs-toggle-thumb .cs-toggle-icon {
        font-size: 14px;
    }
    
    .cs-switcher-btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .cs-content {
        padding: 20px;
    }
    
    .cs-content h2 {
        font-size: 24px;
    }
    
    .cs-content h3 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .cs-switcher-container {
        gap: 8px;
        padding: 10px 15px;
    }
    
    .cs-style-toggle .cs-switcher-label {
        font-size: 16px;
    }
    
    .cs-toggle {
        width: 60px;
        height: 30px;
    }
    
    .cs-toggle-thumb {
        height: 24px;
        width: 24px;
        left: 3px;
        bottom: 3px;
    }
    
    .cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
        transform: translateX(30px);
    }
    
    .cs-toggle-thumb .cs-toggle-icon {
        font-size: 12px;
    }
    
    .cs-switcher-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .cs-content {
        padding: 15px;
    }
    
    .cs-content h2 {
        font-size: 20px;
    }
    
    .cs-content h3 {
        font-size: 18px;
    }
}

/* ===============================================
   RTL Support
   =============================================== */
[dir="rtl"] .cs-toggle-thumb {
    left: auto;
    right: 4px;
}

[dir="rtl"] .cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
    transform: translateX(-40px);
}

@media (max-width: 768px) {
    [dir="rtl"] .cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
        transform: translateX(-35px);
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .cs-toggle-input:checked + .cs-toggle-slider .cs-toggle-thumb {
        transform: translateX(-30px);
    }
}

/* ===============================================
   Elementor Editor
   =============================================== */
.elementor-editor-active .cs-content {
    pointer-events: all;
    opacity: 1 !important;
    visibility: visible !important;
    position: relative !important;
    margin-bottom: 20px;
}

.elementor-editor-active .cs-content:not(.active) {
    border: 2px dashed #ccc;
    background: #f9f9f9;
}

.elementor-editor-active .cs-content:not(.active)::before {
    content: "المحتوى مخفي (سيظهر عند اختياره في الموقع)";
    display: block;
    background: #ff9800;
    color: white;
    padding: 5px 10px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 12px;
    font-weight: bold;
}

/* ===============================================
   Print Styles
   =============================================== */
@media print {
    .cs-switcher-container {
        display: none;
    }
    
    .cs-content {
        opacity: 1 !important;
        visibility: visible !important;
        position: relative !important;
        transform: none !important;
    }
}

/* ===============================================
   Loading State
   =============================================== */
.cs-wrapper.loading .cs-content {
    pointer-events: none;
}

/* ===============================================
   Accessibility
   =============================================== */
.cs-switcher-btn:focus,
.cs-toggle:focus-within,
.cs-radio-label:focus-within,
.cs-switcher-dropdown:focus {
    outline: 2px solid #43a047;
    outline-offset: 2px;
}

/* ===============================================
   Custom Scrollbar for Content
   =============================================== */
.cs-content::-webkit-scrollbar {
    width: 8px;
}

.cs-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.cs-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.cs-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ===============================================
   Notice Messages for Templates & Sections
   =============================================== */
.cs-notice {
    background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%);
    border-inline-start: 4px solid #ff9800;
    padding: 15px 20px;
    border-radius: 8px;
    margin: 20px 0;
    font-size: 16px;
    font-weight: 500;
    color: #e65100;
    box-shadow: 0 2px 8px rgba(255, 152, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.cs-notice::before {
    content: "⚠️";
    font-size: 24px;
}

/* Template Content Wrapper */
.cs-content[data-content-type="template"],
.cs-content[data-content-type="section"] {
    min-height: 100px;
}

/* Loading State */
.cs-content.loading {
    position: relative;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cs-content.loading::after {
    content: "جاري التحميل...";
    font-size: 18px;
    color: #666;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
