/* =========================================================
   Nexus Studio UI - Light & Modern (Final Scroll Fixed)
========================================================= */

.nexus-wrapper,
.nexus-wrapper * {
    box-sizing: border-box;
}

/* ========================
   ریشه اصلی پنل
======================== */

.nexus-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    font-family: Tahoma, Yekan, "Vazirmatn", sans-serif;
    direction: rtl;

    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 24px;

    background: #f9fafb;
    padding: 24px;
    border-radius: 16px;
    color: #111827;

    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.08);

    /*
       اصلاح اصلی:
       ارتفاع پنل را نسبت به ارتفاع صفحه محدود می‌کنیم
       تا محتوای داخلی بتواند اسکرول بخورد.
    */
    height: calc(100vh - 190px);
    min-height: 520px;
    max-height: calc(100vh - 190px);

    /*
       مهم:
       نمی‌گذاریم محتوای داخلی کل صفحه را هل بدهد.
    */
    overflow: hidden;

    /*
       برای اینکه در Grid اسکرول داخلی درست کار کند.
    */
    min-width: 0;
}

/* ========================
   ستون دکمه‌ها
======================== */

.nexus-sidebar {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 14px;

    display: flex;
    flex-direction: column;
    gap: 10px;

    box-shadow:
        0 18px 40px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(148, 163, 184, 0.18);

    /*
       اگر تعداد دکمه‌ها زیاد شد، ستون دکمه‌ها هم اسکرول بخورد.
    */
    height: 100%;
    overflow-y: auto;
    min-height: 0;
}

.nexus-sidebar::-webkit-scrollbar {
    width: 6px;
}

.nexus-sidebar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.nexus-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.nexus-sidebar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.nexus-btn {
    width: 100%;
    padding: 13px 12px;
    border: none;
    border-radius: 10px;
    background: #f3f4f6;
    color: #1f2933;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: right;

    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    transition:
        transform 0.18s ease,
        background-color 0.18s ease,
        color 0.18s ease,
        box-shadow 0.18s ease;

    flex-shrink: 0;
}

.nexus-btn::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #cbd5f5;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.18s ease;
}

.nexus-btn:hover {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.15);
}

.nexus-btn.active {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;
    box-shadow:
        0 10px 24px rgba(37, 99, 235, 0.35),
        0 0 0 1px rgba(191, 219, 254, 0.7);
}

.nexus-btn.active::before {
    opacity: 1;
    background: #bfdbfe;
    transform: scale(1);
}

/* ========================
   بخش محتوا - اصلاح اصلی اسکرول
======================== */

.nexus-content {
    min-width: 0;
    min-height: 0;

    /*
       مهم‌ترین بخش:
       ارتفاع کامل از wrapper می‌گیرد و خودش اسکرول می‌شود.
    */
    height: 100%;
    max-height: 100%;
    overflow-y: auto;
    overflow-x: hidden;

    /*
       در RTL اسکرول‌بار معمولاً سمت چپ می‌افتد.
       این پدینگ باعث می‌شود اسکرول‌بار به محتوا نچسبد.
    */
    padding-left: 10px;
    padding-right: 0;

    /*
       اسکرول نرم‌تر در موبایل و مرورگرها
    */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* استایل اسکرول‌بار محتوا */
.nexus-content::-webkit-scrollbar {
    width: 7px;
}

.nexus-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

.nexus-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.nexus-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* برای Firefox */
.nexus-content {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* ========================
   پنل‌ها
======================== */

.nexus-panel {
    display: none;
    min-width: 0;
}

.nexus-panel.active {
    display: block;
    animation: nexusFade 0.35s ease;
}

/* ========================
   کارت محتوا / سکشن
======================== */

.nexus-section {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 22px;

    box-shadow:
        0 16px 40px rgba(15, 23, 42, 0.06),
        0 0 0 1px rgba(226, 232, 240, 0.8);

    line-height: 1.9;
}

.nexus-section h2 {
    margin-top: 0;
    margin-bottom: 6px;
    font-size: 19px;
    font-weight: 700;
    color: #111827;
}

.nexus-hint {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 18px;
    line-height: 1.9;
}

/* ========================
   فرم
======================== */

.nexus-form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 18px 18px;
    min-width: 0;
}

.nexus-field {
    min-width: 0;
    line-height: 1.9;
}

.nexus-field label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.nexus-field input,
.nexus-field select,
.nexus-field textarea {
    width: 100%;
    max-width: 100%;

    padding: 11px 13px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;

    font-size: 13px;
    font-family: inherit;

    background: #f9fafb;
    color: #111827;

    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease,
        background-color 0.2s ease,
        transform 0.1s ease;
}

.nexus-field input:focus,
.nexus-field select:focus,
.nexus-field textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow:
        0 0 0 1px rgba(37, 99, 235, 0.35),
        0 0 0 5px rgba(59, 130, 246, 0.15);
    background: #ffffff;
    transform: translateY(-0.5px);
}

