/* ========================================
   PROJECTS DASHBOARD STYLES
   Matches existing app theme
   ======================================== */

/* ========================================
   STATUS TABS
   ======================================== */

.status-tabs {
    display: flex;
    gap: 8px;
    padding: 16px 0;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.status-tab {
    padding: 10px 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    color: #64748b;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-tab:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.status-tab.active {
    background: #2563eb;
    color: white;
    border-color: #2563eb;
}

.tab-count {
    background: rgba(0,0,0,0.1);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.status-tab.active .tab-count {
    background: rgba(255,255,255,0.2);
}

/* ========================================
   VIEW TOGGLE
   ======================================== */

.view-toggle {
    display: flex;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.view-btn {
    padding: 8px 16px;
    border: none;
    background: white;
    color: #64748b;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.view-btn:hover {
    background: #f8fafc;
}

.view-btn.active {
    background: #2563eb;
    color: white;
}

.view-btn + .view-btn {
    border-left: 1px solid #e5e7eb;
}

/* ========================================
   PROJECTS GRID (Card View)
   ======================================== */

.projects-container {
    padding: 0 20px 20px;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.projects-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ========================================
   PROJECT CARD (Sticky Note Style)
   ======================================== */

.project-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.project-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.project-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--project-color, #3b82f6);
}

/* Priority Colors */
.project-card[data-priority="urgent"]::before { background: #ef4444; }
.project-card[data-priority="high"]::before { background: #f97316; }
.project-card[data-priority="normal"]::before { background: #3b82f6; }
.project-card[data-priority="low"]::before { background: #22c55e; }

.project-card-header {
    padding: 16px 16px 12px;
    border-bottom: 1px solid #f1f5f9;
}

.project-card-id {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.project-card-title {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.project-card-customer {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.project-card-body {
    padding: 12px 16px;
}

.project-card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.project-status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.project-status-badge.planning {
    background: #e0f2fe;
    color: #0369a1;
}

.project-status-badge.in_progress {
    background: #fef3c7;
    color: #b45309;
}

.project-status-badge.on_hold {
    background: #f3e8ff;
    color: #7c3aed;
}

.project-status-badge.completed {
    background: #dcfce7;
    color: #15803d;
}

.project-status-badge.cancelled {
    background: #fee2e2;
    color: #dc2626;
}

.project-value {
    font-size: 14px;
    font-weight: 600;
    color: #059669;
}

/* Progress Bar */
.project-progress-container {
    margin-bottom: 12px;
}

.project-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
}

.project-progress-label {
    font-size: 11px;
    color: #64748b;
}

.project-progress-percent {
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
}

.project-progress-bar {
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.project-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.project-progress-fill.completed {
    background: linear-gradient(90deg, #22c55e 0%, #16a34a 100%);
}

/* Task Stats */
.project-task-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #64748b;
}

.task-stat {
    display: flex;
    align-items: center;
    gap: 4px;
}

.task-stat-icon {
    font-size: 14px;
}

/* Card Footer */
.project-card-footer {
    padding: 12px 16px;
    background: #f8fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.project-dates {
    font-size: 11px;
    color: #64748b;
}

.project-dates span {
    display: block;
}

.project-dates .overdue {
    color: #dc2626;
    font-weight: 600;
}

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

.project-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background: white;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s ease;
}

.project-action-btn:hover {
    background: #e5e7eb;
    color: #1e293b;
}

.project-action-btn.primary:hover {
    background: #2563eb;
    color: white;
}

/* ========================================
   LIST VIEW STYLES
   ======================================== */

.projects-grid.list-view .project-card {
    display: flex;
    align-items: center;
    padding: 16px;
}

.projects-grid.list-view .project-card::before {
    width: 4px;
    height: 100%;
    top: 0;
    left: 0;
    right: auto;
}

.projects-grid.list-view .project-card-header,
.projects-grid.list-view .project-card-body,
.projects-grid.list-view .project-card-footer {
    border: none;
    padding: 0;
    background: none;
}

.projects-grid.list-view .project-card-header {
    flex: 1;
    min-width: 200px;
    padding-left: 16px;
}

.projects-grid.list-view .project-card-body {
    flex: 2;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 24px;
}

.projects-grid.list-view .project-card-meta {
    margin: 0;
}

.projects-grid.list-view .project-progress-container {
    flex: 1;
    margin: 0;
    min-width: 150px;
}

.projects-grid.list-view .project-task-stats {
    min-width: 120px;
}

.projects-grid.list-view .project-card-footer {
    min-width: 180px;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

/* ========================================
   SIDEBAR STATS
   ======================================== */

.project-stats-mini {
    display: flex;
    gap: 8px;
}

.project-stats-mini .stat-item {
    flex: 1;
    background: rgba(255,255,255,0.1);
    padding: 12px 8px;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.project-stats-mini .stat-item:hover {
    background: rgba(255,255,255,0.15);
}

.project-stats-mini .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: white;
}

.project-stats-mini .stat-label {
    display: block;
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* ========================================
   SIDEBAR NAV LINK
   ======================================== */

.sidebar-nav-link {
    display: block;
    padding: 10px 12px;
    background: rgba(255,255,255,0.1);
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 13px;
    transition: all 0.2s ease;
}

.sidebar-nav-link:hover {
    background: rgba(255,255,255,0.2);
}

/* ========================================
   EMPTY STATE
   ======================================== */

.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 20px;
    color: #1e293b;
    margin: 0 0 8px 0;
}

.empty-state p {
    color: #64748b;
    margin: 0 0 24px 0;
}

/* ========================================
   LOADING STATE
   ======================================== */

.loading-placeholder {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

/* ========================================
   PROJECT DETAIL MODAL
   ======================================== */

.project-detail-modal {
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.project-detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.project-detail-title-section {
    flex: 1;
}

.project-detail-id {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.project-detail-title {
    font-size: 22px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 8px 0;
}

.project-detail-customer {
    font-size: 14px;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.project-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    min-height: 0;  /* ADD THIS LINE */
}


/* Tabs in Detail View */
.detail-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 24px;
}

.detail-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    color: #64748b;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.2s ease;
}

.detail-tab:hover {
    color: #1e293b;
}

.detail-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.detail-tab-content {
    display: none;
}

.detail-tab-content.active {
    display: block;
}

/* Tasks List */
.tasks-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.task-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.task-item:hover {
    background: #f1f5f9;
}

.task-checkbox {
    width: 20px;
    height: 20px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.task-checkbox.checked {
    background: #22c55e;
    border-color: #22c55e;
    color: white;
}

.task-content {
    flex: 1;
}

.task-title {
    font-size: 14px;
    color: #1e293b;
    font-weight: 500;
}

.task-item.completed .task-title {
    text-decoration: line-through;
    color: #94a3b8;
}

.task-meta {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.task-phase-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.task-phase-badge.pre_installation { background: #e0f2fe; color: #0369a1; }
.task-phase-badge.installation { background: #fef3c7; color: #b45309; }
.task-phase-badge.commissioning { background: #f3e8ff; color: #7c3aed; }
.task-phase-badge.handover { background: #dcfce7; color: #15803d; }

/* Notes Section */
.notes-section {
    margin-top: 20px;
}

.note-item {
    padding: 16px;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: 8px;
    margin-bottom: 12px;
}

.note-item.pinned {
    background: #fef3c7;
    border-color: #fcd34d;
}

.note-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.note-type {
    font-size: 11px;
    font-weight: 600;
    color: #b45309;
    text-transform: uppercase;
}

.note-date {
    font-size: 11px;
    color: #94a3b8;
}

.note-content {
    font-size: 14px;
    color: #1e293b;
    line-height: 1.5;
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e5e7eb;
}

.timeline-item {
    position: relative;
    padding-bottom: 20px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 4px;
    width: 10px;
    height: 10px;
    background: #3b82f6;
    border-radius: 50%;
    border: 2px solid white;
}

.timeline-item.project_created::before { background: #22c55e; }
.timeline-item.task_completed::before { background: #8b5cf6; }
.timeline-item.status_changed::before { background: #f59e0b; }
.timeline-item.note_added::before { background: #ec4899; }

.timeline-content {
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: 8px;
}

.timeline-action {
    font-size: 13px;
    color: #1e293b;
    font-weight: 500;
}

.timeline-description {
    font-size: 12px;
    color: #64748b;
    margin-top: 4px;
}

.timeline-date {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 6px;
}

/* ========================================
   TEMPLATES MODAL
   ======================================== */

.templates-modal {
    width: 90%;
    max-width: 600px;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #1e293b;
}

.modal-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    color: #64748b;
}

.modal-close-btn:hover {
    background: #e5e7eb;
    color: #1e293b;
}

.modal-body {
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.template-item {
    padding: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.template-item:hover {
    border-color: #3b82f6;
    background: #f8fafc;
}

.template-name {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 4px;
}

.template-description {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 8px;
}

.template-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #94a3b8;
}

.template-meta span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .projects-grid {
        grid-template-columns: 1fr;
    }
    
    .status-tabs {
        padding: 12px 0;
    }
    
    .status-tab {
        padding: 8px 12px;
        font-size: 12px;
    }
    
    .view-toggle {
        display: none;
    }
    
    .project-detail-modal {
        width: 100%;
        max-width: none;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }
    
    .projects-grid.list-view .project-card {
        flex-direction: column;
        align-items: stretch;
    }
    
    .projects-grid.list-view .project-card-header,
    .projects-grid.list-view .project-card-body,
    .projects-grid.list-view .project-card-footer {
        padding: 12px 16px;
    }
    
    .projects-grid.list-view .project-card-body {
        flex-direction: column;
        gap: 12px;
    }
}

/* ========================================
   MILESTONE MODAL FIX - SCROLLING
   ======================================== */

/* When milestone modal is shown, it uses .modal-content */
.modal-overlay .modal-content {
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

/* Milestone modal body */
.ms-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    padding: 20px;
}

/* Milestone modal header and footer shouldn't shrink */
.ms-modal-header {
    flex-shrink: 0;
}

.ms-modal-footer {
    flex-shrink: 0;
}
/* FORCE SCROLL FIX */
#projectDetailContent {
    max-height: 70vh !important;
    overflow-y: auto !important;
}

