/* ========================================
   🎨 ADVANCED FEATURES STYLING
   Search, Comments, and Role Management
   ======================================== */

/* ===== SEARCH BAR ===== */
.search-bar-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-right: 16px;
}

.search-input-wrapper {
    position: relative;
    width: 400px;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

.search-input {
    width: 100%;
    padding: 12px 48px 12px 48px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--card-bg);
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.search-clear-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-clear-btn:hover {
    background: var(--hover-bg);
}

.filter-toggle-btn {
    position: relative;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.3s;
}

.filter-toggle-btn:hover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.filter-count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* ===== FILTER PANEL ===== */
.filter-panel {
    position: fixed;
    top: 80px;
    right: 24px;
    width: 360px;
    max-height: calc(100vh - 120px);
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.filter-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.filter-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: background 0.2s;
}

.filter-close-btn:hover {
    background: var(--hover-bg);
}

.filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.filter-group {
    margin-bottom: 24px;
}

.filter-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-checkbox {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.filter-checkbox:hover {
    background: var(--hover-bg);
}

.filter-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.date-range-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
}

.date-input {
    flex: 1;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
}

.filter-actions {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.saved-filters-section {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

.saved-filters-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.saved-filters-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.saved-filter-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--hover-bg);
    border-radius: 10px;
}

.filter-name {
    font-size: 14px;
    font-weight: 500;
}

.filter-item-actions {
    display: flex;
    gap: 6px;
}

.filter-item-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: background 0.2s;
}

.filter-item-actions button:hover {
    background: var(--card-bg);
}

.no-filters {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 20px;
}

/* ===== COMMENTS PANEL ===== */
.comments-panel {
    position: fixed;
    right: 24px;
    top: 80px;
    width: 480px;
    max-height: calc(100vh - 120px);
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.comments-header h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.comment-item {
    display: flex;
    gap: 12px;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.comment-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
    min-width: 0;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.comment-author {
    font-weight: 600;
    font-size: 14px;
}

.comment-time {
    font-size: 12px;
    color: var(--text-muted);
}

.comment-delete-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
}

.comment-delete-btn:hover {
    background: var(--hover-bg);
    color: #ef4444;
}

.comment-text {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 10px;
    word-wrap: break-word;
}

.mention-highlight {
    color: var(--primary);
    font-weight: 600;
    background: rgba(79, 70, 229, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
}

.comment-attachments {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.attachment-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--hover-bg);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-main);
    font-size: 13px;
    transition: background 0.2s;
}

.attachment-link:hover {
    background: var(--border);
}

.comment-reactions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.reaction-badge {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--hover-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.reaction-badge:hover {
    background: var(--border);
    transform: scale(1.05);
}

.add-reaction-btn {
    padding: 4px 8px;
    background: none;
    border: 1px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.add-reaction-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.comment-input-section {
    padding: 20px 24px;
    border-top: 1px solid var(--border);
}

.comment-input-wrapper {
    position: relative;
}

.comment-textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    background: var(--card-bg);
}

.comment-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.comment-input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.input-tools {
    display: flex;
    gap: 6px;
}

.tool-btn {
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.tool-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.attachment-preview {
    margin-top: 12px;
    padding: 12px;
    background: var(--hover-bg);
    border-radius: 10px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--card-bg);
    border-radius: 8px;
    margin-bottom: 8px;
}

.file-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

.remove-file-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
}

.remove-file-btn:hover {
    background: var(--hover-bg);
    color: #ef4444;
}

.mention-autocomplete {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 8px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 200px;
    overflow-y: auto;
}

.mention-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.mention-item:hover {
    background: var(--hover-bg);
}

.mention-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
}

.mention-info {
    display: flex;
    flex-direction: column;
}

.mention-name {
    font-size: 14px;
    font-weight: 600;
}

.mention-email {
    font-size: 12px;
    color: var(--text-muted);
}

.emoji-picker-popup,
.reaction-picker-popup {
    position: fixed;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    gap: 6px;
    z-index: 10000;
}

.emoji-btn,
.reaction-btn {
    padding: 8px;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.emoji-btn:hover,
.reaction-btn:hover {
    background: var(--hover-bg);
}

.no-comments {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

/* ===== ROLE MANAGEMENT ===== */
.role-manager-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 800px;
    max-height: 90vh;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 22px;
    font-weight: 800;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.roles-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.roles-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.roles-list {
    display: grid;
    gap: 20px;
}

.role-card {
    padding: 24px;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 16px;
    transition: all 0.3s;
}

.role-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.role-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.role-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.role-badge {
    padding: 6px 14px;
    border-radius: 12px;
    color: white;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.system-badge,
.default-badge {
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.system-badge {
    background: #6b7280;
    color: white;
}

.default-badge {
    background: #22c55e;
    color: white;
}

.role-actions {
    display: flex;
    gap: 6px;
}

.icon-btn {
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
}

.icon-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.role-permissions h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.permission-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.permission-tag {
    padding: 6px 12px;
    background: rgba(79, 70, 229, 0.1);
    color: var(--primary);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
}

.role-stats {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Role Creation Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s;
}

.modal-content {
    width: 600px;
    max-height: 90vh;
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 28px;
}

.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 10px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 14px;
    background: var(--card-bg);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
}

.color-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.color-option {
    width: 40px;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: var(--text-main);
    box-shadow: 0 0 0 2px var(--card-bg), 0 0 0 4px var(--text-main);
}

.color-input-custom {
    width: 100%;
    height: 50px;
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
}

.permissions-checklist {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.permission-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.permission-checkbox-label:hover {
    background: var(--hover-bg);
}

.permission-checkbox {
    margin-top: 2px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.permission-info {
    flex: 1;
}

.permission-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
}

.permission-desc {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 28px;
    border-top: 1px solid var(--border);
}

/* ===== TASK CARD COMMENT BUTTONS ===== */
.task-action-btn {
    padding: 8px;
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-muted);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}

.task-action-btn.comment-btn {
    position: relative;
}

.comment-count {
    font-size: 11px;
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.task-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

