/* =========================================
   DESIGN TOKENS
   ========================================= */
:root {
    --acc-primary: #2563eb;
    --acc-primary-light: #60a5fa;
    --acc-card-bg: #ffffff;
    --acc-border: #e5e7eb;
    --acc-bg-soft: #f3f4f6;
    --acc-text-title: #111827;
    --acc-text-main: #1e293b;
    --acc-text-muted: #94a3b8;
    --acc-danger: #dc2626;
    --acc-warning: #f59e0b;
    --acc-space-md: 16px;
    --acc-radius-md: 16px;
    --acc-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
    --acc-transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* =========================================
   GENERAL BODY & LAYOUT
   ========================================= */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--acc-bg-soft);
    color: var(--acc-text-main);
    line-height: 1.6;
}

/* =========================================
   TABULATOR AS CARD GRID
   ========================================= */
.projects-runtime-table {
    background-color: transparent !important;
    border: none !important;
}

.projects-runtime-table .tabulator-tableholder {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
    gap: var(--acc-space-md) !important;
    padding: var(--acc-space-md) !important;
    align-items: start !important;
    overflow-x: hidden !important;
}

.projects-runtime-table .tabulator-table {
    display: contents !important;
}

.projects-runtime-table .tabulator-row {
    display: block !important;
    background: transparent !important;
    border: none !important;
    height: auto !important;
    margin: 0 !important;
    animation: fadeInUp 0.3s ease-out forwards;
}

.projects-runtime-table .tabulator-cell {
    display: block !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    white-space: normal !important;
}

.projects-runtime-table .tabulator-header,
.projects-runtime-table .tabulator-footer {
    display: none !important;
}

/* =========================================
   TABULATOR PAGINATION
   ========================================= */
.tabulator-paginator {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    direction: rtl;
}

.tabulator-page {
    padding: 6px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    transition: background-color 0.2s, color 0.2s;
    font-size: 13px;
}

.tabulator-page.active {
    background: var(--acc-primary);
    color: #fff;
    border-color: var(--acc-primary);
}

.tabulator-page:hover:not(.active) {
    background: #f0f0f0;
}

.tabulator-page[data-page="next"],
.tabulator-page[data-page="prev"] {
    font-weight: bold;
}

/* =========================================
   CARD STRUCTURE
   ========================================= */
.project-card-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

.project-card-container {
    width: 100%;
    background: var(--acc-card-bg);
    border-radius: 12px;
    border: 1px solid var(--acc-border);
    box-shadow: var(--acc-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.project-card-container:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
    border-color: var(--acc-primary);
}

.project-card-content {
    padding: 16px 18px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project-card-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 10px 16px;
    background: #fafafa;
    border-top: 1px solid #f1f1f1;
    flex-shrink: 0;
}

.project-card-footer button {
    background: none;
    border: none;
    cursor: pointer;
}

/* =========================================
   ACTION BUTTONS
   ========================================= */
.action-btn {
    border: 1px solid var(--acc-border);
    background: #fff;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--acc-text-muted);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--acc-transition);
}

.action-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

.action-btn.edit:hover {
    color: #2196F3;
    border-color: #2196F3;
    background: #e3f2fd;
}

.action-btn.delete:hover {
    color: #f44336;
    border-color: #f44336;
    background: #ffebee;
}

/* =========================================
   RUNTIME CARD FALLBACK
   ========================================= */
.runtime-card-fallback {
    padding: 10px;
    background-color: var(--acc-bg-soft);
    border: 1px dashed var(--acc-border);
    border-radius: 8px;
    font-weight: 600;
    color: var(--acc-text-muted);
    text-align: center;
    font-size: 13px;
}

.runtime-card-fallback.error {
    color: var(--acc-danger);
    border-color: var(--acc-danger);
    background-color: #fff0f0;
}

/* =========================================
   RUNTIME CARD STRUCTURE
   ========================================= */
.runtime-card {
    background: var(--acc-card-bg);
    border: 1px solid var(--acc-border);
    border-radius: var(--acc-radius-md);
    padding: 20px;
    box-shadow: var(--acc-shadow);
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: all var(--acc-transition);
}

.runtime-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
    border-color: var(--acc-primary);
}

