/**
 * Task Management Module - Styling
 * Adapted from Review Module for consistent UI/UX
 */

/* Stats Cards */
.stat-card {
    border-radius: 12px;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 2px solid transparent;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
}

.stat-card.active {
    border-color: var(--bs-primary);
}

.stat-card .icon-container {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: #6c757d;
}

/* Filter Section */
.filter-card {
    border-radius: 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* Table Standards */
.table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    white-space: nowrap;
}

/* Modal Styling */
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* Instructions Box */
.instructions-box {
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8eb 100%);
    border-radius: 12px;
    padding: 1.5rem;
    margin-top: 2rem;
}

.instructions-box h5 {
    color: #495057;
    margin-bottom: 1rem;
}

.instructions-box ul {
    margin-bottom: 0;
    padding-left: 1.25rem;
}

.instructions-box li {
    margin-bottom: 0.5rem;
    color: #6c757d;
}

/* Status Badges */
.status-badge {
    padding: 0.4em 0.75em;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: capitalize;
}

/* Priority Indicators */
.priority-pill {
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}
.p-high { background-color: #fee2e2; color: #991b1b; }
.p-normal { background-color: #fef3c7; color: #92400e; }
.p-low { background-color: #dcfce7; color: #166534; }

/* Status Badges - Soft Style */
.badge-soft {
    display: inline-flex;
    align-items: center;
    padding: 0.45em 1em;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.bg-soft-primary { background-color: #e0e7ff !important; color: #4338ca !important; border: 1px solid #c7d2fe; }
.bg-soft-success { background-color: #dcfce7 !important; color: #15803d !important; border: 1px solid #bbf7d0; }
.bg-soft-warning { background-color: #fef3c7 !important; color: #b45309 !important; border: 1px solid #fde68a; }
.bg-soft-danger { background-color: #fee2e2 !important; color: #b91c1c !important; border: 1px solid #fecaca; }
.bg-soft-info { background-color: #e0f2fe !important; color: #0369a1 !important; border: 1px solid #bae6fd; }
.bg-soft-secondary { background-color: #f1f5f9 !important; color: #475569 !important; border: 1px solid #e2e8f0; }

/* Responsive Adjustments */
@media (max-width: 768px) {
    .stat-card .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-card .icon-container {
        width: 36px;
        height: 36px;
        margin-right: 10px !important;
    }

    .stat-card .icon-container i {
        font-size: 1.25rem !important;
    }

    .stat-card .card-body {
        padding: 0.75rem 0.5rem;
        flex-direction: column;
        text-align: center;
        align-items: center !important;
    }

    .stat-card .card-body .icon-container {
        margin-right: 0 !important;
        margin-bottom: 0.5rem;
    }
}

/* Modern Mobile Table (Cards) */
@media (max-width: 768px) {
    .table-responsive {
        overflow-x: hidden !important; /* Force no horizontal scroll on mobile */
    }
    #tasksTable {
        width: 100% !important;
        table-layout: fixed !important;
        border-collapse: collapse !important;
        margin: 0 !important;
    }
    #tasksTable thead {
        display: none;
    }
    #tasksTable, #tasksTable tbody {
        display: block;
        width: 100% !important;
    }
    #tasksTable tbody tr {
        display: block;
        position: relative;
        background-color: #fff;
        border: 1px solid #e9ecef;
        border-left: 5px solid #dee2e6 !important;
        border-radius: 8px;
        padding: 0.75rem 1rem;
        margin-bottom: 1.25rem;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        overflow: hidden;
    }
    #tasksTable tbody tr.st-pending    { border-left-color: #6c757d !important; }
    #tasksTable tbody tr.st-assigned   { border-left-color: #0dcaf0 !important; }
    #tasksTable tbody tr.st-viewed     { border-left-color: #0d6efd !important; }
    #tasksTable tbody tr.st-inprogress  { border-left-color: #fd7e14 !important; }
    #tasksTable tbody tr.st-onhold     { border-left-color: #ffc107 !important; }
    #tasksTable tbody tr.st-completed  { border-left-color: #198754 !important; }
    #tasksTable tbody tr.st-cancelled  { border-left-color: #dc3545 !important; }

    #tasksTable tbody td {
        display: block;
        width: 100%;
        border: none;
        padding: 0.15rem 0 !important;
        text-align: left !important;
    }
    #tasksTable tbody td:not(:first-child) {
        display: none !important;
    }
}

/* Modern Separated Rows (Desktop Layout) */
@media (min-width: 769px) {
    #tasksTable {
        border-collapse: separate !important;
        border-spacing: 0 10px !important;
        background: transparent !important;
    }
    #tasksTable thead th {
        border-top: none !important;
        border-bottom: none !important;
        font-size: 0.85rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: #adb5bd;
        background: transparent !important;
        padding-bottom: 10px;
    }
    #tasksTable tbody tr {
        box-shadow: 0 4px 10px rgba(0,0,0,0.03);
        border-radius: 12px;
        background-color: #fff !important;
        transition: transform 0.2s ease;
    }
    #tasksTable tbody tr:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(0,0,0,0.06);
    }
    #tasksTable tbody tr td {
        border-top: 1px solid #f1f3f5 !important;
        border-bottom: 1px solid #f1f3f5 !important;
        background-color: #fff !important;
        padding: 1rem 1.25rem;
    }
    #tasksTable tbody tr td:first-child {
        border-left: 1px solid #f1f3f5 !important;
        border-top-left-radius: 12px;
        border-bottom-left-radius: 12px;
    }
    #tasksTable tbody tr td:last-child {
        border-right: 1px solid #f1f3f5 !important;
        border-top-right-radius: 12px;
        border-bottom-right-radius: 12px;
    }

    /* Left accents for status */
    #tasksTable tbody tr.st-pending td:first-child { border-left: 5px solid #6c757d !important; }
    #tasksTable tbody tr.st-assigned td:first-child { border-left: 5px solid #0dcaf0 !important; }
    #tasksTable tbody tr.st-viewed td:first-child { border-left: 5px solid #0d6efd !important; }
    #tasksTable tbody tr.st-inprogress td:first-child { border-left: 5px solid #fd7e14 !important; }
    #tasksTable tbody tr.st-onhold td:first-child { border-left: 5px solid #ffc107 !important; }
    #tasksTable tbody tr.st-completed td:first-child { border-left: 5px solid #198754 !important; }
    #tasksTable tbody tr.st-cancelled td:first-child { border-left: 5px solid #dc3545 !important; }
}

