/* Task Layout Container */
.task-layout-container {
    display: flex;
    min-height: calc(100vh - 45px - 57px - 3rem);
    position: relative;
    background-color: #f0f2f5;
}

/* Sidebar Styles */
.task-sidebar {
    width: 260px;
    background: white;
    border-right: 1px solid #dee2e6;
    padding: 20px 0;
    align-self: stretch;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 900;
}

.task-sidebar-header {
    padding: 0 20px 10px;
    margin-bottom: 10px;
}

.task-sidebar-header h2 {
    color: #0056b3;
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    line-height: 1.3;
}

.task-sidebar-header p {
    color: #6c757d;
    font-size: 13px;
    margin-top: 0;
    line-height: 1.4;
}

.task-sidebar-nav-menu {
    list-style: none;
    padding: 0;
    margin: 10px 0 0 0;
}

.task-sidebar-nav-item {
    margin-bottom: 2px;
}

.task-sidebar-nav-button {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: #495057;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    position: relative;
    border-radius: 0;
}

.task-sidebar-nav-button::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 3px;
    background: #007bff;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.task-sidebar-nav-button:hover {
    background: #f8f9fa;
    color: #0056b3;
}

.task-sidebar-nav-button:hover::before {
    opacity: 0.5;
}

.task-sidebar-nav-button.active {
    background: #e9ecef;
    color: #0056b3;
    font-weight: 600;
}

.task-sidebar-nav-button.active::before {
    opacity: 1;
}

.task-sidebar-nav-icon {
    margin-right: 10px;
    font-size: 18px;
    min-width: 20px;
    text-align: center;
    line-height: 1;
}

.task-sidebar-mobile-toggle {
    display: none;
    position: fixed;
    top: 55px;
    left: 15px;
    z-index: 1001;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Main Content Styles */
.task-main-content {
    flex: 1;
    background: #f0f2f5;
    padding: 20px;
    overflow-y: auto;
}

.task-form-content-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

.task-page-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #dee2e6;
}

.task-page-title {
    color: #0056b3;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.task-page-subtitle {
    color: #6c757d;
    font-size: 14px;
    margin-bottom: 0;
}

/* Form Section Styles */
.task-form-section-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

.task-form-section-header {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white;
    padding: 18px 24px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

.task-form-section-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
    color: white;
}

.task-form-section-body {
    padding: 24px;
}

/* Form Controls */
.task-form-control {
    width: 100%;
    padding: 9px 14px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
    line-height: 1.5;
    background-color: #fff;
    color: #495057;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.task-form-control:focus {
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

textarea.task-form-control {
    min-height: 100px;
    resize: vertical;
}

.task-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 1rem;
}

.task-form-row > .form-group {
    flex: 1;
    margin-bottom: 0;
}

.task-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* Tooltip Styles */
.task-tooltip {
    position: relative;
    display: inline-flex;
    vertical-align: middle;
    margin-left: 6px;
    cursor: help;
}

.task-tooltip-icon-display {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: #007bff;
    color: white;
    border-radius: 50%;
    font-size: 11px;
    font-weight: bold;
    user-select: none;
    line-height: 1;
}

.task-tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background-color: #333;
    color: #fff;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    font-size: 13px;
    line-height: 1.4;
    z-index: 1050;
    width: max-content;
    max-width: 280px;
    text-align: left;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out, transform 0.2s ease-in-out;
    pointer-events: none;
    box-sizing: border-box;
}

.task-tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.task-tooltip:hover .task-tooltip-text,
.task-tooltip:focus .task-tooltip-text,
.task-tooltip:focus-within .task-tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-3px);
}

/* Empty State Styles */
.task-empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px dashed #dee2e6;
    margin-top: 10px;
}