.runtime-card::before {
    content: "";
    position: absolute;
    top: 0;
    inset-inline: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--acc-primary), var(--acc-primary-light));
}

.runtime-field-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.runtime-field-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.runtime-field-label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--acc-text-muted);
}

.runtime-field-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--acc-text-main);
    word-break: break-word;
}

.runtime-card div:nth-child(4) .runtime-field-value {
    font-size: 15px;
    color: var(--acc-primary);
    font-weight: 800;
}

.runtime-card div:last-child .runtime-field-value {
    background: var(--acc-bg-soft);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    color: #8d1111;
    font-weight: 600;
}

/* =========================================
   CARD MENU
   ========================================= */
.card-menu-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #ffffffcc;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 3px 6px;
    cursor: pointer;
    font-size: 14px;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.card-menu-btn:hover {
    background: #fff;
    border-color: #bbb;
}

.card-menu-popup {
    position: absolute;
    top: 36px;
    left: 8px;
    width: 150px;
    padding: 8px 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    z-index: 50;
    display: none;
}

.card-menu-popup.visible {
    display: block;
}

.card-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--acc-text-main);
}

.card-menu-item:hover {
    background: #f5f5f5;
}

/* =========================================
   SEARCH BAR
   ========================================= */
.projects-toolbar-wrapper {
    padding: 15px;
    background-color: var(--acc-card-bg);
    border-radius: 10px;
    box-shadow: var(--acc-shadow);
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.projects-runtime-search {
    width: 80%;
    max-width: 500px;
    padding: 12px 18px;
    border: 1px solid var(--acc-border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.projects-runtime-search:focus {
    outline: none;
    border-color: var(--acc-primary);
    box-shadow: 0 0 0 0.2rem rgba(37, 99, 231, 0.25);
}

.projects-runtime-search::placeholder {
    color: var(--acc-text-muted);
}

/* =========================================
   ANIMATIONS
   ========================================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* =========================================
   RESPONSIVE DESIGN
   ========================================= */
@media (max-width: 992px) {
    .projects-runtime-table .tabulator-tableholder {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
    }
}

@media (max-width: 768px) {
    .projects-runtime-table .tabulator-tableholder {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)) !important;
    }
}

@media (max-width: 600px) {
    .projects-runtime-table .tabulator-tableholder {
        grid-template-columns: 1fr !important;
    }

    .projects-toolbar-wrapper {
        padding: 10px;
    }

    .projects-runtime-search {
        width: 90%;
        padding: 10px 12px;
    }
}

/* --- ظاهر کلی کارت‌ها --- */
.project-card-wrapper {
    position: relative;
    margin-bottom: 20px;
    padding: 16px 48px 16px 16px;
    /* فضای سمت راست برای دکمه‌ها */
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.project-card-wrapper:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* --- محل قرارگیری دکمه‌ها --- */
/* .project-card-actions {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    z-index: 5;
} */

/* دکمه‌ها زیر هدر کارت */
.project-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px dashed #e5e7eb;
}

/* --- استایل دکمه‌ها --- */
.project-card-actions button {
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    padding: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.project-card-actions button:hover {
    background: #e5e7eb;
}

/* جلوگیری از به‌هم‌چسبیدن محتوا داخل کارت */
.project-card-wrapper {
    position: relative;
    padding: 16px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}


/* حالت چندستونه (اختیاری برای پخش شدن کارت‌ها) */
/* پخش شدن کارت‌ها تا جایی که صفحه جا دارد */
.projects-runtime-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(420px, 1fr));
    gap: 20px;
}


@media (max-width: 900px) {
    .projects-runtime-list {
        grid-template-columns: 1fr;
    }
}


.search-select {
    position: relative;
    width: 100%;
}

.search-select-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    background: white;
}

.search-select-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    margin-top: 4px;
    max-height: 240px;
    overflow-y: auto;
    z-index: 99999;
    display: none;
}

.search-select-item {
    padding: 10px 14px;
    cursor: pointer;
}

.search-select-item:hover {
    background: #f3f4f6;
}

.projects-dynamic-modal {
    width: min(960px, 100%);
    max-height: 90vh;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.projects-dynamic-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    /* مهم */
}

.projects-dynamic-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    /* مهم */
}