/**
 * Custom Admin Sidebar Styles
 * גווני תכלת-אפור, מינימליסטי, RTL
 */

:root {
    --cas-primary: #a8c0ed;
    --cas-primary-dark: #8aabde;
    --cas-primary-light: #c2d4f3;
    --cas-bg-main: #f8f9fb;
    --cas-bg-sidebar: #ffffff;
    --cas-text-primary: #2c3e50;
    --cas-text-secondary: #7f8c9a;
    --cas-border: #e1e4e8;
    --cas-hover: #f0f4f8;
    --cas-shadow: rgba(168, 192, 237, 0.1);
    --cas-shadow-hover: rgba(168, 192, 237, 0.2);
}

/* הסרת הadmin bar המקורי */
body.has-custom-sidebar {
    padding-top: 0 !important;
}

body.has-custom-sidebar.admin-bar {
    padding-top: 0 !important;
}

#wpadminbar {
    display: none !important;
}

/* Container ראשי */
#cas-sidebar-root {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    direction: rtl;
}

/* מצב צף */
#cas-sidebar-root.floating {
    position: fixed;
    /* top ו-left יקבעו דינמית מה-JS */
    right: auto;
    height: auto;
    max-height: calc(100vh - 40px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    overflow: hidden;
    transition: none; /* ללא אנימציה בגרירה */
}

/* במצב גרירה */
#cas-sidebar-root.floating.dragging {
    transition: none;
    box-shadow: 0 8px 30px rgba(168, 192, 237, 0.4);
}

/* הסיידבר עצמו */
.cas-sidebar {
    position: relative;
    height: 100vh;
    background: var(--cas-bg-sidebar);
    border-left: 1px solid var(--cas-border);
    box-shadow: -2px 0 8px var(--cas-shadow);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* מצב צף */
.floating .cas-sidebar {
    height: auto;
    max-height: calc(100vh - 40px);
    border-radius: 12px;
    border: 1px solid var(--cas-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.cas-sidebar.collapsed {
    width: 80px;
}

.cas-sidebar.expanded {
    width: 200px;
}

/* מצב המבורגר (צף + מכווץ) */
.floating .cas-sidebar.hamburger {
    width: 60px !important;
    height: 60px !important;
    border-radius: 50%;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(168, 192, 237, 0.3);
}

.floating .cas-sidebar.hamburger .cas-header {
    padding: 0;
    border: none;
    background: var(--cas-primary);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    justify-content: center;
}

.floating .cas-sidebar.hamburger .cas-header-controls,
.floating .cas-sidebar.hamburger .cas-logo {
    display: none;
}

.floating .cas-sidebar.hamburger .cas-hamburger-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--cas-primary);
}

.floating .cas-sidebar.hamburger .cas-hamburger-btn:hover {
    background: var(--cas-primary-dark);
    transform: scale(1.1);
}

/* כפתור המבורגר */
.cas-hamburger-btn svg {
    width: 24px;
    height: 24px;
}

/* הסרת Resize Handle */
.cas-resize-handle {
    display: none;
}

/* Header */
.cas-header {
    padding: 16px;
    border-bottom: 1px solid var(--cas-border);
    background: linear-gradient(135deg, var(--cas-primary-light) 0%, var(--cas-bg-sidebar) 100%);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: relative;
}

/* ידית גרירה */
.cas-drag-handle {
    position: absolute;
    left: 50%;
    top: 8px;
    transform: translateX(-50%);
    width: 40px;
    height: 6px;
    cursor: grab;
    display: none;
    z-index: 100;
}

/* הצג רק במצב צף */
.floating .cas-drag-handle {
    display: block;
}

.cas-drag-handle.dragging {
    cursor: grabbing;
}

.cas-drag-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 100%;
}

.cas-drag-dots span {
    width: 4px;
    height: 4px;
    background: var(--cas-text-secondary);
    border-radius: 50%;
    transition: background 0.2s;
}