/* User Avatar/Initials */
.avatar-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: white;
    background-color: #6c757d;
}

/* Source Badges/Buttons */
.badge-src {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    cursor: pointer;
    background: #f8f9fa;
    color: #495057;
}

.badge-src:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1) !important;
}

.badge-src-order {
    background-color: #e0f2fe;
    color: #0369a1;
    border-color: #bae6fd;
}
.badge-src-order:hover {
    background-color: #bae6fd;
}

.badge-src-service {
    background-color: #fef3c7;
    color: #92400e;
    border-color: #fde68a;
}
.badge-src-service:hover {
    background-color: #fde68a;
}

.badge-src-global {
    background-color: #f3f4f6;
    color: #374151;
    border-color: #e5e7eb;
}

/* Soft Color Utilities */
.bg-soft-primary { background-color: #e0f2fe; color: #0369a1; }
.bg-soft-success { background-color: #dcfce7; color: #166534; }
.bg-soft-warning { background-color: #fef3c7; color: #92400e; }
.bg-soft-danger  { background-color: #fee2e2; color: #991b1b; }
.bg-soft-info    { background-color: #e0f2fe; color: #0369a1; }

/* Premium Tabs */
.nav-tabs-premium {
    border-bottom: 2px solid #f1f3f5;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.nav-tabs-premium::-webkit-scrollbar {
    display: none;
}

.nav-tabs-premium .nav-link {
    white-space: nowrap;
    border: none;
    background: transparent;
    color: #94a3b8;
    font-weight: 600;
    padding: 0.75rem 0.25rem;
    position: relative;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.nav-tabs-premium .nav-link:hover {
    color: #495057;
}

.nav-tabs-premium .nav-link.active {
    color: #764ba2;
    background: transparent;
}

.nav-tabs-premium .nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

/* Modern Form Elements inside Modal */
.modal-body .form-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #adb5bd;
    margin-bottom: 0.5rem;
}

.modal-body .form-control, .modal-body .form-select {
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 0.6rem 0.85rem;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.modal-body .form-control:focus, .modal-body .form-select:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

/* Timeline System */
.history-list {
    position: relative;
    padding: 1.5rem 0.5rem;
}

.history-list::before {
    content: '';
    position: absolute;
    left: 1.5rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #f1f3f5;
    z-index: 0;
}

.history-item {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.history-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: white;
    border: 2px solid #f1f3f5;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    z-index: 2;
    font-size: 0.95rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.history-icon.hi-status { border-color: #6366f1; color: #6366f1; }
.history-icon.hi-assign { border-color: #06b6d4; color: #06b6d4; }
.history-icon.hi-comment { border-color: #10b981; color: #10b981; }

.history-content {
    flex-grow: 1;
    background: #ffffff;
    padding: 1.25rem;
    border-radius: 12px;
    border: 1px solid #f1f3f5;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.history-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-meta {
    font-weight: 500;
    font-size: 0.72rem;
    color: #94a3b8;
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.history-text {
    font-size: 0.9rem;
    color: #475569;
    line-height: 1.5;
}

/* History Chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.chip {
    padding: 0.35rem 0.8rem;
    background: #f1f5f9;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: 1px solid #e2e8f0;
}

.chip i { font-size: 0.8rem; color: #64748b; }

.chip--time {
    background: #f0fdf4;
    color: #16a34a;
    border-color: #dcfce7;
}

/* Create Task Page Specifics */
.btn-broadcast {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    border: none;
    border-radius: 12px;
    padding: 1rem 2rem;
    font-weight: 700;
    font-size: 1.1rem;
    color: white;
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.btn-broadcast::after {
    content: '';
    position: absolute;
    top: 0; left: -100%; width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: 0.5s;
}

.btn-broadcast:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.5);
    color: white;
}

.btn-broadcast:hover::after {
    left: 100%;
}

.attachment-zone { display: flex; gap: 0.75rem; align-items: center; }
.btn-camera, .btn-files {
    width: 44px; height: 44px; border-radius: 12px; border: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.25rem; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); color: white;
}
.btn-camera { background: #10b981; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3); }
.btn-files { background: #6366f1; box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3); }

.btn-camera:hover, .btn-files:hover { 
    transform: translateY(-2px) rotate(3deg); 
    box-shadow: 0 6px 18px rgba(0,0,0,0.15); 
    filter: brightness(1.1);
    color: white; 
}

.file-preview-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.file-preview-item { 
    position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; 
    border: 2px solid #f1f5f9; transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.file-preview-item:hover { transform: scale(1.05); box-shadow: 0 5px 15px rgba(0,0,0,0.1); border-color: #e2e8f0; }

.file-preview-item img { width: 100%; height: 100%; object-fit: cover; }

.remove-file { 
    position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; 
    background: #ef4444; color: white; border: none; border-radius: 50%; 
    display: flex; align-items: center; justify-content: center; 
    font-size: 14px; cursor: pointer; transition: 0.2s;
    z-index: 10;
}
.remove-file:hover { background: #dc2626; transform: scale(1.1); }

.file-name {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: rgba(0,0,0,0.6); color: white; font-size: 0.65rem;
    padding: 2px 5px; text-align: center; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis;
}

/* Soft Attachment Grid In Modal */
.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.attachment-item {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #f1f5f9;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.attachment-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0,0,0,0.08);
    border-color: #e2e8f0;
}

.attachment-item a {
    text-decoration: none;
    display: block;
}

.attachment-item img {
    width: 100%;
    height: 90px;
    object-fit: cover;
}

.attachment-item .pdf {
    height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff1f2 0%, #fee2e2 100%);
    color: #ef4444;
    font-size: 1.75rem;
}

.attachment-item .cap {
    padding: 8px 10px;
    font-size: 0.75rem;
    color: #475569;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

/* Modal UI Fixes */
@media (max-width: 768px) {
    #taskModal .modal-body {
        padding: 1.25rem 1.15rem !important;
    }
    
    .attachment-grid {
        grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
        gap: 0.85rem;
    }
    
    .attachment-item img, .attachment-item .pdf {
        height: 80px;
    }
}
