/**
 * LifeSavers United - Emergency Request System Stylesheet
 * File: css/emergency-request-system.css
 * Dedicated styling for coordinator dashboard and the unified request edit modal.
 * Follows LSU design rules: zero inline styles, crimson accents, high clarity.
 */

/* ==========================================================================
   1. EDIT REQUEST MODAL (OVERLAY & CARD)
   ========================================================================== */
.lsu-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    padding: 16px;
    box-sizing: border-box;
    opacity: 0;
    animation: lsuModalFadeIn 0.2s ease-out forwards;
}

@keyframes lsuModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lsu-modal-card {
    background-color: #ffffff;
    border-radius: 20px;
    max-width: 760px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25), 0 0 0 1px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
    transform: scale(0.97);
    animation: lsuModalScaleUp 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.lsu-edit-form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    overflow: hidden;
    margin: 0;
}

.lsu-modal-alert {
    display: none;
    padding: 12px 16px;
    border-radius: 10px;
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    font-size: 0.875rem;
    font-weight: 600;
}

.lsu-modal-alert.visible {
    display: block;
}

@keyframes lsuModalScaleUp {
    from { transform: scale(0.97); }
    to { transform: scale(1); }
}

/* Modal Header */
.lsu-modal-header {
    padding: 18px 22px;
    background: linear-gradient(135deg, #fef2f2 0%, #fff 100%);
    border-bottom: 1px solid #fee2e2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 12px;
}

.lsu-modal-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

.lsu-modal-header-text {
    flex: 1 1 auto;
    min-width: 0;
}

.lsu-modal-icon-badge {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background-color: #fee2e2;
    color: #dc2626;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lsu-modal-title {
    font-size: 1.1875rem;
    font-weight: 700;
    color: #111827;
    margin: 0;
    line-height: 1.3;
}

.lsu-modal-subtitle {
    font-size: 0.8125rem;
    color: #6b7280;
    margin-top: 3px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.lsu-modal-id-badge {
    background-color: #e5e7eb;
    color: #374151;
    padding: 2px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.72rem;
    font-weight: 600;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

.lsu-modal-close-btn {
    background: transparent;
    border: none;
    color: #6b7280;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.lsu-modal-close-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

/* Modal Scrollable Body */
.lsu-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-sizing: border-box;
}

/* Section Groupings */
.edit-form-section {
    background-color: #fafafa;
    border: 1px solid #f3f4f6;
    border-radius: 14px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.edit-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.edit-section-header span.sec-num {
    background-color: #dc2626;
    color: #ffffff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
}

.edit-section-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
}

/* Grids & Form Controls */
.edit-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
}

@media (min-width: 640px) {
    .edit-grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

.edit-field-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

.edit-field-group label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
}

.edit-field-group label span.req {
    color: #dc2626;
}

.edit-input,
.edit-select,
.edit-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 0.9375rem;
    color: #111827;
    background-color: #ffffff;
    box-sizing: border-box;
    font-family: inherit;
    transition: all 0.15s ease;
}

.edit-input:focus,
.edit-select:focus,
.edit-textarea:focus {
    border-color: #dc2626;
    outline: none;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12);
}

.edit-textarea {
    resize: vertical;
    min-height: 70px;
}

/* ==========================================================================
   2. VISUAL BLOOD GROUP GRID IN EDIT MODAL
   ========================================================================== */
.edit-blood-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

@media (min-width: 640px) {
    .edit-blood-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.edit-blood-item {
    position: relative;
}

.edit-blood-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.edit-blood-item label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 6px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 700;
    color: #374151;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.edit-blood-item label:hover {
    border-color: #fca5a5;
    background-color: #fef2f2;
}

.edit-blood-item input[type="radio"]:checked + label {
    border-color: #dc2626;
    background-color: #fef2f2;
    color: #dc2626;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.15);
}

/* ==========================================================================
   3. VISUAL URGENCY SELECTOR IN EDIT MODAL
   ========================================================================== */
.edit-urgency-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.edit-urgency-item {
    position: relative;
}

.edit-urgency-item input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.edit-urgency-item label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    background-color: #ffffff;
}

.edit-urgency-item.crit label { color: #dc2626; }
.edit-urgency-item.urg label { color: #d97706; }
.edit-urgency-item.norm label { color: #059669; }

.edit-urgency-item.crit input[type="radio"]:checked + label {
    border-color: #dc2626;
    background-color: #fee2e2;
    box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.2);
}

.edit-urgency-item.urg input[type="radio"]:checked + label {
    border-color: #d97706;
    background-color: #fef3c7;
    box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2);
}

.edit-urgency-item.norm input[type="radio"]:checked + label {
    border-color: #059669;
    background-color: #d1fae5;
    box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2);
}

/* ==========================================================================
   4. MULTI-COMPONENT BUILDER STYLES IN EDIT MODAL
   ========================================================================== */
.edit-components-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.edit-component-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background-color: #ffffff;
    padding: 6px 8px;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.edit-component-select-wrap {
    flex: 1 1 auto;
}

.edit-component-select {
    width: 100%;
    height: 42px;
    padding: 8px 12px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1f2937;
    background-color: #f9fafb;
    box-sizing: border-box;
    cursor: pointer;
}

.edit-component-select:focus {
    border-color: #dc2626;
    background-color: #ffffff;
    outline: none;
}

.edit-stepper {
    display: inline-flex;
    align-items: center;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    height: 42px;
    box-sizing: border-box;
    overflow: hidden;
}

.edit-stepper-btn {
    background: #f3f4f6;
    border: none;
    width: 34px;
    height: 40px;
    font-size: 16px;
    font-weight: 700;
    color: #4b5563;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    user-select: none;
}