.cas-drag-handle:hover .cas-drag-dots span {
    background: var(--cas-primary);
}

.cas-drag-handle.dragging .cas-drag-dots span {
    background: var(--cas-primary-dark);
}

/* דחיפת התוכן למטה במצב צף */
.floating .cas-header {
    padding-top: 24px;
}

.cas-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex: 1;
}

/* כפתור Toggle */
.cas-toggle-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cas-primary);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cas-toggle-btn:hover {
    background: var(--cas-primary-dark);
    transform: scale(1.05);
}

.cas-toggle-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* קבוצת כפתורי בקרה */
.cas-header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* כפתור מצב צף */
.cas-float-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--cas-hover);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.cas-float-btn:hover {
    background: var(--cas-primary-light);
}

.cas-float-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--cas-text-secondary);
}

.cas-float-btn.active {
    background: var(--cas-primary);
}

.cas-float-btn.active svg {
    fill: white;
}

/* במצב מכווץ - הסתר טקסטים */
.cas-sidebar.collapsed .cas-logo-text {
    display: none;
}

.cas-sidebar.collapsed .cas-header-controls {
    flex-direction: column;
    gap: 4px;
}

.cas-sidebar.collapsed .cas-float-btn,
.cas-sidebar.collapsed .cas-toggle-btn {
    width: 32px;
    height: 32px;
}

.cas-logo-icon {
    width: 32px;
    height: 32px;
    fill: var(--cas-primary);
    transition: transform 0.3s;
}

.cas-sidebar:hover .cas-logo-icon {
    transform: scale(1.1);
}

.cas-logo-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--cas-text-primary);
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
}

.cas-sidebar.expanded .cas-logo-text {
    opacity: 1;
}

/* User Section */
.cas-user-section {
    padding: 16px;
    border-bottom: 1px solid var(--cas-border);
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.cas-user-section:hover {
    background: var(--cas-hover);
}

.cas-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--cas-primary);
    flex-shrink: 0;
}

.cas-user-info {
    flex: 1;
    min-width: 0;
    opacity: 0;
    transition: opacity 0.3s;
}

.cas-sidebar.expanded .cas-user-info {
    opacity: 1;
}

.cas-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--cas-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cas-user-role {
    font-size: 12px;
    color: var(--cas-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Menu Container */
.cas-menu-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 0;
}

/* Custom Scrollbar */
.cas-menu-container::-webkit-scrollbar {
    width: 6px;
}

.cas-menu-container::-webkit-scrollbar-track {
    background: transparent;
}

.cas-menu-container::-webkit-scrollbar-thumb {
    background: var(--cas-border);
    border-radius: 3px;
}

.cas-menu-container::-webkit-scrollbar-thumb:hover {
    background: var(--cas-primary);
}

/* Menu Items */
.cas-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin: 2px 8px;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    color: var(--cas-text-primary);
    transition: all 0.2s;
    position: relative;
}

/* פריט "אופציות נוספות" - קטן יותר */
.cas-menu-item.more-options {
    padding: 8px 16px;
    margin-top: 16px;
    border-top: 1px solid var(--cas-border);
    opacity: 0.7;
}

.cas-menu-item.more-options .cas-menu-text {
    font-size: 12px;
    font-weight: 400;
}

.cas-menu-item.more-options .cas-menu-icon {
    width: 16px;
    height: 16px;
}

.cas-menu-item:hover {
    background: var(--cas-hover);
    transform: translateX(-2px);
}

.cas-menu-item.active {
    background: var(--cas-primary);
    color: white;
    box-shadow: 0 2px 8px var(--cas-shadow-hover);
}

.cas-menu-item.active .cas-menu-icon {
    fill: white;
}

/* Menu Icon */
.cas-menu-icon {
    width: 20px;
    height: 20px;
    fill: var(--cas-primary);
    flex-shrink: 0;
    transition: fill 0.2s;
}

