/**
 * استایل‌های بهبود یافته برای پلاگین Table در EditorJS
 * 
 * این فایل شامل استایل‌های RTL و بهبودهای بصری برای جدول است
 * 
 * @author VO2.ir
 * @version 1.0.0
 */

/* بهبود استایل کلی جدول */
.tc-wrap {
    direction: rtl;
    text-align: right;
    margin: 20px 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.3s ease;
}

.tc-wrap:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* بهبود استایل جدول */
.tc-table {
    border-top: 2px solid #1976d2;
    font-size: 14px;
    line-height: 1.6;
    background: #fff;
}

/* بهبود استایل سطرها */
.tc-row {
    border-bottom: 1px solid #e8e8eb;
    transition: background-color 0.2s ease;
}

.tc-row:hover {
    background-color: #f5f5f5;
}

.tc-row--selected {
    background: #e3f2fd !important;
}

/* بهبود استایل سلول‌ها */
.tc-cell {
    padding: 12px 16px !important;
    border-right: 1px solid #e8e8eb;
    min-height: 44px;
    word-break: break-word;
    overflow-wrap: break-word;
    text-align: right;
    vertical-align: middle;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.tc-cell:focus {
    outline: 2px solid #1976d2;
    outline-offset: -2px;
    background-color: #f0f7ff;
    border-color: #1976d2;
}

.tc-cell--selected {
    background: #e3f2fd !important;
    border-color: #90caf9;
}

/* بهبود استایل هدر جدول */
.tc-table--heading .tc-row:first-child {
    background: linear-gradient(135deg, #1976d2 0%, #1565c0 100%);
    color: #fff;
    font-weight: 600;
    border-bottom: 3px solid #0d47a1;
}

.tc-table--heading .tc-row:first-child .tc-cell {
    color: #fff;
    border-right-color: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.tc-table--heading .tc-row:first-child .tc-cell:focus {
    background-color: rgba(255, 255, 255, 0.1);
    outline-color: rgba(255, 255, 255, 0.5);
}

.tc-table--heading .tc-row:first-child [contenteditable]:empty:before {
    color: rgba(255, 255, 255, 0.7);
}

/* بهبود دکمه‌های افزودن سطر و ستون */
.tc-add-row,
.tc-add-column {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    border-radius: 4px;
    transition: all 0.3s ease;
    color: #6c757d;
    font-size: 12px;
    font-weight: 500;
}

.tc-add-row:hover,
.tc-add-column:hover {
    background: #e9ecef;
    border-color: #1976d2;
    color: #1976d2;
    transform: scale(1.02);
}

.tc-add-row {
    margin-top: 2px;
    border-radius: 0 0 4px 4px;
}

.tc-add-column {
    border-radius: 0 4px 4px 0;
}

/* بهبود استایل Toolbox */
.tc-toolbox {
    z-index: 10;
}

.tc-toolbox__toggler {
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.tc-toolbox__toggler:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

/* بهبود استایل Popover */
.tc-popover {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 8px;
    background: #fff;
    border: 1px solid #e0e0e0;
}

.tc-popover__item {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 4px;
    transition: all 0.2s ease;
    font-size: 14px;
    direction: rtl;
    text-align: right;
}

.tc-popover__item:hover {
    background: #f0f7ff;
    transform: translateX(-2px);
}

.tc-popover__item-icon {
    margin-left: 10px;
    margin-right: 0;
    border-radius: 6px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    transition: all 0.2s ease;
}

.tc-popover__item:hover .tc-popover__item-icon {
    background: #e3f2fd;
    border-color: #1976d2;
}

.tc-popover__item-label {
    font-weight: 500;
    color: #333;
}

.tc-popover__item--confirm {
    background: #ffebee;
    color: #c62828;
}

.tc-popover__item--confirm:hover {
    background: #ffcdd2;
    color: #b71c1c;
}

.tc-popover__item--confirm .tc-popover__item-icon {
    background: #ffebee;
    border-color: #ef5350;
}

/* بهبود استایل برای حالت read-only */
.tc-wrap--readonly {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tc-wrap--readonly .tc-cell {
    background: #fafafa;
    cursor: default;
}

.tc-wrap--readonly .tc-row:hover {
    background-color: transparent;
}

/* بهبود استایل برای موبایل */
@media (max-width: 768px) {
    .tc-wrap {
        margin: 15px -10px;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .tc-cell {
        padding: 10px 12px !important;
        font-size: 13px;
        min-height: 40px;
    }

    .tc-table {
        font-size: 13px;
    }

    .tc-popover {
        padding: 6px;
    }

    .tc-popover__item {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* بهبود استایل برای چاپ */
@media print {
    .tc-wrap {
        border: 1px solid #000;
        box-shadow: none;
        page-break-inside: avoid;
    }

    .tc-cell {
        border: 1px solid #000;
    }

    .tc-table--heading .tc-row:first-child {
        background: #f0f0f0 !important;
        color: #000 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* بهبود استایل برای حالت focus */
.tc-cell[contenteditable="true"]:focus {
    background-color: #f0f7ff;
    box-shadow: inset 0 0 0 2px #1976d2;
}

/* بهبود استایل برای جداول خالی */
.tc-cell:empty:before {
    content: attr(data-placeholder, '');
    color: #999;
    font-style: italic;
}

/* بهبود استایل برای جداول با محتوای زیاد */
.tc-table {
    max-height: 600px;
    overflow-y: auto;
}

.tc-table::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tc-table::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tc-table::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.tc-table::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* بهبود استایل برای جداول با عرض زیاد */
.tc-wrap {
    overflow-x: auto;
}

.tc-wrap::-webkit-scrollbar {
    height: 8px;
}

.tc-wrap::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.tc-wrap::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.tc-wrap::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* بهبود استایل برای جداول با border */
.tc-table {
    border-collapse: separate;
    border-spacing: 0;
}

/* بهبود استایل برای جداول با zebra striping (اختیاری) */
.tc-row:nth-child(even) {
    background-color: #fafafa;
}

.tc-table--heading .tc-row:nth-child(even) {
    background-color: transparent;
}

/* بهبود استایل برای جداول با hover effect */
.tc-row:hover .tc-cell {
    background-color: #f5f5f5;
}

.tc-table--heading .tc-row:first-child:hover .tc-cell {
    background-color: rgba(255, 255, 255, 0.1);
}

/* بهبود استایل برای جداول با responsive design */
@media (max-width: 650px) {
    .tc-wrap {
        font-size: 12px;
    }

    .tc-cell {
        padding: 8px 10px !important;
        font-size: 12px;
        min-height: 36px;
    }

    .tc-popover__item {
        padding: 6px 10px;
        font-size: 12px;
    }

    .tc-popover__item-icon {
        width: 22px;
        height: 22px;
    }
}

/* بهبود استایل برای جداول با alignment */
.tc-cell[data-align="center"] {
    text-align: center;
}

.tc-cell[data-align="left"] {
    text-align: left;
}

.tc-cell[data-align="right"] {
    text-align: right;
}

/* بهبود استایل برای جداول با width */
.tc-table {
    width: 100%;
    table-layout: auto;
}

/* بهبود استایل برای جداول با min-width */
.tc-cell {
    min-width: 80px;
}

/* بهبود استایل برای جداول با max-width */
.tc-wrap {
    max-width: 100%;
}

/* بهبود استایل برای جداول با overflow */
.tc-cell {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* بهبود استایل برای جداول با word-wrap */
.tc-cell {
    word-wrap: break-word;
    hyphens: auto;
}

/* بهبود استایل برای جداول با line-height */
.tc-cell {
    line-height: 1.6;
}

/* بهبود استایل برای جداول با font-family */
.tc-table {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* بهبود استایل برای جداول با color */
.tc-cell {
    color: #333;
}

.tc-table--heading .tc-row:first-child .tc-cell {
    color: #fff;
}

/* بهبود استایل برای جداول با background */
.tc-wrap {
    background: #fff;
}

.tc-table {
    background: #fff;
}

/* بهبود استایل برای جداول با border-radius */
.tc-wrap {
    border-radius: 8px;
}

.tc-cell:first-child {
    border-top-right-radius: 8px;
}

.tc-cell:last-child {
    border-top-left-radius: 8px;
}

.tc-row:last-child .tc-cell:first-child {
    border-bottom-right-radius: 8px;
}

.tc-row:last-child .tc-cell:last-child {
    border-bottom-left-radius: 8px;
}

