/* ===================================
   Advanced Settings Modal - CSS
   עיצוב חלונית הגדרות מתקדמות
   =================================== */

/* ===================================
   Custom Fonts - גופן גליל
   =================================== */

@font-face{font-family:'Galil';font-style:normal;font-weight:300 700;font-display:swap;src:url('/assets/fonts/rubik/rubik-latin.woff2') format('woff2');unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}
@font-face{font-family:'Galil';font-style:normal;font-weight:300 700;font-display:swap;src:url('/assets/fonts/rubik/rubik-hebrew.woff2') format('woff2');unicode-range:U+0307-0308,U+0590-05FF,U+200C-2010,U+20AA,U+25CC,U+FB1D-FB4F}

/* Modal Base Styles */
.advanced-settings-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Galil', 'Heebo', sans-serif;
    letter-spacing: normal;
    direction: rtl;
}

/* Modal Overlay */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease-out;
}

/* Modal Content Container */
.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 800px;
    width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideInScale 0.3s ease-out;
    overflow: hidden;
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, #1e3a5f 0%, #162d4a 100%);
    color: white;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-header h2::before {
    content: '\f013'; /* FontAwesome cog icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 18px;
    opacity: 0.9;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

/* Modal Body */
.modal-body {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

/* Settings Container */
.settings-container {
    flex: 2;
    padding: 24px;
    overflow-y: auto;
    border-left: 1px solid #e5e7eb;
}

/* Settings Content Area */
#settingsContent {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Settings Tree Base */
.settings-tree {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Setting Category */
.setting-category {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
}

.setting-category:hover {
    border-color: #1e3a5f;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.1);
}

/* Category Header */
.category-header {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.category-header:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
}

.category-header.active {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-bottom-color: #1e3a5f;
}

/* Category Toggle Icon */
.category-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.category-toggle i {
    font-size: 12px;
    color: #6b7280;
    transition: transform 0.3s ease;
}

.category-header.active .category-toggle {
    background: #1e3a5f;
}

.category-header.active .category-toggle i {
    color: white;
    transform: rotate(180deg);
}

/* Main Category Checkbox */
.main-checkbox {
    width: 20px;
    height: 20px;
    accent-color: #1e3a5f;
    cursor: pointer;
    border-radius: 4px;
}

/* Category Title */
.category-title {
    flex: 1;
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
}

.category-header.active .category-title {
    color: #1e3a5f;
}

/* Category Icon */
.category-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.category-icon i {
    font-size: 14px;
    color: #6b7280;
}

.category-header.active .category-icon {
    background: #1e3a5f;
}

.category-header.active .category-icon i {
    color: white;
}

/* Sub-Options Container */
.sub-options {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s ease;
    background: white;
}

.sub-options.expanded {
    padding: 20px;
    max-height: none; /* 🆕 בלי חיתוך — רשימות ארוכות (מבנה/מקורות) נגללות עם החלונית */
    overflow: visible;
}

/* Sub-Option Item */
.sub-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer;
    margin-bottom: 8px;
}

.sub-option:last-child {
    margin-bottom: 0;
}

.sub-option:hover {
    background: #f1f5f9;
    transform: translateX(-4px);
}

.sub-option.checked {
    background: #dbeafe;
    border: 1px solid #93c5fd;
}

/* Sub-Option Checkbox */
.sub-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #1e3a5f;
    cursor: pointer;
}

/* Sub-Option Label */
.sub-option-label {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    cursor: pointer;
}

.sub-option.checked .sub-option-label {
    color: #1e40af;
    font-weight: 600;
}

/* Sub-Option Icon */
.sub-option-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9ca3af;
    font-size: 12px;
}

.sub-option.checked .sub-option-icon {
    color: #1e3a5f;
}

/* Saved Styles Panel */
.saved-styles-panel {
    flex: 1;
    background: #f9fafb;
    border-right: 1px solid #e5e7eb;
    padding: 24px;
    overflow-y: auto;
    min-width: 280px;
}

.saved-styles-panel h3 {
    margin: 0 0 20px 0;
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    display: flex;
    align-items: center;
    gap: 10px;
}