.nexus-field input:hover,
.nexus-field select:hover,
.nexus-field textarea:hover {
    border-color: #94a3b8;
    background: #f3f4f6;
}

.nexus-field textarea {
    resize: vertical;
    min-height: 110px;
}

.nexus-full {
    grid-column: 1 / -1;
}

.nexus-small {
    display: block;
    margin-top: 4px;
    font-size: 11px;
    color: #9ca3af;
}

/* ========================
   دکمه اصلی
======================== */

.nexus-primary-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;

    padding: 12px 20px;

    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #ffffff;

    border: none;
    border-radius: 999px;

    font-size: 14px;
    font-weight: 700;

    cursor: pointer;

    box-shadow:
        0 15px 35px rgba(37, 99, 235, 0.35),
        0 0 0 1px rgba(191, 219, 254, 0.8);

    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        background-position 0.2s ease;

    background-size: 200% 200%;
}

.nexus-primary-btn:hover {
    transform: translateY(-1px) scale(1.01);
    box-shadow:
        0 18px 40px rgba(37, 99, 235, 0.45),
        0 0 0 1px rgba(191, 219, 254, 1);
    background-position: 100% 0;
}

.nexus-primary-btn:active {
    transform: translateY(1px) scale(0.99);
    box-shadow:
        0 8px 20px rgba(37, 99, 235, 0.3),
        0 0 0 1px rgba(147, 197, 253, 0.7);
}

.nexus-actions {
    margin-top: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.nexus-status-msg {
    font-size: 12px;
    color: #6b7280;
}

.nexus-status-msg.success {
    color: #10b981;
}

.nexus-status-msg.error {
    color: #ef4444;
}

/* ========================
   استایل سفارشات مشتری / تایم‌لاین
   اگر قبلاً داشتی، این بخش کمک می‌کند کارت‌ها مرتب‌تر شوند.
======================== */

.nexus-timeline {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.nexus-timeline-item {
    border: 1px solid #e5e7eb;
    background: #f9fafb;
    border-radius: 12px;
    padding: 16px;
}

.nexus-timeline-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.nexus-timeline-header h3 {
    margin: 0;
    font-size: 15px;
    color: #111827;
}

.nexus-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    padding: 5px 10px;
    border-radius: 999px;

    background: #dbeafe;
    color: #1d4ed8;

    font-size: 12px;
    font-weight: 700;
}

.nexus-timeline-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;

    font-size: 12px;
    color: #6b7280;
}

.nexus-timeline-notes {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed #d1d5db;

    font-size: 13px;
    color: #374151;
}

.nexus-timeline-notes p {
    margin: 6px 0 0;
}

/* ========================
   انیمیشن
======================== */

@keyframes nexusFade {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================
   ریسپانسیو
======================== */

@media (max-width: 768px) {
    .nexus-wrapper {
        grid-template-columns: 1fr;
        padding: 16px;
        gap: 16px;
        box-shadow: none;
        border-radius: 0;

        /*
           در موبایل بهتر است کل صفحه اسکرول شود،
           نه فقط باکس داخلی.
        */
        height: auto;
        min-height: auto;
        max-height: none;
        overflow: visible;
    }

    .nexus-sidebar {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        height: auto;
        padding: 10px;
        border-radius: 12px;
        gap: 6px;
    }

    .nexus-btn {
        white-space: nowrap;
        font-size: 12px;
        padding: 10px 12px;
        width: auto;
        flex: 0 0 auto;
    }

    .nexus-content {
        height: auto;
        max-height: none;
        overflow: visible;
        padding-left: 0;
    }

    .nexus-section {
        padding: 16px;
    }

    .nexus-form-grid {
        grid-template-columns: 1fr;
    }
}
