/* Custom Application Styles */

/* Add your custom styles here */

/* Quick Actions Button Consistency */
.card-body .row .btn-outline-primary,
.card-body .row .btn-primary {
    border: 1px solid var(--primary-color) !important;
    color: var(--primary-color) !important;
    background-color: transparent !important;
    transition: all 0.3s ease;
}

.card-body .row .btn-outline-primary:hover,
.card-body .row .btn-primary:hover {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
}

.card-body .row .btn-outline-primary:focus,
.card-body .row .btn-outline-primary:active,
.card-body .row .btn-primary:focus,
.card-body .row .btn-primary:active {
    background-color: var(--primary-color) !important;
    color: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 0.2rem rgba(19, 135, 197, 0.25) !important;
}

/* ============================================ */
/* Slide-in Panel Styles (Global) */
/* ============================================ */

.task-panel-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1050;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.task-panel-backdrop.show {
    display: block;
    opacity: 1;
}

.task-panel {
    position: fixed;
    top: 0;
    right: -50%;
    width: 50%;
    height: 100vh;
    background: white;
    z-index: 1060;
    transition: right 0.3s ease-in-out, width 0.3s ease-in-out;
    box-shadow: -5px 0 15px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
}

.task-panel.show {
    right: 0;
}

/* Quick View Panel - Narrower Width */
.task-panel.quick-view-panel {
    width: 28%;
    right: -28%;
}

.task-panel.quick-view-panel.show {
    right: 0;
}

.task-panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--primary-color);
    color: white;
}

.task-panel-header h5 {
    margin: 0;
    color: white;
    font-weight: 600;
}

.task-panel-header .btn-close {
    filter: brightness(0) invert(1);
}

.task-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.task-panel-body .invalid-feedback {
    display: block;
    margin-top: 0.25rem;
}

.task-panel-body .product-row .invalid-feedback:empty {
    display: none;
}

/* Responsive design for mobile */
@media (max-width: 768px) {
    .task-panel {
        width: 100%;
        right: -100%;
    }

    .task-panel.quick-view-panel {
        width: 100%;
        right: -100%;
    }
}

/* Print styles - hide panel when printing */
@media print {
    .task-panel,
    .task-panel-backdrop {
        display: none !important;
    }
}

/* ============================================ */
/* Pipeline/Kanban View Styles */
/* ============================================ */

/* Prevent page-level horizontal scroll - CRITICAL */
html {
    overflow-x: hidden !important;
    max-width: 100vw;
}

body {
    overflow-x: hidden !important;
    max-width: 100vw;
    position: relative;
}

.container-fluid {
    overflow-x: hidden !important;
    max-width: 100%;
}

.main-content {
    overflow-x: hidden !important;
}

#pipeline-view.card {
    min-height: calc(100vh - 350px);
    max-height: calc(100vh - 350px);
    height: calc(100vh - 350px);
    width: 100%;
    max-width: 100%;
    overflow: hidden !important;
    position: relative;
    box-sizing: border-box;
}

.pipeline-container {
    height: 100%;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    position: relative;
    box-sizing: border-box;
}

.pipeline-columns-wrapper {
    display: flex;
    gap: 1.5rem;
    overflow-x: auto !important;
    overflow-y: hidden;
    padding: 1rem;
    flex: 1;
    width: calc(100% - 2rem);
    max-width: calc(100% - 2rem);
    margin: 0 auto;
    position: relative;
    flex-wrap: nowrap;
    box-sizing: border-box;
    min-height: 350px;
}

/* Horizontal scrollbar styling */
.pipeline-columns-wrapper::-webkit-scrollbar {
    height: 8px;
}

.pipeline-columns-wrapper::-webkit-scrollbar-track {
    background: #f1f3f4;
    border-radius: 4px;
}

.pipeline-columns-wrapper::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 4px;
}

.pipeline-columns-wrapper::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

.pipeline-column {
    flex: 0 0 auto;
    min-width: 280px;
    max-width: 280px;
    min-height: 300px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
}

.column-header {
    position: sticky;
    top: 0;
    z-index: 10;
    padding: 0.5rem 0.75rem;
    background: var(--primary-color);
    color: white;
    display: flex;
    flex-direction: column;
    border-radius: 6px 6px 0 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.column-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

/* Stage Color Coding - Open Stages (Blue) */
.stage-open-header {
    background: var(--primary-color) !important;
}

.stage-open-column {
    border: 2px solid rgba(19, 135, 197, 0.3);
}

/* Stage Color Coding - Won/Deal Stages (Green) */
.stage-won-header {
    background: rgba(40, 167, 69, 0.7) !important;
}

.stage-won-column {
    border: 2px solid rgba(40, 167, 69, 0.3);
}

/* Stage Color Coding - Lost/No Deal Stages (Red) */
.stage-lost-header {
    background: #e57373 !important;
}

.stage-lost-column {
    border: 2px solid rgba(229, 115, 115, 0.3);
}

.column-header h6 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.column-header .badge {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    border-radius: 10px;
    font-size: 0.7rem;
    min-width: 24px;
    text-align: center;
}

.column-total-amount {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.85);
    font-weight: 400;
    margin-left: 0.3rem;
    white-space: nowrap;
}