.saved-styles-panel h3::before {
    content: '\f0c7'; /* FontAwesome save icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    color: #1e3a5f;
    font-size: 16px;
}

/* Saved Style Item */
.saved-style-item {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.saved-style-item:hover {
    border-color: #1e3a5f;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.1);
    transform: translateY(-2px);
}

.saved-style-item.active {
    border-color: #1e3a5f;
    background: #dbeafe;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.15);
}

.style-name {
    font-size: 14px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.saved-style-item.active .style-name {
    color: #1e40af;
}

.style-description {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 8px;
    line-height: 1.4;
}

.style-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 11px;
    color: #9ca3af;
}

.style-usage {
    display: flex;
    align-items: center;
    gap: 4px;
}

.style-date {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Style Actions */
.style-actions {
    position: absolute;
    top: 12px;
    left: 12px;
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.saved-style-item:hover .style-actions {
    opacity: 1;
}

.style-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.2s ease;
}

.style-action-btn.edit {
    background: #fef3c7;
    color: #d97706;
}

.style-action-btn.delete {
    background: #fee2e2;
    color: #dc2626;
}

.style-action-btn:hover {
    transform: scale(1.1);
}

/* Modal Footer */
.modal-footer {
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    padding: 20px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Button Styles */
.btn-primary, .btn-secondary {
    padding: 12px 20px;
    border-radius: 8px;
    font-family: 'Galil', 'Heebo', sans-serif;
    letter-spacing: normal;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
}

.btn-primary {
    background: linear-gradient(135deg, #1e3a5f 0%, #162d4a 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    box-shadow: 0 6px 16px rgba(30, 58, 95, 0.4);
    transform: translateY(-2px);
}

.btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInScale {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Enhanced UI Components - שלב 7 */

/* Settings Header with Search and Controls */
.settings-header {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 16px 20px;
    margin: -24px -24px 20px -24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-search-container {
    position: relative;
}

.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.settings-search {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'Galil', 'Heebo', sans-serif;
    letter-spacing: normal;
    font-size: 14px;
    background: white;
    transition: all 0.2s ease;
    direction: rtl;
}

.settings-search:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.search-icon {
    position: absolute;
    right: 12px;
    color: #9ca3af;
    pointer-events: none;
}

.clear-search {
    position: absolute;
    left: 8px;
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-search:hover {
    color: #374151;
    background: #f3f4f6;
}

.search-results {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
    text-align: center;
}

.settings-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.settings-control-btn {
    padding: 8px 12px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: #6b7280;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.settings-control-btn:hover {
    border-color: #1e3a5f;
    color: #1e3a5f;
    background: #f8fafc;
}

/* Enhanced Category Styles */
.setting-category.enhanced {
    animation: fadeInUp 0.6s ease-out both;
}

.category-header.expanded .category-toggle i {
    transform: rotate(180deg);
}

.category-toggle {
    transition: all 0.3s ease;
}

.category-checkbox-container {
    position: relative;
    display: flex;
    align-items: center;
}

.checkbox-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(30, 58, 95, 0.3);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

.ripple-effect {
    position: absolute;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(30, 58, 95, 0.3);
    transform: scale(0);
    animation: ripple 0.6s ease-out;
    pointer-events: none;
    top: 50%;
    left: 50%;
    margin: -20px 0 0 -20px;
}

@keyframes ripple {
    to {
        transform: scale(2);
        opacity: 0;
    }
}

.category-content {
    flex: 1;
    min-width: 0;
}

.category-title-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.category-description {
    font-size: 12px;
    color: #6b7280;
    line-height: 1.4;
}

.active-count {
    background: #1e3a5f;
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Enhanced Sub-Options */
.sub-option-checkbox-container {
    position: relative;
}

.sub-option.slide-in {
    animation: slideInRight 0.3s ease-out both;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Search Highlighting */
.setting-category.search-highlight {
    border: 2px solid #1e3a5f;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.15);
}

.setting-category.search-highlight .category-header {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
}

/* Settings Summary */
.settings-summary {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    margin: 20px -24px -24px -24px;
    padding: 16px 20px;
}

.summary-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.summary-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #6b7280;
}

.summary-item i {
    color: #1e3a5f;
    width: 16px;
    text-align: center;
}

/* Notifications */
.settings-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 10001;
    font-size: 14px;
    font-family: 'Galil', 'Heebo', sans-serif;
    letter-spacing: normal;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.settings-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.settings-notification.success {
    border-color: #10b981;
    background: #f0fdf4;
}

.settings-notification.success i {
    color: #10b981;
}

.settings-notification.info {
    border-color: #1e3a5f;
    background: #eff6ff;
}

.settings-notification.info i {
    color: #1e3a5f;
}

/* Enhanced Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.setting-category.animate-in {
    animation: fadeInUp 0.6s ease-out both;
}

/* Focus States for Accessibility */
.category-header:focus,
.sub-option:focus {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
    border-radius: 4px;
}

.settings-search:focus {
    outline: 2px solid #1e3a5f;
    outline-offset: 2px;
}

/* Improved Checkbox Styling */
.main-checkbox,
.sub-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #1e3a5f;
    cursor: pointer;
    transition: all 0.2s ease;
}

.main-checkbox:checked,
.sub-checkbox:checked {
    transform: scale(1.1);
}

/* Enhanced Hover Effects */
.setting-category:hover {
    transform: translateY(-1px);
}

.sub-option:hover {
    transform: translateX(-2px);
    background: #f1f5f9;
}

/* Loading States */
.settings-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
    color: #6b7280;
}

.settings-loading i {
    animation: spin 1s linear infinite;
    margin-left: 8px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95vw;
        max-height: 95vh;
        border-radius: 12px;
    }

    .modal-body {
        flex-direction: column;
    }

    .saved-styles-panel {
        min-width: unset;
        border-right: none;
        border-top: 1px solid #e5e7eb;
        max-height: 200px;
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .settings-container {
        padding: 20px;
    }

    .modal-footer {
        padding: 16px 20px;
    }

    .modal-actions {
        flex-direction: column;
        width: 100%;
        gap: 8px;
    }

    .btn-primary, .btn-secondary {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .modal-content {
        width: 98vw;
        margin: 10px;
    }

    .category-header {
        padding: 12px 16px;
    }

    .sub-options.expanded {
        padding: 16px;
    }

    .saved-styles-panel {
        padding: 16px;
    }
}
/* ============================================================
   🆕 עץ-הגדרות קומפקטי (שטוח, בלי קופסאות) + רדיו בשורה אחת
   ============================================================ */
.settings-tree { gap: 4px !important; }

/* קטגוריה — בלי קופסה/מסגרת/צל */
.settings-tree .setting-category {
    background: none !important; border: none !important; border-radius: 0 !important;
    box-shadow: none !important; overflow: visible !important; margin: 0 0 6px !important;
}
.settings-tree .setting-category:hover { transform: none !important; border-color: transparent !important; box-shadow: none !important; }

/* כותרת-קטגוריה — שורה שטוחה עם קו-הפרדה דק */
.settings-tree .category-header {
    background: none !important; border: none !important;
    border-bottom: 1px solid var(--border-light, #e2e8f0) !important;
    padding: 7px 2px !important; display: flex; align-items: center; gap: 8px;
    cursor: pointer; box-shadow: none !important;
}
.settings-tree .category-header:hover { background: none !important; }
.settings-tree .category-header .category-title { flex: 1; font-size: 14px; font-weight: 700; color: var(--accent-primary, #1e3a5f); }
.settings-tree .cat-caret { font-size: 11px; color: var(--text-muted, #94a3b8); transition: transform 0.2s ease; }
.settings-tree .category-header:not(.active) .cat-caret { transform: rotate(-90deg); }

/* תיאור-קטגוריה */
.settings-tree .category-desc {
    font-size: 11.5px; color: var(--text-muted, #64748b);
    margin: 4px 0 2px; padding-inline-start: 20px; line-height: 1.4;
}

/* גוף האפשרויות — מוזח, קומפקטי, בלי חיתוך */
.settings-tree .sub-options {
    padding: 4px 0 2px 18px !important; background: none !important;
    max-height: none !important; overflow: visible !important;
    transition: none !important;
}
.settings-tree .sub-options:not(.expanded) { display: none; }

/* צ'קבוקס — שורה קומפקטית + תיאור-משנה קטן */
.settings-tree .opt-row { margin: 3px 0; }
.settings-tree .opt-line { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; margin: 0; }
.settings-tree .opt-line input { width: 15px; height: 15px; accent-color: var(--accent-primary, #1e3a5f); flex-shrink: 0; margin: 0; cursor: pointer; }
.settings-tree .opt-title { font-size: 13px; color: var(--text-primary, #1e293b); }
.settings-tree .opt-row.checked .opt-title { font-weight: 600; color: var(--accent-primary, #1e3a5f); }
.settings-tree .opt-desc { font-size: 11px; color: var(--text-muted, #64748b); margin: 1px 0 0; padding-inline-start: 22px; line-height: 1.35; }

/* קבוצת-רדיו בשורה אחת */
.settings-tree .radio-row { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 4px 0; }
.settings-tree .radio-row-label { font-size: 12px; font-weight: 600; color: var(--text-secondary, #475569); }
.settings-tree .radio-inline {
    display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
    font-size: 12.5px; color: var(--text-primary, #1e293b);
    padding: 2px 7px; border-radius: 6px; border: 1px solid transparent;
}
.settings-tree .radio-inline input { width: 14px; height: 14px; accent-color: var(--accent-primary, #1e3a5f); margin: 0; cursor: pointer; }
.settings-tree .radio-inline.checked { color: var(--accent-primary, #1e3a5f); font-weight: 600; background: #eef2f8; border-color: #c9d6e8; }

/* קבוצת-רדיו מקוננת תחת צ'קבוקס — מוזחת */
.settings-tree .opt-child { margin: 2px 0 5px; padding-inline-start: 20px; }
.settings-tree .opt-child .radio-row { margin: 2px 0; }

/* "בחר הכל" למקורות */
.settings-tree .select-all-row { display: block; margin-bottom: 4px; }
.settings-tree .select-all-row .opt-title { font-weight: 600; }

/* 🆕 שורת-הפעולות של "כוונון מדויק" בתוך MilaWindow */
.ww-body .ww-adv-actions {
    display: flex; gap: 8px; justify-content: flex-start; flex-wrap: wrap;
    margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--border-light, #e2e8f0);
}
.ww-body .settings-container { display: block; }
