/* ==================== MODAL SYSTEM ==================== */

/* ==================== MODAL SYSTEM ==================== */

/* CRITICAL: Modals must be hidden by default */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none; /* Hidden by default - IMPORTANT! */
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.modal {
    background: white;
    border-radius: 20px;
    max-width: 600px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    margin: 80px auto 40px; /* Added top margin to avoid header */
    position: relative;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-head {
    padding: 24px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}

.modal-head b {
    font-size: 20px;
    font-weight: 800;
    color: #212529;
}

.modal-body {
    padding: 24px;
}

.reg-modal-container {
    max-width: 500px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 700;
    color: #212529;
}

.reg-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    transition: all 0.3s ease;
}

.reg-input:focus {
    outline: none;
    border-color: #006C35;
    box-shadow: 0 0 0 3px rgba(0, 108, 53, 0.1);
}

/* ==================== CASE DETAILS MODAL ==================== */

.case-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9998;
    display: none;
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: center;
    overflow-y: auto;
    padding: 20px;
}

.case-modal {
    background: white;
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
    margin: 80px auto 40px; /* Added top margin to avoid header */
}

.case-modal-header {
    padding: 24px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}

.case-modal-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: #212529;
    margin: 0;
}

.case-modal-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f5f5f5;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #666;
}

.case-modal-close:hover {
    background: #e5e5e5;
    color: #212529;
    transform: rotate(90deg);
}

.case-modal-body {
    padding: 24px;
}

.case-modal-footer {
    padding: 20px 24px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: white;
    z-index: 10;
    border-radius: 0 0 20px 20px;
}

/* Case Detail Sections */
.case-detail-section {
    margin-bottom: 28px;
}

.case-detail-section:last-child {
    margin-bottom: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 800;
    color: #212529;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f5f5f5;
}

.section-title span {
    font-size: 20px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.detail-item {
    background: #f8f9fa;
    padding: 14px;
    border-radius: 10px;
    border-right: 3px solid #006C35;
}

.detail-label {
    font-size: 12px;
    color: #666;
    font-weight: 600;
    margin-bottom: 6px;
}

.detail-value {
    font-size: 15px;
    font-weight: 700;
    color: #212529;
}

.case-description {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 10px;
    line-height: 1.8;
    color: #495057;
    font-size: 14px;
    border-right: 3px solid #006C35;
}

/* Medicines List */
.medicines-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.medicine-item {
    background: #f8f9fa;
    padding: 14px;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-right: 3px solid #006C35;
}

.medicine-info {
    flex: 1;
}

.medicine-name {
    font-size: 15px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 6px;
}

.medicine-details {
    font-size: 13px;
    color: #666;
}

.medicine-price {
    font-size: 16px;
    font-weight: 800;
    color: #006C35;
    white-space: nowrap;
}

/* Medical Report Image */
.medical-report-image {
    width: 100%;
    max-width: 600px;
    height: auto;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.medical-report-image:hover {
    transform: scale(1.02);
}

/* NGO Info */
.ngo-info {
    display: flex;
    gap: 16px;
    background: #f8f9fa;
    padding: 16px;
    border-radius: 10px;
    border-right: 3px solid #006C35;
}

.ngo-logo {
    width: 64px;
    height: 64px;
    border-radius: 12px;
    object-fit: cover;
    flex-shrink: 0;
}

.ngo-details {
    flex: 1;
}

.ngo-name {
    font-size: 16px;
    font-weight: 700;
    color: #212529;
    margin-bottom: 6px;
}

.ngo-license {
    font-size: 13px;
    color: #666;
}

/* Progress Section */
.progress-section {
    background: #f8f9fa;
    padding: 16px;
    border-radius: 10px;
    border-right: 3px solid #006C35;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #495057;
    margin-bottom: 12px;
}

.progress-bar-modal {
    height: 32px;
    background: #e9ecef;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
}

.progress-fill-modal {
    height: 100%;
    background: linear-gradient(90deg, #006C35 0%, #28a745 100%);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
    transition: width 0.5s ease;
    min-width: 40px;
}

/* ==================== RESPONSIVE ==================== */

@media (max-width: 768px) {
    .modal-backdrop,
    .case-modal-backdrop {
        padding: 10px;
    }
    
    .modal,
    .case-modal {
        margin: 60px auto 20px; /* Reduced top margin for mobile */
        max-height: 90vh;
        border-radius: 16px;
    }
    
    .modal-head,
    .case-modal-header {
        padding: 16px;
        border-radius: 16px 16px 0 0;
    }
    
    .modal-head b,
    .case-modal-header h2 {
        font-size: 18px;
    }
    
    .modal-body,
    .case-modal-body {
        padding: 16px;
    }
    
    .case-modal-footer {
        padding: 16px;
        flex-direction: column;
        border-radius: 0 0 16px 16px;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .medicine-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .ngo-info {
        flex-direction: column;
        text-align: center;
    }
    
    .ngo-logo {
        margin: 0 auto;
    }
}

@media (max-width: 480px) {
    .modal,
    .case-modal {
        margin: 50px auto 10px; /* Further reduced for small screens */
        border-radius: 12px;
    }
    
    .section-title {
        font-size: 14px;
    }
    
    .section-title span {
        font-size: 18px;
    }
}