/* ===== PM-HUB Projects Styles ===== */
/* Обновлённые стили для компактного дизайна */

/* ===== Page Header ===== */
.projects-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.projects-page .page-header h1 {
    font-size: 2rem;
    font-weight: 600;
    margin: 0;
}

/* ===== Page Header Compact (Stats + Tabs + Create Button) ===== */
.page-header-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.page-header-compact h1 {
    font-size: 1.75rem;
    font-weight: 600;
    margin: 0;
    flex-shrink: 0;
}

.stats-inline {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.stat-badge {
    font-size: 0.9rem;
    color: #495057;
}

.stat-badge strong {
    font-size: 1.1rem;
    color: #212529;
    margin-left: 0.25rem;
}

.stat-badge.stat-active strong {
    color: #28a745;
}

.stat-badge.stat-risk strong {
    color: #dc3545;
}

.btn-create-project {
    flex-shrink: 0;
    margin-left: auto;
}

/* ===== Compact Header (Stats + View Tabs) ===== */
.compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 1rem;
}

/* Stats Badges (inline) */
.stats-badges {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* View Tabs */
.view-tabs {
    display: flex;
    gap: 0.5rem;
}

.view-tab {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.view-tab:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.view-tab.active {
    background: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

.view-tab i {
    font-size: 1rem;
}

.tab-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.view-tab.active .tab-count {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== Filters Compact ===== */
.filters-compact {
    margin-bottom: 2rem;
}

.filters-form {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

/* Total Count (inline with search) */
.total-count {
    font-size: 0.9rem;
    color: #495057;
    white-space: nowrap;
}

.total-count strong {
    font-size: 1rem;
    color: #212529;
}

.search-box {
    flex: 1;
    min-width: 250px;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
}

.search-box input {
    padding-left: 38px;
}

.filters-form .form-select {
    width: auto;
    min-width: 180px;
}

/* ===== KANBAN BOARD VIEW ===== */
.kanban-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
}

.kanban-column {
    border-radius: 8px;
    min-width: 280px;
    /* Removed max-width for wide screen responsiveness */
    display: flex;
    flex-direction: column;
    height: calc(100vh - 320px);
    min-height: 500px;
    border: 1px solid #dee2e6;
}

/* Alternating column backgrounds */
.kanban-column:nth-child(odd) {
    background: #ffffff;
}

.kanban-column:nth-child(even) {
    background: #f8f9fa;
}

.kanban-column-header {
    padding: 1rem;
    border-bottom: 2px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 8px 8px 0 0;
}

.kanban-column-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: #495057;
}

.kanban-column-count {
    background: #e9ecef;
    color: #495057;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.kanban-column-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Kanban Card (compact version) */
.kanban-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 1rem;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    cursor: move;
    user-select: none;
}

.kanban-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    border-color: #0d6efd;
}

.kanban-card .card-title h3 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.kanban-card .project-code {
    font-size: 0.7rem;
}

.kanban-card .card-status {
    margin-bottom: 0.75rem;
}

.kanban-card .deadline-section {
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    font-size: 0.8rem;
}

/* Dual Progress Bars (UPDATED for visibility) */
.progress-dual {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.progress-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-icon {
    font-size: 1rem;
    flex-shrink: 0;
    width: 20px;
    text-align: center;
}

.progress-thin {
    flex: 1;
    height: 8px; /* INCREASED from 5px for visibility */
    border-radius: 4px;
    background: #e9ecef;
    overflow: hidden;
    position: relative;
}

.progress-thin .progress-bar {
    height: 100%;
    min-width: 2%; /* Show color even at 0-1% */
    transition: width 0.3s ease;
}

.progress-percent {
    font-size: 0.75rem;
    font-weight: 600;
    color: #495057;
    min-width: 35px;
    text-align: right;
    flex-shrink: 0;
}

/* Kanban Empty State */
.kanban-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    color: #adb5bd;
    text-align: center;
}

.kanban-empty i {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: #dee2e6;
}

.kanban-empty span {
    font-size: 0.9rem;
}

/* Kanban Column Header Colors (soft backgrounds) */
.kanban-planned .kanban-column-header {
    background: #f8f9fa;
    border-bottom-color: #dee2e6;
}

.kanban-active .kanban-column-header {
    background: #e7f3ff;
    border-bottom-color: #b8daff;
}

.kanban-hold .kanban-column-header {
    background: #fff8e6;
    border-bottom-color: #ffe8a1;
}

.kanban-completed .kanban-column-header {
    background: #e8f5e9;
    border-bottom-color: #c3e6cb;
}

.kanban-cancelled .kanban-column-header {
    background: #fce8e8;
    border-bottom-color: #f5c6cb;
}

/* ===== CARDS VIEW (Grid) ===== */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

.project-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 1.25rem;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: #0d6efd;
}

/* Card Header with Icons */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.card-title {
    flex: 1;
}

.card-title h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 0.25rem 0;
    color: #212529;
}

