/**
 * Silva Customer Portal - Enterprise Projects Tab Styles
 * 
 * Modern, mobile-first design system matching Figma mockups
 * Includes: Property header, detail views, responsive cards
 * 
 * @package Silva_Customer_Portal
 * @version 2.3.0
 */

/* ========================================
   PROPERTY HEADER CARD (Enterprise)
   ======================================== */

.property-header-card {
    background: #ffffff;
    border: 1px solid #f0f0f0; /* Lighter border for modern look */
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04); /* Softer shadow */
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    position: relative; /* Ensure normal flow positioning */
    z-index: 1; /* Keep above background but below modals */
}

/* Projects List View Container */
.projects-list-view {
    position: relative;
    width: 100%;
}

/* Projects Accordion - Ensure it's not covered */
#projects-accordion {
    position: relative;
    z-index: 0;
    margin-top: 0; /* Header already has margin-bottom */
    clear: both; /* Clear any floats */
    padding-bottom: 100px; /* Add padding for fixed bottom nav */
}

.property-info-section {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 250px;
}

.property-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.property-details {
    flex: 1;
}

.property-title {
    font-size: 13px;
    font-weight: 500;
    color: #6b7280;
    margin: 0 0 2px 0;
}

.property-address {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.property-actions-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    min-width: 280px;
}

/* Appointment Button States */
.btn-appointment {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    background: #3b82f6;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-appointment:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(59, 130, 246, 0.3);
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.btn-icon:empty {
    display: none;
}

/* ========================================
   UPCOMING VISIT CARD (Modern)
   ======================================== */

.upcoming-visit-card {
    width: 100%;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s ease;
}

.upcoming-visit-card:hover {
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.15);
    transform: translateY(-1px);
}

.visit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.visit-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #0369a1;
}

.visit-icon {
    display: inline-flex;
    align-items: center;
    color: #0284c7;
}

.visit-badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #0ea5e9;
    color: #ffffff;
}

.visit-details {
    margin-bottom: 12px;
}

.visit-type {
    font-size: 15px;
    font-weight: 600;
    color: #0c4a6e;
    margin-bottom: 4px;
}

.visit-datetime {
    font-size: 13px;
    color: #0369a1;
    font-weight: 500;
}

.visit-action {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #0284c7;
    text-decoration: none;
    transition: all 0.2s;
}

.visit-action:hover {
    color: #0369a1;
    transform: translateX(2px);
}

/* ========================================
   ACTION ITEMS (Priority Alerts)
   ======================================== */

.action-item {
    width: 100%;
    margin-bottom: 12px;
    padding: 14px 16px;
    border-radius: 10px;
    border-left: 4px solid transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.action-item.priority-high {
    background: #fef2f2;
    border-left-color: #dc2626;
}

.action-item.priority-high:hover {
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.15);
    transform: translateX(2px);
}

.action-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: #dc2626;
}

.action-content {
    flex: 1;
}

.action-title {
    font-size: 14px;
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 2px;
}

.action-subtitle {
    font-size: 13px;
    color: #dc2626;
    font-weight: 500;
}

/* Appointment Scheduled Success Card */
.appointment-reminder {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    background: #f0fdf4;
    border-left: 4px solid #10b981;
}

.appointment-reminder.appointment-scheduled {
    background: #ecfdf5;
}

.reminder-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.reminder-content {
    flex: 1;
}

.reminder-title {
    font-size: 14px;
    font-weight: 600;
    color: #059669;
    margin-bottom: 2px;
}

.reminder-date {
    font-size: 13px;
    color: #047857;
}

