/**
 * web-modules.css  — v3.3 – Modern Redesign
 * Scoped under .web-modules-content-panel
 * A fresh, card‑based UI with smooth interactions, modern colors, and subtle animations.
 */

/* ──────────────────────────────────────────────────────
   CSS Variables – Modern palette & spacing
   ────────────────────────────────────────────────────── */
.web-modules-content-panel {
    --wm-primary: #4361ee;
    --wm-primary-dark: #3a56d4;
    --wm-secondary: #7209b7;
    --wm-success: #06d6a0;
    --wm-warning: #ff9e00;
    --wm-danger: #ef476f;
    --wm-text: #2d3748;
    --wm-text-light: #718096;
    --wm-bg: #f7fafc;
    --wm-surface: #ffffff;
    --wm-border: #e2e8f0;
    --wm-border-light: #edf2f7;
    --wm-shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --wm-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --wm-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --wm-radius: 12px;
    --wm-radius-sm: 8px;
    --wm-transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, sans-serif;
    font-size: 14px;
    color: var(--wm-text);
    background: var(--wm-bg);
    padding: 1rem;
    box-sizing: border-box;
}

/* ── Global Reset for internal elements ── */
.web-modules-content-panel *,
.web-modules-content-panel *::before,
.web-modules-content-panel *::after {
    box-sizing: inherit;
}

.web-modules-content-panel #search-container-web-modules {
    display: none !important;
}

/* ── Loader Animation ───────────────────────────────── */
.wm-global-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    gap: 1rem;
    color: var(--wm-text-light);
}
.wm-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--wm-border);
    border-top-color: var(--wm-primary);
    border-radius: 50%;
    animation: wm-spin 0.8s linear infinite;
}
@keyframes wm-spin {
    to { transform: rotate(360deg); }
}

/* ── Main Layout ────────────────────────────────────── */
.wm-layout {
    display: block;
    min-height: 70vh;
}

/* ── Panel Card ────────────────────────────────────── */
.wm-panel {
    background: var(--wm-surface);
    border-radius: var(--wm-radius);
    box-shadow: var(--wm-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    backdrop-filter: blur(2px);
    transition: box-shadow 0.2s;
/*    max-height: 90vh;
    overflow-y: auto;*/
}
.wm-panel:hover {
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.02);
}

/* ── Panel Header ──────────────────────────────────── */
.wm-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-bottom: 1px solid var(--wm-border-light);
    gap: 1rem;
}
.wm-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: -0.01em;
    color: var(--wm-text);
}
.wm-panel-title svg {
    width: 22px;
    height: 22px;
    fill: var(--wm-primary);
    stroke: none;
}

/* ── Menu Tabs (Pill style) ────────────────────────── */
.wm-menu-tabs-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem 1.5rem 0;
    background: var(--wm-surface);
    border-bottom: 1px solid var(--wm-border-light);
}
.wm-menu-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1.2rem;
    background: transparent;
    border: 1px solid var(--wm-border);
    border-radius: 100px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--wm-text-light);
    cursor: pointer;
    transition: var(--wm-transition);
}
.wm-menu-tab:hover {
    background: var(--wm-primary);
    border-color: var(--wm-primary);
    color: white;
    transform: translateY(-1px);
}
.wm-menu-tab.active {
    background: var(--wm-primary);
    border-color: var(--wm-primary);
    color: white;
    box-shadow: var(--wm-shadow-sm);
}
.wm-count-chip {
    background: rgba(0,0,0,0.1);
    border-radius: 20px;
    padding: 0.15rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 600;
}
.wm-menu-tab.active .wm-count-chip {
    background: rgba(255,255,255,0.2);
    color: white;
}

/* ── Menu Meta (Location badges) ───────────────────── */
.wm-menu-meta {
    display: flex;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    background: #fefefe;
    border-bottom: 1px solid var(--wm-border-light);
}
.wm-meta-pill {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--wm-text-light);
    background: var(--wm-border-light);
    padding: 0.2rem 0.8rem;
    border-radius: 30px;
}