.column-body {
    flex: 1;
    padding: 0.65rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.column-body::-webkit-scrollbar {
    width: 6px;
}

.column-body::-webkit-scrollbar-track {
    background: #e9ecef;
    border-radius: 3px;
}

.column-body::-webkit-scrollbar-thumb {
    background: #adb5bd;
    border-radius: 3px;
}

.column-body::-webkit-scrollbar-thumb:hover {
    background: #6c757d;
}

.task-card {
    background: white;
    border-radius: 6px;
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.65rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e9ecef;
    position: relative;
}

.task-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
    border-color: var(--primary-color);
}

.task-card-overdue {
    background-color: #fff5f5;
    border-color: #ffcccc;
}

.task-card-overdue:hover {
    background-color: #ffe6e6;
    border-color: #ff9999;
}

.task-card:last-child {
    margin-bottom: 0;
}

.task-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
    gap: 0.4rem;
}

.task-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.3;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-card-actions {
    display: flex;
    gap: 0.2rem;
    flex-shrink: 0;
}

.task-action-icon {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(19, 135, 197, 0.1);
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.75rem;
}

.task-action-icon:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.task-card-client {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: #495057;
    margin-bottom: 0.45rem;
    padding: 0.25rem 0.4rem;
    background: #f8f9fa;
    border-radius: 3px;
}

.task-card-client i {
    color: var(--primary-color);
    font-size: 0.85rem;
}

.task-card-info {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
    font-size: 0.8rem;
}

.task-card-amount {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-weight: 600;
    color: #28a745;
}

.task-card-amount i {
    font-size: 0.8rem;
}

.task-card-date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #6c757d;
}

.task-card-date i {
    color: var(--primary-color);
    font-size: 0.8rem;
}

.task-card-assignee {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    color: #6c757d;
    font-size: 0.75rem;
    margin-bottom: 0;
}

.task-card-assignee i {
    color: var(--primary-color);
    font-size: 0.8rem;
}

.task-card-footer {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #e9ecef;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.task-assignees {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.assignee-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.assignee-avatar:not(:first-child) {
    margin-left: -8px;
}

.assignee-more {
    background: #6c757d;
    font-size: 0.65rem;
}


.company-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: #e7f3ff;
    color: var(--primary-color);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* Drag and Drop States */
.task-card.updating {
    opacity: 0.5;
    pointer-events: none;
}

.task-card-ghost {
    opacity: 0.4;
    background: #e7f3ff;
}

.task-card-dragging {
    opacity: 0.8;
    transform: rotate(2deg);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

.column-body.drag-over {
    background: #e7f3ff;
}

/* Empty State */
.column-empty {
    text-align: center;
    padding: 2rem 1rem;
    color: #adb5bd;
    font-size: 0.9rem;
}

.column-empty i {
    font-size: 2rem;
    display: block;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Loading State */
.pipeline-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

.pipeline-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    #pipeline-view.card {
        min-height: calc(100vh - 380px);
        max-height: calc(100vh - 380px);
        height: calc(100vh - 380px);
    }

    .pipeline-columns-wrapper {
        gap: 1rem;
    }

    .pipeline-column {
        min-width: 280px;
        max-width: 280px;
    }
}

/* Status Filter Dropdown */
.status-filter-item {
    cursor: pointer;
    padding: 0.5rem 1rem;
    transition: background-color 0.2s ease;
}

.status-filter-item:hover {
    background-color: rgba(19, 135, 197, 0.1);
}

.status-filter-item.active {
    background-color: rgba(19, 135, 197, 0.15);
    font-weight: 600;
    color: var(--primary-color);
}

.status-filter-item .badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

#statusFilterDropdown {
    font-weight: 500;
}

#statusFilterDropdown .badge {
    font-weight: 600;
}

/* View Switcher */
.view-switcher {
    display: flex;
    gap: 0.5rem;
}

.view-switcher .btn {
    transition: all 0.2s ease;
}

.view-switcher .btn-outline-primary.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.view-switcher .btn-outline-light {
    color: white;
    border-color: rgba(255, 255, 255, 0.5);
}

.view-switcher .btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.8);
    color: white;
}

.view-switcher .btn-outline-light.active {
    background: white;
    color: var(--primary-color);
    border-color: white;
}

/* ============================================ */
/* Quick View Panel Styles */
/* ============================================ */

.quick-view-content {
    background: white;
}

.quick-view-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
}

.quick-view-header h5 {
    font-size: 1rem;
    font-weight: 600;
    color: #212529;
    line-height: 1.4;
}