.project-code {
    font-size: 0.75rem;
    color: #6c757d;
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

/* Card Actions (Icons) */
.card-actions {
    display: flex;
    gap: 0.25rem;
}

.icon-btn {
    padding: 0.4rem;
    background: transparent;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    color: #6c757d;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.icon-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

.edit-btn:hover {
    background: #e7f3ff;
    border-color: #0d6efd;
    color: #0d6efd;
}

.menu-btn:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

/* Card Status */
.card-status {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Overrun Badge */
.badge-overrun {
    background: #ffe5e5 !important;
    color: #c92a2a !important;
    border: 1px solid #ffc9c9;
    font-weight: 700;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

/* ===== Deadline Section ===== */
.deadline-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.85rem;
}

.deadline-section i {
    color: #6c757d;
    font-size: 1rem;
    flex-shrink: 0;
}

.deadline-label {
    color: #6c757d;
    font-weight: 500;
    white-space: nowrap;
}

.deadline-value {
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.deadline-value small {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Budget Section ===== */
.budget-section {
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 6px;
    font-size: 0.85rem;
}

.budget-row,
.forecast-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.budget-row:last-child,
.forecast-row:last-child {
    margin-bottom: 0;
}

.budget-row i,
.forecast-row i {
    color: #6c757d;
    font-size: 1rem;
    min-width: 16px;
    flex-shrink: 0;
}

.budget-label,
.forecast-label {
    color: #6c757d;
    font-weight: 500;
    white-space: nowrap;
}

.budget-value,
.forecast-value {
    font-weight: 600;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

.budget-value small,
.forecast-value small {
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Progress Section */
.progress-section {
    margin-bottom: 0.5rem;
}

.progress-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.4rem;
    font-size: 0.8rem;
    color: #6c757d;
}

.progress-label span:first-child {
    font-weight: 500;
}

.progress-value {
    font-weight: 600;
    color: #495057;
}

.progress {
    height: 8px;
    border-radius: 4px;
    background: #e9ecef;
    overflow: hidden;
}

.progress-bar {
    transition: width 0.3s ease;
    min-width: 2%; /* ADDED: Show color even at 0-1% */
}

/* Card Metadata */
.card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: #6c757d;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.meta-item i {
    color: #adb5bd;
}

/* ===== TABLE VIEW ===== */
.projects-table {
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.projects-table th {
    background: #f8f9fa;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #495057;
    padding: 1rem 0.75rem;
    border-bottom: 2px solid #dee2e6;
}

.projects-table td {
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
}

.projects-table tbody tr {
    transition: background 0.2s;
}

.projects-table tbody tr:hover {
    background: #f8f9fa;
}

.projects-table code {
    background: #f8f9fa;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85rem;
    color: #495057;
}

/* Progress Inline (для таблицы) */
.progress-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.progress-percent {
    min-width: 40px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
}

.progress-sm {
    height: 8px;
    flex: 1;
}

/* Прогресс-бар БЕЗ цветной заливки (серый) */
.progress-inline .progress-bar {
    background-color: #6c757d !important;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 0.25rem;
}

.action-buttons .btn-sm {
    padding: 0.25rem 0.5rem;
}

/* ===== LIST VIEW ===== */
.projects-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.list-item {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.list-item:hover {
    border-color: #adb5bd;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.list-header {
    padding: 0.875rem 1rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.list-main {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    flex-wrap: wrap;
}

.expand-icon {
    font-size: 0.75rem;
    color: #6c757d;
    transition: transform 0.2s;
}

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

.project-code-inline {
    font-size: 0.8rem;
    color: #6c757d;
    font-family: 'Courier New', monospace;
    background: #f8f9fa;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.list-summary {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.85rem;
}

.progress-mini,
.budget-mini,
.date-mini {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.progress-mini {
    font-weight: 600;
    color: #495057;
}

.budget-mini {
    color: #6c757d;
}

.date-mini {
    color: #6c757d;
}

.date-mini i {
    font-size: 0.75rem;
}

/* List Details (раскрывающаяся секция) */
.list-details {
    display: none;
    padding: 1rem;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.list-item.expanded .list-details {
    display: block;
}

.detail-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.detail-row strong {
    min-width: 100px;
    font-size: 0.85rem;
}

.detail-row .progress {
    flex: 1;
    max-width: 300px;
}

.detail-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

/* ===== Status Badges ===== */
.badge {
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
}

/* Project Status */
.status-planned {
    background: #e7f3ff;
    color: #0056b3;
}

.status-active {
    background: #d1f2eb;
    color: #0f5132;
}

.status-on_hold {
    background: #fff3cd;
    color: #856404;
}

.status-completed {
    background: #d1e7dd;
    color: #0a3622;
}

.status-cancelled {
    background: #f8d7da;
    color: #721c24;
}

/* Health Status */
.health-success {
    background: #d1f2eb;
    color: #0f5132;
}

.health-warning {
    background: #fff3cd;
    color: #856404;
}

.health-danger {
    background: #f8d7da;
    color: #721c24;
}

/* Progress Bar Colors */
.bg-success {
    background-color: #28a745 !important;
}

.bg-warning {
    background-color: #ffc107 !important;
}

.bg-danger {
    background-color: #dc3545 !important;
}

.bg-info {
    background-color: #17a2b8 !important;
}

.bg-secondary {
    background-color: #6c757d !important;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #6c757d;
}

.empty-state i {
    color: #dee2e6;
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    margin-bottom: 0.75rem;
    color: #495057;
}

.empty-state p {
    margin-bottom: 2rem;
}

/* ===== Drag & Drop Styles ===== */
.sortable-ghost {
    opacity: 0.4;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
}

.sortable-drag {
    opacity: 0.8;
    cursor: grabbing !important;
    transform: rotate(3deg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.25) !important;
}

.sortable-chosen {
    cursor: grab;
}

/* Cursor styles for draggable cards */
.kanban-card {
    cursor: move; /* Show that card is draggable */
    user-select: none; /* Prevent text selection while dragging */
}

.kanban-card:active {
    cursor: grabbing;
}

/* Make edit button not trigger drag */
.card-actions {
    cursor: pointer; /* Keep normal pointer for action buttons */
}

/* ===== Responsive ===== */
@media (max-width: 1200px) {
    .kanban-board {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .page-header-compact {
        flex-direction: column;
        align-items: flex-start;
    }

    .compact-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .view-tabs {
        width: 100%;
        justify-content: space-between;
    }

    .view-tab {
        flex: 1;
        justify-content: center;
    }

    .tab-count {
        display: none;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }

    .kanban-board {
        grid-template-columns: 1fr;
    }

    .kanban-column {
        max-width: 100%;
    }

    .filters-form {
        flex-direction: column;
        width: 100%;
    }

    .search-box {
        width: 100%;
    }

    .filters-form .form-select {
        width: 100%;
    }

    .list-summary {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .detail-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-row .progress {
        max-width: 100%;
        width: 100%;
    }
}

@media (max-width: 576px) {
    .projects-page .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }

    .stats-badges {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .card-title h3 {
        font-size: 1rem;
    }

    .list-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ===== Form Styles ===== */
.form-page .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.form-container {
    max-width: 900px;
    margin: 0 auto;
}

.project-form {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid #e0e0e0;
}

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

.form-section h3 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

@media (max-width: 576px) {
    .form-actions {
        flex-direction: column;
    }

    .form-actions .btn {
        width: 100%;
    }
}
