/* ===================================
   Table View Styles
   =================================== */

.table-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--bg-light);
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.table-filters {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-filters label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}

.table-actions {
    display: flex;
    gap: 8px;
}

.table-scroll-container {
    flex: 1;
    overflow: auto;
    background-color: var(--bg-white);
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 1200px; /* Ensure horizontal scroll on small screens */
}

/* Sticky header */
.task-table thead {
    position: sticky;
    top: 0;
    background-color: #f3f4f6;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.task-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
    color: var(--text-dark);
    background-color: #f3f4f6;
}

.task-table th.sortable {
    cursor: pointer;
    user-select: none;
    transition: background-color 0.15s;
}

.task-table th.sortable:hover {
    background-color: #e5e7eb;
}

.task-table th.sortable i {
    margin-left: 4px;
    font-size: 12px;
    color: var(--text-light);
}

.task-table th.sorted i {
    color: var(--primary-color);
}

.task-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s;
}

/* Zebra striping */
.task-table tbody tr:nth-child(even) {
    background-color: #f9fafb;
}

.task-table tbody tr:hover {
    background-color: #eff6ff;
    cursor: pointer;
}

.task-table tbody tr.selected {
    background-color: #dbeafe;
}

.task-table td {
    padding: 10px 16px;
    white-space: nowrap;
    vertical-align: middle;
}

/* Hierarchy indentation and expand/collapse */
.col-expand {
    width: 40px;
    text-align: center;
    padding: 10px 8px;
}

.table-expand-icon {
    cursor: pointer;
    color: var(--text-light);
    transition: transform 0.2s, color 0.2s;
    display: inline-block;
    width: 16px;
    text-align: center;
}

.table-expand-icon:hover {
    color: var(--primary-color);
}

.table-expand-icon.expanded {
    transform: rotate(90deg);
}

.table-cell-name {
    display: flex;
    align-items: center;
    gap: 4px;
}

.table-indent {
    display: inline-block;
    flex-shrink: 0;
}

.table-task-name {
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Column widths */
.col-name {
    min-width: 300px;
    max-width: 500px;
}

.col-id {
    width: 120px;
}

.col-status {
    width: 140px;
}

.col-units,
.col-complete {
    width: 100px;
    text-align: right;
}

.col-progress {
    width: 120px;
}

.col-assigned {
    width: 150px;
}

.col-priority {
    width: 120px;
}

.col-cost {
    width: 120px;
    text-align: right;
}

/* Status badges in table */
.table-status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.table-status-badge.status-not-started {
    background-color: #f3f4f6;
    color: #6b7280;
}

.table-status-badge.status-in-progress {
    background-color: #dbeafe;
    color: #1e40af;
}

.table-status-badge.status-complete {
    background-color: #d1fae5;
    color: #065f46;
}

/* Priority badges in table */
.table-priority-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
}

.table-priority-badge.priority-high {
    background-color: #fee2e2;
    color: #991b1b;
}

.table-priority-badge.priority-medium {
    background-color: #fef3c7;
    color: #92400e;
}

.table-priority-badge.priority-low {
    background-color: #e0e7ff;
    color: #3730a3;
}

/* Progress bar in table */
.table-progress-bar {
    width: 100%;
    height: 20px;
    background-color: #f3f4f6;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.table-progress-fill {
    height: 100%;
    background-color: var(--success-color);
    transition: width 0.3s;
}

.table-progress-text {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dark);
}

/* Assigned users */
.table-assigned-users {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
}

.table-assigned-count {
    color: var(--text-light);
}

/* Loading state */
.table-loading {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
}

.table-loading i {
    font-size: 24px;
    margin-bottom: 8px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Empty state */
.table-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.table-empty i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.table-empty p {
    margin: 8px 0 0 0;
}

/* Responsive adjustments */
@media (max-width: 1400px) {
    .col-cost {
        display: none;
    }
}

@media (max-width: 1200px) {
    .col-assigned,
    .col-priority {
        display: none;
    }
}

@media (max-width: 900px) {
    .col-units,
    .col-complete {
        display: none;
    }

    .col-name {
        min-width: 200px;
    }
}

/* Column Manager Modal */
.column-manager-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px;
    background-color: #fafafa;
}

.column-manager-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 6px;
    cursor: move;
    transition: background-color 0.2s, box-shadow 0.2s;
}

.column-manager-item:hover {
    background-color: #f9fafb;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.column-manager-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.column-drag-handle {
    color: var(--text-light);
    cursor: grab;
    font-size: 14px;
}

.column-drag-handle:active {
    cursor: grabbing;
}

.column-manager-item input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.column-manager-item label {
    flex: 1;
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* Style for actual cost column */
.col-actual-cost {
    text-align: right;
    font-weight: 500;
    color: var(--success-color);
}

/* Inline Editing Styles */
.editable-cell {
    cursor: pointer;
    position: relative;
    transition: background-color 0.2s;
}

.editable-cell:hover:not(.editing) {
    background-color: #f0f9ff !important;
    outline: 1px solid #bfdbfe;
}

.editable-cell:hover:not(.editing)::after {
    content: '✎';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: #60a5fa;
    opacity: 0.6;
}

.editable-cell.editing {
    background-color: #fff !important;
    padding: 0 !important;
}

.table-cell-edit {
    width: 100%;
    height: 100%;
    padding: 8px 12px;
    border: 2px solid var(--primary-color);
    background-color: white;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.table-cell-edit:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select.table-cell-edit {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 28px;
}

input[type="number"].table-cell-edit {
    text-align: right;
}

/* Make sure badges and inner content don't interfere with editing */
.editable-cell .table-status-badge,
.editable-cell .table-priority-badge,
.editable-cell .table-cell-name,
.editable-cell .table-task-name {
    pointer-events: none;
}
