html {
    height: 100%;
}

body {
    font-family: 'Vazir', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e0eafc, #cfdef3);
    margin: 0;
    padding: 20px;
    direction: rtl;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
}

.container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    width: 100%;
    max-width: 1300px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
}

h1 {
    color: #1a202c;
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    font-weight: 700;
}

.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 0.9rem;
}

.header-bar .bold {
    font-weight: 700;
}

.user-actions {
    display: flex;
    gap: 8px;
}

.login-form {
    max-width: 450px;
    margin: 0 auto;
    padding: 25px;
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    display: none;
}

.login-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

input, select, textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 0.9rem;
    box-sizing: border-box;
    font-family: 'Vazir', sans-serif;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: #4c51bf;
    box-shadow: 0 0 6px rgba(76, 81, 191, 0.3);
    outline: none;
}

input:disabled {
    background: #f7fafc;
    border-color: #e2e8f0;
    cursor: not-allowed;
    opacity: 0.7;
}

select:invalid {
    color: #a0aec0;
}

.task-creator-search input {
    border: 1px solid #e2e8f0;
    padding: 8px;
    font-size: 0.85rem;
}

.task-timestamp {
    font-size: 0.7rem;
    color: #718096;
    position: absolute;
    bottom: 6px;
    left: 8px;
    margin: 0;
}

.filter-section input, .filter-section select {
    min-width: 100px;
    padding: 8px;
    font-size: 0.85rem;
}