.task-empty-state-icon {
    font-size: 44px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.task-empty-state h3 {
    color: #495057;
    font-size: 1.2em;
    margin-bottom: 6px;
}

.task-empty-state p {
    font-size: 0.95em;
    margin-bottom: 0;
}

/* Summary Box Styles */
.task-summary-box {
    padding: 8px 12px;
    margin-bottom: 12px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-left-width: 3px;
    border-radius: 4px;
    font-size: 0.85em;
    color: #495057;
}

.task-summary-box strong {
    color: #343a40;
    font-weight: 600;
}

.task-summary-box.files { border-left-color: #17a2b8; }
.task-summary-box.files strong { color: #0c5460; }
.task-summary-box.internal-notes { border-left-color: #ffc107; }
.task-summary-box.internal-notes strong { color: #856404; }
.task-summary-box.public-notes { border-left-color: #28a745; }
.task-summary-box.public-notes strong { color: #155724; }
.task-summary-box.repetition { border-left-color: #fd7e14; }
.task-summary-box.repetition strong { color: #783d06; }

/* Table Styles */
.task-form-section-body .data-table.compact th,
.task-form-section-body .data-table.compact td {
    padding: 0.5rem 0.6rem;
}

.task-form-section-body .data-table.compact .button-small {
    font-size: 0.8em;
}

.form-group label .required {
    font-weight: bold;
    color: #dc3545;
}

/* Internal Comments Table Specific Styles */
.internal-comments-table .actions-column { width: 90px; }
.internal-comments-table .note-column { width: auto; }
.internal-comments-table .date-column { width: 120px; }

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    .task-sidebar {
        position: fixed;
        top: 45px;
        left: 0;
        height: calc(100vh - 45px);
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        padding-top: 10px;
    }

    .task-sidebar.open {
        transform: translateX(0);
    }

    .task-main-content {
        margin-left: 0;
        padding: 15px;
    }
    
    .task-form-content-wrapper {
        padding: 0;
    }

    .task-sidebar-mobile-toggle {
        display: block;
    }

    .task-form-row {
        flex-direction: column;
        gap: 0;
    }

    .task-form-row > .form-group {
        margin-bottom: 1rem;
    }

    .task-form-actions {
        flex-direction: column;
    }

    .task-form-actions button,
    .task-form-actions .button {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        margin-top: 0 !important;
    }

    .task-form-actions .button:not(:last-child) {
        margin-bottom: 8px;
    }

    .task-page-header {
        margin-top: 30px;
    }

    .task-tooltip-text {
        max-width: 220px;
    }
}

@media (max-width: 400px) {
    .task-tooltip-text {
        max-width: 180px;
        font-size: 12px;
        padding: 6px 10px;
    }

    .task-tooltip-text::after {
        border-width: 5px;
    }
}

/* --- Project Page Styles --- */
.project-card[id], .element-card[id] {
    scroll-margin-top: 80px; /* Adjust this value based on your fixed header height */
}
.projects-list { display: flex; flex-direction: column; gap: 20px; }
.project-card { background: #ffffff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.07); border: 1px solid #dee2e6; overflow: hidden; transition: all 0.2s ease; }
.project-card:hover { box-shadow: 0 4px 8px rgba(0, 0, 0, 0.08); transform: translateY(-1px); }
.project-card-owned { border-left: 4px solid #28a745; }
.project-header-form { margin: 0; }
.project-header { 
    padding: 20px 24px; 
    cursor: pointer; 
    transition: background-color 0.2s ease; 
    border: none; 
    background: linear-gradient(135deg, #2c5aa0 0%, #1e4080 100%); 
    width: 100%; 
    text-align: left; 
    display: block; 
    color: white;
}
.project-header:hover { background: linear-gradient(135deg, #245291 0%, #1a3971 100%); }
.project-header-content { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.project-left { display: flex; align-items: center; gap: 16px; flex: 1; min-width: 0; }
.chevron { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.2); border-radius: 6px; transition: all 0.3s ease; flex-shrink: 0; }
.chevron::before { content: '→'; color: white; font-size: 12px; font-weight: 600; transition: all 0.3s ease; }
.chevron.expanded { background: rgba(255,255,255,0.4); }
.chevron.expanded::before { content: '↓'; color: white; }
.project-info { flex: 1; min-width: 0; }
.project-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.project-title { font-size: 1.2rem; font-weight: 600; color: white; flex: 1; }
.project-badges { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.favorite-badge { font-size: 1rem; }
.priority-badge { 
    padding: 2px 6px; 
    border-radius: 12px; 
    font-size: 0.7rem; 
    font-weight: 600; 
    text-transform: uppercase;
}
.priority-high { background: #ffebee; color: #c62828; border: 1px solid #ffcdd2; }
.priority-medium { background: #fff3e0; color: #ef6c00; border: 1px solid #ffcc02; }
.priority-normal { background: #e8f5e8; color: #2e7d32; border: 1px solid #c8e6c9; }
.priority-low { background: #f3e5f5; color: #7b1fa2; border: 1px solid #e1bee7; }
.project-description { 
    color: rgba(255,255,255,0.9); 
    font-size: 0.9rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: break-word;
    -webkit-line-clamp: 1; /* Default to 1 line */
}
.project-card.is-expanded .project-description {
    -webkit-line-clamp: 3; /* Expand to 3 lines */
}
.status-badge { padding: 5px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.status-created { background: #e3f2fd; color: #1976d2; border: 1px solid #bbdefb; }
.status-active { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.status-on-hold { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.status-progress { background: #cce5ff; color: #004085; border: 1px solid #99ccff; }
.status-finished { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.status-ended { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.project-right { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; padding-left: 16px; }
.project-id-display { font-size: 1rem; font-weight: 500; color: white; }
.project-dates { font-size: 0.85rem; color: rgba(255,255,255,0.8); }
.project-meta { display: flex; gap: 24px; color: rgba(255,255,255,0.8); font-size: 0.85rem; align-items: center; }
.project-details { background: #f8fafc; border-top: 1px solid #e2e8f0; animation: slideDown 0.3s ease-out; }
@keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
.project-details-inner { padding: 24px; }
.project-preferences { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 16px; margin-bottom: 20px; }
.preference-group { display: flex; align-items: center; gap: 20px; }
.favorite-toggle { 
    background: none; 
    border: 1px solid #ddd; 
    border-radius: 4px; 
    padding: 6px 12px; 
    cursor: pointer; 
    transition: all 0.2s ease;
    font-size: 0.9rem;
}
.favorite-toggle:hover { background: #f8f9fa; }
.favorite-toggle.is-favorite { background: #fff3cd; border-color: #ffeaa7; color: #856404; }
.project-details-actions { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.elements-list { display: flex; flex-direction: column; gap: 12px; }
.element-card { background: #ffffff; border-radius: 6px; border: 1px solid #e2e8f0; overflow: hidden; }
.element-header-form { margin: 0; }
.element-header-button { 
    width: 100%; 
    border: none; 
    background: #ffffff !important; /* Override global button styles */
    color: inherit !important; /* Override global button styles */
    cursor: pointer; 
    padding: 16px 20px; 
    text-align: left; 
    transition: background-color 0.2s ease; 
}
.element-header-button:hover { background: #f8f9fa !important; }
.element-header-content { display: flex; justify-content: space-between; align-items: center; }
.element-left { display: flex; align-items: center; gap: 12px; flex: 1; }
.element-chevron { width: 16px; height: 16px; display: flex; align-items: center; justify-content: center; background: #e9ecef; border-radius: 4px; transition: all 0.3s ease; flex-shrink: 0; }
.element-chevron::before { content: '→'; color: #495057; font-size: 10px; font-weight: 600; transition: all 0.3s ease; }
.element-chevron.expanded { background: #6c757d; }
.element-chevron.expanded::before { content: '↓'; color: white; }
.element-info { flex: 1; }
.element-title { font-weight: 600; color: #343a40; font-size: 1rem; }
.element-type { font-size: 0.8rem; color: #6c757d; }
.element-right { text-align: right; }
.element-count { font-size: 0.8rem; color: #6c757d; }
.element-details { background: #f8fafc; border-top: 1px solid #e2e8f0; padding: 16px 20px; }
.element-actions { margin-bottom: 12px; }
.element-items { display: flex; flex-direction: column; gap: 8px; }
.element-item { background: #ffffff; padding: 12px 16px; border-radius: 4px; border: 1px solid #e5e7eb; display: flex; justify-content: space-between; align-items: flex-start; }
.task-item { align-items: flex-start; }
.item-info { flex: 1; }
.item-title { font-weight: 500; color: #343a40; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.item-meta { font-size: 0.8rem; color: #6c757d; margin-bottom: 4px; }
.item-description { font-size: 0.85rem; color: #555; line-height: 1.4; margin-top: 8px; padding: 8px; background: #f8f9fa; border-radius: 4px; }
.item-actions { display: flex; gap: 5px; flex-shrink: 0; margin-left: 10px; }
.item-readonly { font-size: 0.8rem; color: #6c757d; font-style: italic; }
.task-status-badge { padding: 2px 6px; border-radius: 12px; font-size: 0.65rem; font-weight: 600; text-transform: uppercase; }
.task-status-badge.status-pending { background: #fff3cd; color: #856404; }
.task-status-badge.status-created { background: #e3f2fd; color: #1976d2; }
.task-status-badge.status-sent { background: #e7f3ff; color: #0066cc; }
.task-status-badge.status-accepted { background: #d4edda; color: #155724; }
.task-status-badge.status-finished { background: #d1ecf1; color: #0c5460; }
.task-status-badge.status-completed { background: #d4edda; color: #155724; }
.task-status-badge.status-refused { background: #f8d7da; color: #721c24; }
.task-status-badge.status-cancelled { background: #f8d7da; color: #721c24; }
.task-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 1000; display: flex; align-items: center; justify-content: center; } 
.task-modal-content { background: white; border-radius: 8px; width: 90%; max-height: 90vh; overflow-y: auto; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3); } 
.task-modal-header { padding: 15px 20px; border-bottom: 1px solid #e9ecef; } 
.task-modal-header h3 { margin: 0; color: #495057; } 
.task-modal-body { padding: 20px; } 
.task-modal-actions { padding: 15px 20px; display: flex; gap: 10px; justify-content: flex-end; background-color: #f8f9fa; border-top: 1px solid #e9ecef; }
.task-form-control { width: 100%; padding: 8px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 14px; }
.form-group { margin-bottom: 15px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; color: #333; }
.form-group-checkbox { display: flex; align-items: center; gap: 8px; }
.form-group-checkbox input[type="checkbox"] { margin: 0; }
.form-group-checkbox label { margin: 0; cursor: pointer; }
.form-group-checkbox-small { display: flex; align-items: center; gap: 6px; }
.form-group-checkbox-small input[type="checkbox"] { margin: 0; transform: scale(0.9); }
.form-group-checkbox-small label { margin: 0; cursor: pointer; font-size: 0.85rem; color: #6c757d; }
.filter-controls, .sort-controls { display: inline-block; }
.task-section-actions { display: flex; align-items: center; gap: 5px; }
.form-row { display: flex; gap: 15px; }
.form-group-half { flex: 1; }
.required { color: #dc3545; }
@media (max-width: 768px) {
    .project-header-content { flex-direction: column; gap: 12px; align-items: flex-start; }
    .project-right { align-items: flex-start; }
    .project-meta { flex-direction: column; gap: 8px; align-items: flex-start; }
    .project-dates-with-edit { flex-direction: column; align-items: flex-start; gap: 8px; }
    .item-actions { flex-direction: column; margin-left: 0; margin-top: 8px; width: 100%; }
    .element-item { flex-direction: column; align-items: stretch; }
    .preference-group { flex-direction: column; align-items: flex-start; gap: 10px; }
    .filter-controls, .sort-controls { display: block; margin-top: 10px; }
    .form-row { flex-direction: column; gap: 0; }
    .task-section-actions { flex-direction: column; align-items: stretch; }
    .task-section-actions form { margin-right: 0 !important; margin-bottom: 5px; }
}

/* --- ADDED FOR DOSSIER FILE MANAGEMENT --- */
.dossier-file-drop-zone {
    border: 2px dashed #007bff;
    border-radius: 6px;
    padding: 20px;
    text-align: center;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 15px;
}

.dossier-file-drop-zone.active {
    background-color: #e3f2fd;
    border-color: #0056b3;
}

.dossier-file-drop-zone.uploading {
    background-color: #e8f5e9;
    border-color: #4caf50;
    cursor: not-allowed;
}

.dossier-file-drop-zone span {
    color: #495057;
    font-weight: 500;
}

.element-item.file-item .item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.file-download-button {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    color: #007bff;
    cursor: pointer;
    text-align: left;
    text-decoration: none;
    font-weight: 500;
}

.file-download-button:hover {
    text-decoration: underline;
    color: #0056b3;
}

.file-item-icon {
    font-size: 1.2rem;
    color: #6c757d;
}

/* --- ADDED FOR LINKED DOSSIER STYLING --- */
.element-item.linked-dossier-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px; /* Reduce padding to accommodate button border */
}

.linked-dossier-nav-form {
    flex-grow: 1;
    margin: 0;
}

/* CORRECTED RULE: Made selector more specific and ensured transparent background */
form.linked-dossier-nav-form .linked-dossier-nav-button {
    display: block;
    width: 100%;
    background-color: transparent; /* Use transparent background */
    border: 1px solid #007bff;     /* Set the blue border */
    border-radius: 4px;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* This hover effect remains the same and is correct */
form.linked-dossier-nav-form .linked-dossier-nav-button:hover {
    background-color: #e3f2fd;
}

.linked-dossier-title {
    font-weight: 600;
    color: #0056b3;
    margin-bottom: 4px;
}

.linked-dossier-description {
    font-size: 0.85rem;
    color: #6c757d;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Show max 2 lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}