/* ===== MODALS ===== */
.pwa-modal {
    position: fixed !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000 !important;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.pwa-modal-content {
    background: #1e1e1e;
    border-radius: 16px;
    width: 95% !important;
    max-width: 600px !important;
    max-height: 90vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
    border: 1px solid #333;
    -webkit-overflow-scrolling: touch !important;
}

.pwa-modal-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    background: #1e1e1e;
}

.pwa-modal-header h3 {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.pwa-modal-body {
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden !important;
    max-width: 100% !important;
    flex: 1;
    background: #121212;
}

/* Modal animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Job detail modal specific styles */
.pwa-modal.job-detail-modal .pwa-modal-content {
    max-width: 90%;
    max-height: 90vh;
}

.pwa-job-detail-tabs {
    display: flex;
    gap: 0;
    margin: -20px -20px 20px -20px;
    background: #1e1e1e;
    border-bottom: 1px solid #333;
    overflow: hidden; /* No scroll */
    justify-content: space-around; /* Distribute evenly */
}

.pwa-job-detail-tabs .pwa-tab-button {
    background: transparent;
    border: none;
    color: #666;
    padding: 12px 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
    position: relative;
}

/* Icon styling */
.pwa-job-detail-tabs .pwa-tab-button i {
    font-size: 18px;
    display: block;
}

/* Hide text by default, show on active */
.pwa-job-detail-tabs .pwa-tab-button span {
    display: none;
    font-size: 10px;
}

.pwa-job-detail-tabs .pwa-tab-button.active span {
    display: block;
}

.pwa-job-detail-tabs .pwa-tab-button:hover {
    color: #999;
    background: rgba(34, 197, 94, 0.05);
}

.pwa-job-detail-tabs .pwa-tab-button.active {
    color: #22c55e;
    border-bottom-color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

/* Secondary modals (material, photo, timesheet) */
.secondary-modal {
    z-index: 10100 !important;
}

.secondary-modal .pwa-modal-content {
    max-width: 500px !important;
}

/* Improved tab panel styling */
.pwa-tab-panel {
    display: none;
    padding: 0;
    animation: fadeIn 0.3s ease;
    overflow-x: hidden !important;
    max-width: 100% !important;
}

.pwa-tab-panel.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Job info styles */
.pwa-job-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pwa-info-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pwa-info-group label {
    color: #999;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
}

.pwa-info-group span {
    color: #fff;
    font-size: 14px;
}

.pwa-info-group p {
    color: #ccc;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

.pwa-job-actions {
    display: flex;
    gap: 8px;
    margin-top: 20px;
}

/* Checklist modal styles */
.pwa-checklist-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.pwa-checklist-group {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #333;
}

.pwa-checklist-category {
    color: #22c55e;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pwa-checklist-item {
    padding: 8px 0;
    border-bottom: 1px solid #2a2a2a;
    transition: all 0.2s ease;
}

.pwa-checklist-item:last-child {
    border-bottom: none;
}

.pwa-checklist-item.completed {
    opacity: 0.6;
}

.pwa-checklist-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-checklist-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.pwa-checklist-checkbox label {
    color: #ccc;
    font-size: 14px;
    cursor: pointer;
    flex: 1;
}

.pwa-checklist-name {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pwa-checklist-instruction {
    margin-top: 4px;
    margin-left: 26px;
    color: #666;
    font-size: 12px;
}

.pwa-checklist-completed {
    margin-top: 4px;
    margin-left: 26px;
    color: #22c55e;
    font-size: 11px;
}

.pwa-checklist-progress {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #333;
}

.pwa-progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    color: #999;
    font-size: 13px;
}

/* Materials modal styles */
.pwa-materials-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pwa-material-item {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
}

.pwa-material-name {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.pwa-material-info {
    display: flex;
    gap: 12px;
    color: #999;
    font-size: 12px;
}

/* Photo modal styles */
.pwa-photo-section {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pwa-photo-group h4 {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.pwa-photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}

.pwa-photo-item {
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s ease;
    position: relative;
    border: 1px solid #333;
}

.pwa-photo-item:hover {
    transform: scale(1.05);
}

.pwa-photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pwa-photo-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
    color: white;
    padding: 6px;
    font-size: 11px;
}

/* Timesheet modal styles */
.pwa-timesheet-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 16px;
}

.pwa-stat {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}

.pwa-stat-value {
    font-size: 24px;
    font-weight: 600;
    color: #22c55e;
}

.pwa-stat-label {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
}

/* Signature modal styles */
.pwa-signature-container {
    background: #1e1e1e;
    border-radius: 8px;
    padding: 8px;
    border: 1px solid #333;
}

.pwa-signature-pad {
    background: white;
    border-radius: 4px;
    cursor: crosshair;
    display: block;
    width: 100%;
    height: 200px;
}

.pwa-signature-actions {
    margin-top: 8px;
    text-align: right;
}

/* Mobile responsiveness for modals */
@media (max-width: 768px) {
    .pwa-modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .pwa-modal.job-detail-modal .pwa-modal-content {
        max-width: 100%;
        max-height: 95vh;
        margin: 10px;
    }

    .pwa-job-detail-tabs {
        scrollbar-width: none;
    }

    .pwa-job-detail-tabs::-webkit-scrollbar {
        display: none;
    }
}

/* Better styling for tab content sections */
#checklist-section,
#materials-section,
#photos-section,
#timesheet-section {
    padding: 15px;
    background: #1a1a1a;
    border-radius: 8px;
    min-height: 200px;
}

/* Mobile specific - even smaller */
@media (max-width: 768px) {
    .pwa-job-detail-tabs .pwa-tab-button {
        padding: 10px 4px;
    }

    .pwa-job-detail-tabs .pwa-tab-button i {
        font-size: 16px;
    }
}