/* ── Items Container ───────────────────────────────── */
.wm-menu-items-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0 1rem;
}
.wm-menu-items-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.75rem 0 0.5rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wm-text-light);
    border-bottom: 1px solid var(--wm-border-light);
}
.wm-hint {
    font-weight: 400;
    font-size: 0.7rem;
    color: #94a3b8;
}
.wm-menu-items-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 4rem;
}

/* ── Individual Menu Items (Card-like) ─────────────── */
.wm-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    background: var(--wm-surface);
    border: 1px solid var(--wm-border);
    border-radius: var(--wm-radius-sm);
    transition: var(--wm-transition);
    cursor: default;
    box-shadow: var(--wm-shadow-sm);
}
.wm-menu-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--wm-shadow-md);
    border-color: var(--wm-primary);
}
.wm-menu-item-child {
    border-left: 4px solid var(--wm-primary);
    background: #fefefe;
}
.wm-mi-drag {
    font-size: 1.2rem;
    color: #cbd5e0;
    cursor: grab;
    user-select: none;
    transition: color 0.2s;
}
.wm-mi-drag:active { cursor: grabbing; }
.wm-menu-item:hover .wm-mi-drag { color: var(--wm-primary); }
.wm-mi-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}
.wm-mi-info {
    flex: 1;
    min-width: 0;
}
.wm-mi-title {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wm-mi-url {
    font-size: 0.7rem;
    color: var(--wm-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.wm-mi-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.2s;
}
.wm-menu-item:hover .wm-mi-actions {
    opacity: 1;
}

/* ── Buttons (including Show Page) ─────────────────── */
.wm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.4rem 0.9rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: var(--wm-transition);
    background: transparent;
    color: var(--wm-text-light);
    line-height: 1;
}
.wm-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.wm-btn-xs {
    padding: 0.25rem 0.6rem;
    font-size: 0.7rem;
}
.wm-btn-sm {
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
}
.wm-btn-primary {
    background: var(--wm-primary);
    color: white;
    box-shadow: var(--wm-shadow-sm);
}
.wm-btn-primary:hover:not(:disabled) {
    background: var(--wm-primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--wm-shadow-md);
}
.wm-btn-ghost {
    background: #f1f5f9;
    border: 1px solid var(--wm-border);
}
.wm-btn-ghost:hover:not(:disabled) {
    background: #e2e8f0;
    border-color: #cbd5e1;
}
.wm-btn-accent {
    background: linear-gradient(135deg, var(--wm-primary), var(--wm-secondary));
    color: white;
}
.wm-btn-accent:hover:not(:disabled) {
    opacity: 0.9;
    transform: translateY(-1px);
}
.wm-btn-accent.active {
    background: linear-gradient(135deg, #3a56d4, #5e2a8a);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.3);
}
.wm-btn-danger {
    background: #fff5f5;
    color: #ef476f;
    border: 1px solid #fed7d7;
}
.wm-btn-danger:hover:not(:disabled) {
    background: #ffe3e3;
    border-color: #feb2b2;
}
.wm-btn-add-child {
    background: #e6f7f0;
    color: #06d6a0;
    border: 1px solid #b2f5e6;
}
.wm-btn-add-child:hover:not(:disabled) {
    background: #c6f6e0;
}
.wm-btn-add-child.active {
    background: #06d6a0;
    color: white;
    border-color: #06d6a0;
    box-shadow: 0 0 0 3px rgba(6, 214, 160, 0.2);
}
.wm-btn-view {
    background: #eef2ff;
    color: var(--wm-primary);
    border: 1px solid #c7d2fe;
}
.wm-btn-view:hover:not(:disabled) {
    background: #e0e7ff;
    color: var(--wm-primary-dark);
}
.wm-btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: wm-spin 0.6s linear infinite;
    margin-right: 0.25rem;
}

/* ── Drag & Drop Placeholder ───────────────────────── */
.wm-drag-placeholder {
    height: 52px;
    border: 2px dashed var(--wm-primary);
    border-radius: var(--wm-radius-sm);
    background: rgba(67, 97, 238, 0.08);
    margin-bottom: 0.5rem;
    pointer-events: none;
    transition: all 0.1s;
}
.wm-menu-item.wm-dragging {
    opacity: 0.4;
    cursor: grabbing;
}
.wm-menu-empty {
    text-align: center;
    padding: 2rem;
    background: #fef9e3;
    border: 1px dashed #fbd38d;
    border-radius: var(--wm-radius-sm);
    color: #c05621;
    font-size: 0.85rem;
}

/* ── Save Row (Bottom) ─────────────────────────────── */
.wm-menu-save-row {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--wm-border-light);
    background: #fefefe;
    margin-top: auto;
}