.quick-view-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f1f3f4;
}

.quick-view-section:last-of-type {
    border-bottom: none;
}

.section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 0.75rem;
    letter-spacing: 0.5px;
}

/* Information Grid */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.info-label {
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 500;
}

.info-value {
    font-size: 0.875rem;
    color: #212529;
    font-weight: 500;
}

/* Related Items */
.related-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.related-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Description */
.description-content {
    font-size: 0.875rem;
    color: #495057;
    line-height: 1.6;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
}

/* Products List */
.products-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.product-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.product-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
}

.product-qty {
    font-size: 0.75rem;
    color: #6c757d;
}

.product-price {
    font-size: 0.875rem;
    font-weight: 600;
    color: #28a745;
}

/* Other Info */
.other-info {
    display: flex;
    align-items: center;
}

.other-info-badge {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #28a745;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Action Buttons */
.quick-view-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    display: flex;
    gap: 0.75rem;
    position: sticky;
    bottom: 0;
}

.quick-view-actions .btn {
    flex: 1;
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
}

/* ============================================ */
/* Task Comments Styles (Global) */
/* ============================================ */

/* Comment Input Box Hover Effect */
#comment-box-collapsed > div:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%) !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 4px 12px rgba(17, 117, 187, 0.15);
    transform: translateY(-2px);
}

/* Comment Item Styles */
.comment-item {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.comment-item:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-color: #dee2e6;
}

.comment-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0d6eaf 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(17, 117, 187, 0.2);
}

.comment-header {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
    justify-content: space-between;
}

.comment-meta {
    flex: 1;
    margin-left: 0.875rem;
}

.comment-author {
    font-weight: 600;
    color: #212529;
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.comment-timestamp {
    color: #6c757d;
    font-size: 0.8125rem;
}

.comment-edited-badge {
    display: inline-block;
    background: #f8f9fa;
    color: #6c757d;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.comment-text-display {
    color: #495057;
    line-height: 1.6;
    font-size: 0.9375rem;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.comment-actions {
    display: flex;
    gap: 0.5rem;
}

.comment-actions .btn-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    text-decoration: none;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.comment-actions .btn-link:hover {
    background: #f8f9fa;
}

.comment-actions .btn-link.text-primary:hover {
    background: #e7f3ff;
}

.comment-actions .btn-link.text-danger:hover {
    background: #ffebee;
}

.comments-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.comments-empty-state i {
    font-size: 3.5rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.comments-empty-state p {
    font-size: 1rem;
    margin-top: 0.75rem;
    color: #868e96;
}

/* Comment Edit Form */
.comment-edit-form {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed #dee2e6;
}

.edit-comment-textarea {
    border-radius: 8px;
    border: 1px solid #dee2e6;
    font-size: 0.9375rem;
}

.edit-comment-textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(17, 117, 187, 0.15);
}

/* Quick View Comment Specific Styles */
.quick-view-section .comment-item {
    border-radius: 8px;
    padding: 1rem;
}

.quick-view-section .comment-time {
    font-size: 0.75rem;
    color: #6c757d;
}

.quick-view-section .comment-edited {
    font-size: 0.7rem;
    color: #6c757d;
    font-style: italic;
}

.quick-view-section .comment-body {
    color: var(--secondary-color);
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Document Attachments */
.documents-container {
    margin-top: 0.75rem;
}

.document-attachment {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-right: 0.625rem;
    margin-bottom: 0.625rem;
    transition: all 0.2s ease;
    max-width: 100%;
}

.document-attachment:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}

.document-icon {
    font-size: 1.5rem;
    margin-right: 0.625rem;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-weight: 600;
    font-size: 0.8125rem;
    color: #212529;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.125rem;
}

.document-size {
    font-size: 0.75rem;
    color: #6c757d;
}

.document-actions {
    display: flex;
    gap: 0.375rem;
    margin-left: 0.625rem;
}

.document-actions .btn-link {
    padding: 0.25rem;
    font-size: 1rem;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
}

.document-actions .btn-link:hover {
    transform: scale(1.15);
}

/* Overdue task row styling for DataTables */
.row-overdue,
.row-overdue > td {
    background-color: #fff5f5 !important;
}

.row-overdue:hover,
.row-overdue:hover > td {
    background-color: #ffe6e6 !important;
}

/* Override DataTables striping for overdue rows */
table.dataTable tbody tr.row-overdue.odd,
table.dataTable tbody tr.row-overdue.odd > td,
table.dataTable tbody tr.row-overdue.even,
table.dataTable tbody tr.row-overdue.even > td {
    background-color: #fff5f5 !important;
}

table.dataTable tbody tr.row-overdue.odd:hover,
table.dataTable tbody tr.row-overdue.odd:hover > td,
table.dataTable tbody tr.row-overdue.even:hover,
table.dataTable tbody tr.row-overdue.even:hover > td {
    background-color: #ffe6e6 !important;
}