/* Invoice Alert */
.invoice-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.invoice-alert-upcoming {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.invoice-alert-overdue {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
}

.invoice-alert:hover {
    transform: translateX(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-size: 13px;
    font-weight: 500;
    color: #92400e;
    margin-bottom: 2px;
}

.invoice-alert-overdue .alert-title {
    color: #991b1b;
}

.alert-amount {
    font-size: 16px;
    font-weight: 700;
    color: #b45309;
}

.invoice-alert-overdue .alert-amount {
    color: #dc2626;
}

.alert-action-btn {
    background: transparent;
    border: none;
    color: #b45309;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}

.invoice-alert-overdue .alert-action-btn {
    color: #dc2626;
}

/* Loading Skeleton */
.loading-skeleton {
    height: 48px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Estimate Loading Skeleton */
.loading-skeleton-estimate {
    padding: 20px 0;
}

.loading-skeleton-estimate .skeleton-section {
    margin-bottom: 24px;
}

.loading-skeleton-estimate .skeleton-title,
.loading-skeleton-estimate .skeleton-box,
.loading-skeleton-estimate .skeleton-line-item > div,
.loading-skeleton-estimate .skeleton-total > div {
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.loading-skeleton-estimate .skeleton-box {
    animation-delay: 0.1s;
}

.loading-skeleton-estimate .skeleton-line-item {
    animation: fadeIn 0.3s ease-out;
}

.loading-skeleton-estimate .skeleton-line-item:nth-child(2) {
    animation-delay: 0.1s;
}

.loading-skeleton-estimate .skeleton-line-item:nth-child(3) {
    animation-delay: 0.2s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ========================================
   DETAIL VIEW (Full-Page)
   ======================================== */

.projects-detail-view {
    min-height: 600px;
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    position: sticky;
    top: 0;
    z-index: 10;
}

.detail-back-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    color: #374151;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.detail-back-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.detail-title-group {
    flex: 1;
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 4px 0;
}

.detail-meta {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
}

/* Detail Content Sections */
.detail-content {
    padding: 24px;
    max-width: 100%;
}

.detail-section {
    background: #ffffff;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    max-width: 100%;
}

.breakdown-section {
    max-width: 100%;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 20px 0;
    letter-spacing: -0.02em;
}

/* Breakdown Table - Enhanced Card Layout */
.breakdown-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.breakdown-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.breakdown-row:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.breakdown-row:last-child {
    border-bottom: 1px solid #e5e7eb;
}

.breakdown-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.item-name {
    font-size: 16px;
    color: #111827;
    font-weight: 600;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 8px;
}

.item-name::before {
    content: attr(data-icon);
    font-size: 14px;
    opacity: 0.6;
    font-weight: 500;
    color: #64748b;
}

.item-description {
    font-size: 14px;
    color: #6b7280;
    line-height: 1.6;
    font-style: italic;
    padding-left: 22px;
}

.item-meta {
    font-size: 13px;
    color: #9ca3af;
    padding-left: 22px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.breakdown-amount {
    font-size: 17px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    margin-left: 16px;
    padding: 6px 12px;
    background: #f9fafb;
    border-radius: 6px;
}

.breakdown-subtotal {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #bae6fd;
    margin-top: 8px;
}

.breakdown-subtotal:hover {
    transform: none;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.subtotal-label,
.subtotal-amount {
    font-weight: 600;
    color: #0c4a6e;
}

.breakdown-total {
    padding: 20px;
    border: 2px solid #10b981;
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    margin-top: 12px;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.15);
}

.breakdown-total:hover {
    transform: none;
    box-shadow: 0 4px 6px rgba(16, 185, 129, 0.15);
}

.total-label {
    font-size: 18px;
    font-weight: 700;
    color: #064e3b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.total-amount {
    font-size: 28px;
    font-weight: 800;
    color: #059669;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Notes Section */
.notes-content {
    font-size: 15px;
    line-height: 1.6;
    color: #374151;
    margin: 0;
}

/* Validity Alert */
.validity-section {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.validity-alert {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: #92400e;
    font-weight: 500;
}

.validity-icon {
    font-size: 20px;
}

/* Enhanced Line Item Styles */
.line-item-row {
    background: #fafbfc;
    border-left: 3px solid #e5e7eb;
    transition: all 0.2s ease;
}

.line-item-row:hover {
    border-left-color: #3b82f6;
    background: #f9fafb;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.item-pricing-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    padding-left: 22px;
    flex-wrap: wrap;
}

/* Scope of Work Section */
.scope-section {
    margin-top: 24px;
}

.scope-content {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 20px;
    line-height: 1.8;
    color: #374151;
    white-space: pre-wrap;
    font-size: 15px;
}

.scope-content::-webkit-scrollbar {
    width: 8px;
}

.scope-content::-webkit-scrollbar-track {
    background: #f0f2f5;
    border-radius: 4px;
}

.scope-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.scope-content::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Deposit Information Section */
.deposit-section {
    margin-top: 20px;
}

.deposit-info-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.deposit-info-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Payment Terms Section */
.terms-section {
    margin-top: 20px;
}

.terms-content {
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 20px;
    line-height: 1.8;
    color: #78350f;
    white-space: pre-wrap;
    font-size: 14px;
}

/* Detail Header Actions */
.detail-header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.btn-download-pdf {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.btn-download-pdf:hover {
    background: #2563eb;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.btn-download-pdf:active {
    transform: translateY(0);
}

.btn-download-pdf svg {
    flex-shrink: 0;
}

/* Progress Bar */
.progress-section {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid #3b82f6;
}

.progress-bar-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-bar {
    height: 16px;
    background: #e0f2fe;
    border-radius: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #2563eb);
    border-radius: 8px;
    transition: width 0.5s ease;
}

.progress-label {
    font-size: 14px;
    font-weight: 600;
    color: #1e40af;
    text-align: center;
}

/* Invoice Summary */
.invoice-amount-card {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.amount-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.amount-row.balance-due {
    padding-top: 16px;
    border-top: 2px solid #e5e7eb;
}

.amount-label {
    font-size: 15px;
    color: #6b7280;
    font-weight: 500;
}

.amount-value {
    font-size: 20px;
    font-weight: 700;
    color: #111827;
}

.amount-value.highlight {
    color: #dc2626;
    font-size: 24px;
}

/* Payment History */
.payments-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.payment-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
}

.payment-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.payment-amount {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.payment-meta {
    font-size: 13px;
    color: #6b7280;
}

.payment-status {
    font-size: 14px;
    color: #059669;
    font-weight: 600;
}

/* ========================================
   DETAIL ACTIONS (Sticky Bottom)
   ======================================== */

.detail-actions {
    position: sticky;
    bottom: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    padding: 16px 24px;
    display: flex;
    gap: 12px;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.05);
}

.detail-actions .btn {
    flex: 1;
    min-height: 48px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(180deg, #014385 0%, #012f6b 100%) !important;
    color: #ffffff;
    border: none;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(1, 67, 133, 0.15);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #01356a 0%, #012951 100%) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08), 0 4px 8px rgba(1, 67, 133, 0.2);
    transform: translateY(-1px);
}

.btn-primary:active {
    background: #01356a !important;
    box-shadow: 0 2px 6px rgba(1, 67, 133, 0.25);
    transform: translateY(0);
}

.btn-secondary {
    background: transparent;
    color: #014385;
    border: 1px solid #d0d7e2;
}

.btn-secondary:hover {
    background: #f3f7ff;
    border-color: #014385;
}

.btn-secondary:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-block {
    width: 100%;
}

/* Approval Success State */
.approval-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    background: #ecfdf5;
    border-radius: 8px;
    color: #059669;
    font-size: 15px;
    font-weight: 600;
}

.success-icon {
    font-size: 24px;
}

.approval-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    color: #6b7280;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.6s linear infinite; /* Animation defined in base.css */
}

/* ========================================
   LOADING SKELETONS
   ======================================== */

.loading-skeleton-detail {
    padding: 24px;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 50%, #f3f4f6 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-line:nth-child(1) { width: 60%; }
.skeleton-line:nth-child(2) { width: 100%; }
.skeleton-line:nth-child(3) { width: 80%; }
.skeleton-line:nth-child(4) { width: 90%; }

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .property-header-card {
        flex-direction: column;
        padding: 20px;
        gap: 16px;
    }
    
    .property-info-section {
        width: 100%;
        min-width: auto;
    }
    
    .property-actions-section {
        width: 100%;
        min-width: auto;
    }
    
    /* FIX: Prevent bottom content from being hidden behind fixed nav */
    .projects-detail-view {
        padding-bottom: 140px; /* Account for sticky actions + fixed bottom nav (70px nav + 70px actions + spacing) */
    }
    
    .detail-header {
        padding: 16px;
    }
    
    .detail-title {
        font-size: 20px;
    }
    
    .detail-content {
        padding: 16px;
        padding-bottom: 0; /* Remove double padding - handled by parent */
    }
    
    .detail-section {
        padding: 16px;
    }
    
    .detail-actions {
        padding: 12px 16px;
        flex-direction: column-reverse;
        margin-bottom: 70px; /* Lift above fixed bottom nav (60px nav height + 10px gap) */
    }
    
    .breakdown-row {
        flex-direction: column;
        gap: 12px;
        padding: 14px;
    }
    
    .breakdown-item {
        gap: 8px;
    }
    
    .item-name {
        font-size: 15px;
    }
    
    .item-description {
        padding-left: 0;
        font-size: 13px;
    }
    
    .item-meta {
        padding-left: 0;
        font-size: 12px;
    }
    
    .item-pricing-row {
        padding-left: 0;
        gap: 8px;
        font-size: 12px;
    }
    
    .item-pricing-row > span {
        font-size: 12px !important;
        padding: 4px 8px !important;
    }
    
    .scope-content {
        padding: 16px;
        font-size: 14px;
        max-height: 250px !important;
    }
    
    .deposit-info-card {
        padding: 16px;
        flex-direction: column;
        align-items: flex-start;
    }
    
    .deposit-info-card > div:first-child {
        width: 100%;
    }
    
    .terms-content {
        padding: 16px;
        font-size: 13px;
    }
    
    .btn-download-pdf {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .btn-download-pdf span {
        display: none;
    }
    
    .btn-download-pdf svg {
        width: 18px;
        height: 18px;
    }
    
    .detail-header-actions {
        position: absolute;
        right: 16px;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .breakdown-amount {
        margin-left: 0;
        align-self: flex-start;
        font-size: 16px;
    }
    
    .total-amount {
        font-size: 24px;
    }
    
    .breakdown-total {
        padding: 16px;
    }
}

/* Touch-friendly targets (WCAG 2.1 AA) */
@media (hover: none) {
    .btn,
    .detail-back-btn,
    .accordion-header {
        min-height: 44px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .property-header-card,
    .detail-section {
        border: 2px solid currentColor;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