/* ── Inline Add Form (Slide-down) ──────────────────── */
.wm-inline-form {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.3s ease-out, opacity 0.2s ease-out, margin 0.2s ease-out;
    margin-bottom: 0;
}
.wm-inline-form.wm-if-open {
    max-height: 420px;
    opacity: 1;
    margin-bottom: 0.75rem;
}
.wm-if-inner {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--wm-radius-sm);
    padding: 1rem 1.25rem;
    box-shadow: var(--wm-shadow-sm);
}
.wm-if-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.wm-if-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    color: var(--wm-primary);
}
.wm-if-label svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.wm-if-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    color: #94a3b8;
    transition: background 0.2s;
}
.wm-if-close-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
}
.wm-if-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}
@media (max-width: 600px) {
    .wm-if-fields { grid-template-columns: 1fr; }
}
.wm-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.wm-field label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--wm-text-light);
}
.wm-select {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--wm-border);
    border-radius: 8px;
    background: white;
    font-size: 0.8rem;
    transition: border 0.2s, box-shadow 0.2s;
}
.wm-select:focus {
    outline: none;
    border-color: var(--wm-primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}
.wm-if-status {
    margin-bottom: 0.75rem;
    min-height: 28px;
}
.wm-status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.75rem;
    border-radius: 30px;
    font-size: 0.7rem;
    font-weight: 500;
}
.wm-status-exists {
    background: #e6f7f0;
    color: #06d6a0;
}
.wm-status-new {
    background: #eef2ff;
    color: var(--wm-primary);
}
.wm-if-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

/* ── Toast Notifications ───────────────────────────── */
#wm-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 0.75rem 1.25rem;
    border-radius: 40px;
    font-size: 0.85rem;
    font-weight: 500;
    background: #1e293b;
    color: white;
    box-shadow: var(--wm-shadow-lg);
    z-index: 99999;
    opacity: 0;
    transform: translateY(16px);
    transition: all 0.2s ease-out;
    pointer-events: none;
}
#wm-toast.wm-toast-show {
    opacity: 1;
    transform: translateY(0);
}
#wm-toast.wm-toast-success { background: #06d6a0; color: #0f3b2c; }
#wm-toast.wm-toast-error   { background: #ef476f; }
#wm-toast.wm-toast-warn    { background: #ff9e00; color: #2d1f00; }

/* ── Responsive Adjustments ────────────────────────── */
@media (max-width: 768px) {
    .web-modules-content-panel {
        padding: 0.5rem;
    }
    .wm-panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    .wm-menu-tabs-row {
        flex-direction: column;
        align-items: stretch;
    }
    .wm-menu-tab {
        justify-content: center;
    }
    .wm-mi-actions {
        opacity: 0.9;
    }
    .wm-menu-save-row {
        flex-direction: column;
        align-items: stretch;
    }
    .wm-btn {
        justify-content: center;
    }
    .wm-menu-items-wrap {
        padding: 0 0.5rem;
    }
}

/* ── Scrollbar (optional) ──────────────────────────── */
.wm-menu-items-list::-webkit-scrollbar {
    width: 5px;
}
.wm-menu-items-list::-webkit-scrollbar-track {
    background: var(--wm-border-light);
    border-radius: 10px;
}
.wm-menu-items-list::-webkit-scrollbar-thumb {
    background: var(--wm-text-light);
    border-radius: 10px;
}