button {
    padding: 10px 20px;
    background: linear-gradient(45deg, #4c51bf, #6b46c1);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(76, 81, 191, 0.3);
    font-weight: 600;
    font-family: 'Vazir', sans-serif;
}

button:hover {
    transform: translateY(-2px);
    background: linear-gradient(45deg, #6b46c1, #4c51bf);
    box-shadow: 0 6px 20px rgba(76, 81, 191, 0.4);
}

.error {
    color: #e53e3e;
    text-align: center;
    margin-top: 15px;
    font-size: 0.9rem;
}

.portal {
    display: none;
}

.portal.active {
    display: block;
}

.logout-btn {
    background: linear-gradient(45deg, #f56565, #e53e3e);
}

.admin-btn {
    background: linear-gradient(45deg, #667eea, #5a67d8);
}

.dept-btn {
    background: linear-gradient(45deg, #48bb78, #38a169);
}

.task-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
}

.task-form-top {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.task-form-top #taskTitle {
    flex: 2;
    min-width: 300px;
    border: 1px solid #e2e8f0;
}

.task-form-top .task-creator-wrapper,
.task-form-top #priority {
    flex: 1;
    max-width: 140px;
}

.task-creator-wrapper {
    position: relative;
}

.search-suggestions {
    position: absolute;
    top: 100%;
    right: 0;
    width: 100%;
    background: white;
    border-radius: 10px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
    max-height: 140px;
    overflow-y: auto;
    display: none;
    z-index: 10;
}

.suggestion-item {
    padding: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.suggestion-item:hover {
    background: #edf2f7;
}

.task-form-bottom {
    display: flex;
    gap: 8px;
    align-items: center;
}

.task-form-bottom textarea {
    flex: 3;
    min-height: 50px;
    resize: vertical;
    border: 1px solid #e2e8f0;
}

.task-form-bottom button {
    flex: 0 0 auto;
    width: 100px;
    background: linear-gradient(45deg, #00b4db, #0083b0);
}

.filter-section {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
    background: linear-gradient(135deg, #e2e8f0, #edf2f7);
    padding: 12px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.filter-section.user-filter {
    margin-top: 10px;
}

.filter-section select, .filter-section input {
    flex: 1;
    min-width: 100px;
}

.switch-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #2d3748;
}

.switch-label input[type="checkbox"] {
    width: auto;
    cursor: pointer;
}

.kanban-board {
    display: flex;
    gap: 15px;
    justify-content: space-between;
    flex-wrap: nowrap;
}

.column {
    background: linear-gradient(135deg, #f7fafc, #edf2f7);
    padding: 15px;
    width: 33.33%;
    min-height: 350px;
    border-radius: 15px;
    transition: all 0.3s ease;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
}

.column.dragover {
    background: linear-gradient(135deg, #e2e8f0, #cbd5e0);
    transform: scale(1.01);
}

.column h3 {
    color: #2d3748;
    margin: 0 0 15px;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
}

.live-dots {
    display: inline-block;
    color: #63b3ed;
    font-size: 1.1rem;
}

.task {
    background: white;
    padding: 10px;
    margin: 6px 0;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
    cursor: move;
    min-height: 70px;
    font-size: 0.85rem;
}

.task.dragging {
    opacity: 0.6;
    transform: scale(0.98);
}

.task.done {
    opacity: 0.7;
}

.high { border-right: 5px solid #fc8181; }
.medium { border-right: 5px solid #f6ad55; }
.low { border-right: 5px solid #68d391; }

.task h4 {
    margin: 0 0 5px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #2d3748;
}

.task p {
    margin: 2px 0;
    font-size: 0.75rem;
    color: #4a5568;
}

.task .admin-task-info {
    display: flex;
    gap: 8px;
    font-size: 0.75rem;
    color: #4a5568;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.comment-count {
    position: absolute;
    top: 6px;
    left: 6px;
    background: #a0aec0;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-family: 'Vazir', sans-serif;
}

.comment-count.new {
    background: #63b3ed;
    transform: scale(1.1);
}

.in-progress-indicator, .done-indicator {
    font-size: 0.7rem;
    color: #718096;
    position: absolute;
    bottom: 6px;
    left: 8px;
}

.comment-popup, .edit-task-popup {
    display: none;
    position: fixed; /* ثابت نسبت به ویوپورت */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #f7fafc;
    padding: 20px;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    z-index: 10000; /* افزایش z-index برای اطمینان */
    width: 450px;
    max-width: 90%;
    color: #2d3748;
    max-height: 80vh;
    overflow-y: auto;
    will-change: transform; /* بهبود رندر */
}

.comment-popup.active, .edit-task-popup.active {
    display: block;
}
.comment-header {
    background: linear-gradient(45deg, #4c51bf, #667eea);
    padding: 12px;
    border-radius: 12px 12px 0 0;
    margin: -20px -20px 20px -20px;
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
    color: white;
}

.task-details {
    background: #edf2f7;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    margin-bottom: 15px;
}

.task-details .details-section {
    background: white;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-top: 8px;
}

.task-details p {
    margin: 0 0 8px;
    font-size: 0.85rem;
}

.task-info {
    font-size: 0.7rem;
    color: #4a5568;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.task-info p {
    margin: 0;
    flex: 1 1 45%;
    font-size: 0.65rem;
}

.comment-list {
    background: #edf2f7;
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.comment-display {
    background: white;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 10px;
    position: relative;
}

.no-comments {
    text-align: center;
    color: #718096;
    font-size: 0.85rem;
}

.comment-timestamp {
    font-size: 0.7rem;
    color: #718096;
    position: absolute;
    bottom: 4px;
    left: 8px;
}

.comment-actions {
    display: flex;
    gap: 8px;
    position: absolute;
    top: 8px;
    left: 8px;
}

.comment-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4a5568;
    padding: 4px;
}

.comment-actions button:hover {
    color: #4c51bf;
}

.admin-panel, .dept-panel {
    display: none;
    margin: 0 auto;
    padding: 20px;
}

.admin-panel.active, .dept-panel.active {
    display: block;
}

.user-management-form, .dept-management-form {
    display: flex;
    gap: 8px;
    align-items: center;
    background: linear-gradient(135deg, #fefcbf, #fefcbf);
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.user-management-form input,
.user-management-form select,
.dept-management-form input {
    flex: 1;
    min-width: 100px;
}

.user-management-form button,
.dept-management-form button {
    background: linear-gradient(45deg, #38a169, #2f855a);
    flex: 0 0 auto;
}

.user-list, .dept-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-item, .dept-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #edf2f7;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.user-item h3, .dept-item span {
    flex: 1;
    margin: 0;
}

.user-item p {
    margin: 0;
    flex: 1;
}

.user-item button, .dept-item button {
    flex: 0 0 auto;
    background: linear-gradient(45deg, #ed8936, #f6ad55);
}

.back-btn {
    background: linear-gradient(45deg, #a0aec0, #718096);
    margin-top: 12px;
}

.back-arrow {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1rem;
}

.filter-section input[type="text"][id="filterFromDate"],
.filter-section input[type="text"][id="filterToDate"] {
    flex: 1;
    min-width: 100px;
    padding: 8px;
    font-size: 0.85rem;
    direction: ltr; /* برای نمایش صحیح تاریخ YYYY/MM/DD */
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    .container {
        padding: 20px;
    }
    .task-form-top, .filter-section, .user-management-form, .dept-management-form {
        flex-direction: column;
    }
    .task-form-top #taskTitle {
        min-width: 100%;
    }
    .task-form-top .task-creator-wrapper,
    .task-form-top #priority {
        max-width: 100%;
    }
    .task-form-bottom {
        flex-direction: column;
    }
    .task-form-bottom textarea, .task-form-bottom button {
        width: 100%;
    }
    .kanban-board {
        flex-direction: column;
        gap: 12px;
    }
    .column {
        width: 100%;
    }
    .user-item, .dept-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .header-bar {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
    .comment-popup, .edit-task-popup {
        width: 90%;
    }
    .task .admin-task-info {
        flex-direction: column;
        gap: 2px;
    }
    input, select, textarea {
        font-size: 0.85rem;
        padding: 8px;
    }
}

.date-input {
    width: 140px;
    padding: 8px;
    font-size: 0.85rem;
    direction: ltr;
    text-align: center;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.date-input:focus {
    outline: none;
    border-color: #007bff;
}

.date-input-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-width: 140px;
    direction: rtl;
}


.date-separator {
    color: #555;
    font-size: 0.85rem;
    margin: 0 4px;
    pointer-events: none;
}



.date-part:focus {
    outline: none;
    border-color: #007bff;
}

.filter-section input[type="text"][id="filterFromDate"],
.filter-section input[type="text"][id="filterToDate"] {
    flex: 1;
    min-width: 80px;
    padding: 1px 1px 1px 1px;
    font-size: 1.5rem;
    direction: ltr;
}

.date-input-wrapper label {
    margin-left: 8px;
    font-size: 0.85rem;
    color: #2d3748;
}

.column h3 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.column h3 input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}