.cas-menu-item:hover .cas-menu-icon {
    fill: var(--cas-primary-dark);
}

/* Menu Text */
.cas-menu-text {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s;
    flex: 1;
}

.cas-sidebar.expanded .cas-menu-text {
    opacity: 1;
}

/* Submenu */
.cas-submenu {
    margin-right: 32px;
    margin-top: 4px;
    display: none;
}

.cas-menu-item.has-children.open + .cas-submenu,
.cas-menu-item-wrapper .cas-submenu {
    display: block;
}

/* תת-תפריט של "אופציות נוספות" - יותר קומפקטי */
.cas-submenu.more-options-sub {
    margin-right: 24px;
    max-height: 300px;
    overflow-y: auto;
}

.cas-submenu.more-options-sub::-webkit-scrollbar {
    width: 4px;
}

.cas-submenu.more-options-sub::-webkit-scrollbar-thumb {
    background: var(--cas-border);
    border-radius: 2px;
}

.cas-submenu-item,
.cas-submenu .cas-menu-item {
    padding: 8px 16px;
    font-size: 13px;
    color: var(--cas-text-secondary);
    border-right: 2px solid transparent;
    transition: all 0.2s;
    display: block;
    text-decoration: none;
}

.cas-submenu-item:hover,
.cas-submenu .cas-menu-item:hover {
    color: var(--cas-primary-dark);
    border-right-color: var(--cas-primary);
    background: var(--cas-hover);
}

/* פריטים בתוך "אופציות נוספות" - עוד יותר קטנים */
.more-options-sub .cas-menu-item {
    padding: 6px 12px;
    margin: 1px 4px;
    font-size: 12px;
}

.more-options-sub .cas-menu-text {
    font-size: 12px;
}

.more-options-sub .cas-menu-icon {
    width: 14px;
    height: 14px;
}

/* Chevron for expandable items */
.cas-menu-chevron {
    width: 16px;
    height: 16px;
    fill: var(--cas-text-secondary);
    transition: transform 0.3s;
    margin-right: auto;
}

.cas-menu-item.open .cas-menu-chevron {
    transform: rotate(90deg);
}

/* Footer */
.cas-footer {
    padding: 12px;
    border-top: 1px solid var(--cas-border);
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
}

.cas-footer-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.cas-footer-btn:hover {
    background: var(--cas-hover);
}

.cas-footer-btn svg {
    width: 20px;
    height: 20px;
    fill: var(--cas-text-secondary);
}

.cas-footer-btn:hover svg {
    fill: var(--cas-primary-dark);
}

/* Animations */
@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.cas-sidebar {
    animation: slideInRight 0.3s ease-out;
}

/* Responsive */
@media screen and (max-width: 782px) {
    .cas-sidebar {
        width: 80px !important;
    }

    .cas-menu-text,
    .cas-user-info,
    .cas-logo-text {
        display: none !important;
    }
}

/* ================================
   דחיפת תוכן בניהול
   ================================ */

/* Container ראשי - תמיד */
body.has-custom-sidebar:not(.cas-floating) #wpcontent {
    margin-right: 80px !important;
    margin-left: 0 !important;
    transition: margin-right 0.3s;
}

body.has-custom-sidebar.cas-expanded:not(.cas-floating) #wpcontent {
    margin-right: 200px !important;
}

/* תוכן פנימי - אפס את ה-margin */
body.has-custom-sidebar:not(.cas-floating) #wpbody-content {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* ================================
   רשימת פוסטים (list view)
   ================================ */

/* השולחן והטפסים */
body.has-custom-sidebar:not(.cas-floating) .wrap {
    margin-right: 0 !important;
    margin-left: 0 !important;
    max-width: 100% !important;
}

body.has-custom-sidebar:not(.cas-floating) .wp-list-table {
    margin-right: 0 !important;
}

