/* ═══════════════════════════════════════════════════════════
   TD Common — کامپوننت‌های مشترک
   نسخه: 1.6 — تقویم با select ماه/سال
   ═══════════════════════════════════════════════════════════ */

.td-card-compact {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-right: 4px solid #3b82f6;
    border-radius: 8px;
    margin-bottom: 5px;
    overflow: hidden;
    transition: all .15s;
    font-family: Vazirmatn, Tahoma, sans-serif;
    direction: rtl;
}

.td-card-compact:hover {
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.td-card-compact.is-open {
    border-color: #2563eb;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.1);
}

.td-card-compact[data-type="incoming"]   { border-right-color: #10b981; }
.td-card-compact[data-type="outgoing"]   { border-right-color: #3b82f6; }
.td-card-compact[data-type="internal"]   { border-right-color: #f59e0b; }
.td-card-compact[data-type="workgroup"]  { border-right-color: #3b82f6; }
.td-card-compact[data-type="management"] { border-right-color: #db2777; }
.td-card-compact[data-type="normal"]     { border-right-color: #10b981; }
.td-card-compact[data-type="important"]  { border-right-color: #f59e0b; }
.td-card-compact[data-type="urgent"]     { border-right-color: #ef4444; }
.td-card-compact[data-type="draft_min"]  { border-right-color: #6b7280; }
.td-card-compact[data-type="approved"]   { border-right-color: #10b981; }

.td-card-compact .td-cc-header {
    padding: 8px 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    transition: background .15s;
    user-select: none;
    min-height: 42px;
}

.td-card-compact .td-cc-header:hover {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
}

.td-card-compact.is-open .td-cc-header {
    background: linear-gradient(180deg, #eff6ff 0%, #dbeafe 100%);
    border-bottom: 1px solid #e2e8f0;
}

.td-card-compact .td-cc-toggle {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: #fff;
    border: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #475569;
    font-size: 10px;
    flex-shrink: 0;
    transition: all .2s;
}

.td-card-compact.is-open .td-cc-toggle {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
    transform: rotate(180deg);
}

.td-card-compact .td-cc-title {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    font-weight: 800;
    color: #1e293b;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-card-compact .td-cc-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    font-size: 11px;
    color: #64748b;
    flex-shrink: 0;
}

.td-card-compact .td-cc-meta > span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    white-space: nowrap;
}

.td-card-compact .td-cc-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
    flex-shrink: 0;
}

.td-cc-badge-incoming   { background: #d1fae5; color: #065f46; }
.td-cc-badge-outgoing   { background: #dbeafe; color: #1e40af; }
.td-cc-badge-internal   { background: #fef3c7; color: #92400e; }
.td-cc-badge-workgroup  { background: #dbeafe; color: #1e40af; }
.td-cc-badge-management { background: #fce7f3; color: #9f1239; }
.td-cc-badge-normal     { background: #d1fae5; color: #065f46; }
.td-cc-badge-important  { background: #fef3c7; color: #92400e; }
.td-cc-badge-urgent     { background: #fecaca; color: #991b1b; }

.td-card-compact .td-cc-progress {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    margin: 0 12px 6px;
    display: none;
}

.td-card-compact.is-open .td-cc-progress {
    display: block;
}

.td-card-compact .td-cc-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #10b981 0%, #059669 100%);
    border-radius: 2px;
    transition: width .4s;
}

.td-card-compact .td-cc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height .3s ease-out;
}

.td-card-compact.is-open .td-cc-body {
    max-height: 5000px;
    overflow: visible;
}

.td-card-compact .td-cc-body-inner {
    padding: 10px 12px;
    background: #fff;
}

.td-card-compact .td-cc-section {
    margin-bottom: 8px;
}

.td-card-compact .td-cc-section:last-child {
    margin-bottom: 0;
}

.td-card-compact .td-cc-section-label {
    font-size: 11.5px;
    font-weight: 800;
    color: #475569;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.td-card-compact .td-cc-section-value {
    font-size: 12.5px;
    color: #334155;
    line-height: 1.8;
    background: #f8fafc;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.td-card-compact .td-cc-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    flex-wrap: wrap;
}

/* ═══════════════ فاصله بین کارت‌ها ═══════════════ */

.td-mn-list,
.td-reg-wg-list,
.td-ann-list,
.td-reg-wg-items {
    gap: 0 !important;
    row-gap: 0 !important;
    column-gap: 0 !important;
}

/* ═══════════════════════════════════════════════════════════
   تقویم شمسی — با select ماه/سال
   ═══════════════════════════════════════════════════════════ */

.td-jalali-calendar {
    position: fixed !important;
    z-index: 2147483647 !important;
    background: #fff;
    border: 2px solid #1e3a8a;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.35);
    padding: 12px;
    width: 320px;
    font-family: Vazirmatn, Tahoma, sans-serif;
    direction: rtl;
    user-select: none;
    pointer-events: auto;
}

/* 🆕 هدر با select ها */
.td-jc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid #eff6ff;
}

.td-jc-nav {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
    padding: 0;
    font-family: inherit;
    flex-shrink: 0;
}

.td-jc-nav:hover {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

/* 🆕 select ماه و سال */
.td-jc-month-select,
.td-jc-year-select {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e3a8a;
    font-family: Vazirmatn, Tahoma, sans-serif;
    font-size: 12.5px;
    font-weight: 700;
    padding: 5px 24px 5px 8px;
    border-radius: 7px;
    cursor: pointer;
    outline: none;
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%231e3a8a' stroke-width='3'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: left 6px center;
    transition: all .15s;
    min-width: 0;
}

.td-jc-month-select {
    flex: 1.3;
}

.td-jc-year-select {
    flex: 1;
}

.td-jc-month-select:hover,
.td-jc-year-select:hover {
    background-color: #dbeafe;
    border-color: #2563eb;
}

.td-jc-month-select:focus,
.td-jc-year-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
    background-color: #fff;
}

.td-jc-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
    margin-bottom: 6px;
}

.td-jc-weekday {
    text-align: center;
    font-size: 10.5px;
    font-weight: 800;
    color: #64748b;
    padding: 4px 0;
}

.td-jc-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.td-jc-day {
    text-align: center;
    padding: 7px 0;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 700;
    color: #1e293b;
    transition: all .15s;
    background: #f8fafc;
    border: 1px solid transparent;
    font-family: inherit;
}

.td-jc-day:hover {
    background: #dbeafe;
    border-color: #2563eb;
    color: #1e3a8a;
}

.td-jc-day.is-today {
    background: #fef3c7;
    color: #92400e;
    font-weight: 900;
}

.td-jc-day.is-empty {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

.td-jc-day.is-selected {
    background: #1e3a8a;
    color: #fff;
    font-weight: 900;
}

.td-jc-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 2px solid #eff6ff;
    gap: 5px;
}

.td-jc-btn {
    flex: 1;
    padding: 7px 10px;
    border-radius: 7px;
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    border: 1px solid;
}

.td-jc-today {
    background: #fef3c7;
    color: #92400e;
    border-color: #fcd34d;
}

.td-jc-today:hover {
    background: #fbbf24;
    color: #fff;
}

.td-jc-close {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.td-jc-close:hover {
    background: #ef4444;
    color: #fff;
    border-color: #ef4444;
}

/* ═══ فیلد تاریخ (نمایش) ═══ */
.td-date-display {
    width: 100%;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
    font-family: Vazirmatn, Tahoma, sans-serif;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: 2px;
    text-align: center;
    cursor: pointer;
    box-sizing: border-box;
    direction: rtl;
    min-height: 38px;
    line-height: 20px;
    transition: all .2s;
}

.td-date-display:hover {
    background: #dbeafe;
    border-color: #2563eb;
}

.td-date-display.is-empty {
    color: #94a3b8;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
}

/* ═══════════════ نوار جستجو ═══════════════ */

.td-search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 12px;
    margin-bottom: 12px;
    margin-top: 16px;
    transition: all .2s;
    position: relative;
    font-family: Vazirmatn, Tahoma, sans-serif;
    direction: rtl;
    z-index: 5;
}

.td-search-bar:focus-within {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.td-search-bar .td-search-icon {
    color: #64748b;
    font-size: 16px;
    flex-shrink: 0;
}

.td-search-bar input[type="text"] {
    flex: 1;
    border: 0 !important;
    outline: none !important;
    background: transparent !important;
    font-family: Vazirmatn, Tahoma, sans-serif !important;
    font-size: 13.5px !important;
    color: #1e293b !important;
    padding: 4px 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    height: auto !important;
    min-height: 0 !important;
    line-height: 1.5 !important;
}

.td-search-bar input[type="text"]::placeholder {
    color: #94a3b8;
}

.td-search-bar .td-search-clear {
    background: #f1f5f9;
    border: 0;
    border-radius: 6px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    font-size: 14px;
    flex-shrink: 0;
    transition: all .15s;
    padding: 0;
    font-family: inherit;
}

.td-search-bar .td-search-clear:hover {
    background: #ef4444;
    color: #fff;
}

.td-search-bar .td-search-count {
    background: #eff6ff;
    color: #1e40af;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
    min-width: 30px;
    text-align: center;
}

.td-search-no-result {
    padding: 40px 20px;
    text-align: center;
    background: #f8fafc;
    border-radius: 10px;
    border: 2px dashed #cbd5e1;
    color: #64748b;
    font-weight: 700;
    font-size: 14px;
}

/* ═══ موبایل ═══ */
@media (max-width: 640px) {
    .td-card-compact .td-cc-header {
        padding: 8px 10px;
        gap: 6px;
    }
    .td-card-compact .td-cc-title {
        font-size: 12px;
    }
    .td-card-compact .td-cc-meta {
        display: none;
    }
    .td-jalali-calendar {
        width: calc(100vw - 30px);
        max-width: 340px;
    }
    .td-search-bar input[type="text"] {
        font-size: 12.5px !important;
    }
}