.edit-stepper-btn:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

.edit-stepper-input {
    width: 36px;
    height: 40px;
    border: none;
    text-align: center;
    font-size: 0.875rem;
    font-weight: 700;
    color: #111827;
    outline: none;
    background: transparent;
    -moz-appearance: textfield;
}

.edit-stepper-input::-webkit-outer-spin-button,
.edit-stepper-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.edit-unit-label {
    padding-right: 10px;
    font-size: 0.8125rem;
    color: #6b7280;
    font-weight: 500;
    user-select: none;
}

.edit-btn-remove-row {
    background: transparent;
    border: none;
    color: #9ca3af;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.edit-btn-remove-row:hover {
    background-color: #fee2e2;
    color: #dc2626;
}

.edit-btn-remove-row.hidden {
    display: none !important;
}

.edit-components-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.edit-btn-add-comp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border: 1.5px dashed #fca5a5;
    color: #dc2626;
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

.edit-btn-add-comp.hidden {
    display: none !important;
}

.edit-btn-add-comp:hover {
    background-color: #fef2f2;
    border-color: #dc2626;
}

.edit-comp-summary-badge {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #059669;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 6px 12px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
}

/* ==========================================================================
   5. AUTOCOMPLETE POPUP ADJUSTMENTS FOR MODAL
   ========================================================================== */
.edit-field-group .hospital-suggestions-dropdown,
.edit-field-group .diagnosis-suggestions-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1.5px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 15px 30px -5px rgba(0, 0, 0, 0.15);
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000005;
    padding: 4px 0;
}

.edit-field-group .hospital-suggestions-dropdown.hidden,
.edit-field-group .diagnosis-suggestions-dropdown.hidden {
    display: none !important;
}

/* Modal Footer Actions */
.lsu-modal-footer {
    padding: 16px 24px;
    background-color: #ffffff;
    border-top: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

.btn-modal-cancel {
    padding: 10px 18px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    color: #374151;
    font-weight: 600;
    font-size: 0.875rem;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-modal-cancel:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.btn-modal-submit {
    padding: 10px 22px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.15s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.25);
}

.btn-modal-submit:hover {
    opacity: 0.95;
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(220, 38, 38, 0.35);
}

.btn-modal-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================================================
   6. MOBILE OPTIMIZATIONS (< 640px)
   ========================================================================== */
@media (max-width: 640px) {
    .lsu-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .lsu-modal-card {
        max-width: 100%;
        width: 100%;
        max-height: 94vh;
        border-radius: 20px 20px 0 0;
        transform: translateY(20px);
        animation: lsuModalSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    }

    .lsu-modal-header {
        padding: 14px 16px;
        gap: 8px;
    }

    .lsu-modal-icon-badge {
        width: 38px;
        height: 38px;
        border-radius: 10px;
    }

    .lsu-modal-icon-badge svg {
        width: 20px;
        height: 20px;
    }

    .lsu-modal-title {
        font-size: 1.0625rem;
    }

    .lsu-modal-subtitle {
        font-size: 0.75rem;
        gap: 4px;
    }

    .lsu-modal-id-badge {
        max-width: 110px;
        font-size: 0.6875rem;
        padding: 1px 6px;
    }

    .lsu-modal-close-btn {
        width: 36px;
        height: 36px;
    }

    .lsu-modal-body {
        padding: 14px 14px 20px;
        gap: 14px;
        -webkit-overflow-scrolling: touch;
    }

    .edit-form-section {
        padding: 14px 12px;
        border-radius: 12px;
        gap: 12px;
    }

    .edit-section-header {
        margin-bottom: 0;
    }

    .edit-section-title {
        font-size: 0.8125rem;
    }

    /* Force 16px font-size on all mobile inputs to completely prevent iOS Safari auto-zoom */
    .edit-input,
    .edit-select,
    .edit-textarea,
    .edit-component-select {
        font-size: 16px !important;
        padding: 10px 12px;
        border-radius: 8px;
    }

    .edit-textarea {
        min-height: 64px;
    }

    /* Component Builder 2-Line Responsive Layout */
    .edit-component-row {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px;
    }

    .edit-component-select-wrap {
        flex: 1 1 100%;
        width: 100%;
    }

    .edit-component-select {
        height: 44px;
        width: 100%;
    }

    .edit-stepper {
        flex: 1 1 auto;
        height: 42px;
    }

    .edit-stepper-btn {
        width: 38px;
        height: 40px;
    }

    .edit-stepper-input {
        width: 40px;
        font-size: 16px !important;
    }

    .edit-btn-remove-row {
        flex: 0 0 auto;
        width: 42px;
        height: 42px;
    }

    /* Mobile Urgency Grid */
    .edit-urgency-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .edit-urgency-item label {
        padding: 9px 4px;
        font-size: 0.775rem;
        gap: 4px;
    }

    /* Mobile Blood Group Grid (3 cols with good touch target) */
    .edit-blood-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
    }

    .edit-blood-item label {
        padding: 9px 4px;
        font-size: 0.875rem;
    }

    /* Autocomplete dropdown positioning on mobile */
    .edit-field-group .hospital-suggestions-dropdown,
    .edit-field-group .diagnosis-suggestions-dropdown {
        max-height: 200px;
        box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
    }

    /* Footer sticky actions on mobile */
    .lsu-modal-footer {
        padding: 12px 16px;
        gap: 10px;
        background-color: #ffffff;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.05);
    }

    .btn-modal-cancel,
    .btn-modal-submit {
        flex: 1 1 50%;
        justify-content: center;
        padding: 12px 14px;
        font-size: 0.9375rem;
    }
}

@keyframes lsuModalSlideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