/* ================================
   עריכת פוסט בודד (edit view)
   ================================ */

/* עורך גוטנברג/בלוקים - דחיפה בסיסית (מכווץ) */
body.has-custom-sidebar:not(.cas-floating) #editor,
body.has-custom-sidebar:not(.cas-floating) .block-editor__container {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

body.has-custom-sidebar:not(.cas-floating) .edit-post-layout,
body.has-custom-sidebar:not(.cas-floating) .editor-editor-interface,
body.has-custom-sidebar:not(.cas-floating) .interface-interface-skeleton {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* ← *** זה מה שחסר! דחיפה כשמורחבים *** */
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .edit-post-layout,
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .editor-editor-interface,
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .interface-interface-skeleton {
    margin-right: 0 !important;  /* לא צריך margin כי #wpcontent כבר דוחף */
    margin-left: 0 !important;
}

/* Header */
body.has-custom-sidebar:not(.cas-floating) .edit-post-header,
body.has-custom-sidebar:not(.cas-floating) .interface-interface-skeleton__header {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* אזור התוכן */
body.has-custom-sidebar:not(.cas-floating) .interface-interface-skeleton__content {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* Classic Editor */
body.has-custom-sidebar:not(.cas-floating) #poststuff,
body.has-custom-sidebar:not(.cas-floating) #post-body {
    margin-right: 0 !important;
    margin-left: 0 !important;
}

/* העורך עצמו - ממורכז */
body.has-custom-sidebar:not(.cas-floating) .editor-styles-wrapper,
body.has-custom-sidebar:not(.cas-floating) .block-editor-writing-flow {
    margin-right: auto !important;
    margin-left: auto !important;
}
/* עורך גוטנברג - מצב מכווץ (80px) */
body.has-custom-sidebar:not(.cas-floating) .edit-post-layout,
body.has-custom-sidebar:not(.cas-floating) .editor-editor-interface,
body.has-custom-sidebar:not(.cas-floating) .interface-interface-skeleton {
    margin-right: 80px !important;
    margin-left: 0 !important;
}

/* עורך גוטנברג - מצב מורחב (200px) */
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .edit-post-layout,
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .editor-editor-interface,
body.has-custom-sidebar.cas-expanded:not(.cas-floating) .interface-interface-skeleton {
    margin-right: 200px !important;
    margin-left: 0 !important;
}

/* מצב צף - בלי דחיפה */
body.has-custom-sidebar.cas-floating .edit-post-layout,
body.has-custom-sidebar.cas-floating .editor-editor-interface,
body.has-custom-sidebar.cas-floating .interface-interface-skeleton {
    margin-right: 0 !important;
}
/* ================================
   דחיפת תוכן בחזית
   ================================ */

body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) {
    margin-right: 80px !important;
    transition: margin-right 0.3s;
}

body.has-custom-sidebar.cas-expanded:not(.wp-admin):not(.cas-floating) {
    margin-right: 200px !important;
}

/* ודא שכל התוכן זז */
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) * {
    box-sizing: border-box;
}

/* במקרה שיש wrapper ראשי */
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) > div,
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) #page,
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) #content,
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) .site,
body.has-custom-sidebar:not(.wp-admin):not(.cas-floating) #wrapper {
    margin-right: 0 !important;
    max-width: 100% !important;
}

/* ================================
   מצב צף - אפס הכל
   ================================ */

body.has-custom-sidebar.cas-floating #wpcontent,
body.has-custom-sidebar.cas-floating:not(.wp-admin) {
    margin-right: 0 !important;
    padding-right: 0;
}

/* Tooltip for collapsed state */
.cas-tooltip {
    position: absolute;
    right: calc(100% + 8px);
    background: var(--cas-text-primary);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1000;
}

.cas-menu-item:hover .cas-tooltip {
    opacity: 1;
}

.cas-sidebar.expanded .cas-tooltip {
    display: none;
}
