/**
 * ENNU Mobile Chart Styles
 * Mobile-first, touch-optimized patient chart
 * Supports iOS and Android with 44x44px minimum touch targets
 */

/* ========================================
   MOBILE CHART WRAPPER
   ======================================== */

.ennu-mobile-chart-wrapper {
    max-width: 100%;
    margin: 0 auto;
    background: #F9FAFB;
    min-height: 100vh;
    padding-bottom: 80px; /* Space for floating action buttons */
    position: relative;
}

/* Error Messages */
.ennu-mobile-error {
    padding: 20px;
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 8px;
    text-align: center;
    margin: 20px;
}

/* ========================================
   PATIENT HEADER (STICKY)
   ======================================== */

.ennu-mobile-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, #7C3AED 0%, #5B21B6 100%);
    color: white;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.patient-photo {
    flex-shrink: 0;
}

.patient-photo img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid rgba(255,255,255,0.3);
}

.patient-info {
    flex: 1;
    min-width: 0;
}

.patient-name {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.patient-meta {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.patient-meta .meta-separator {
    opacity: 0.5;
}

.mobile-menu-toggle {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(255,255,255,0.15);
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mobile-menu-toggle:active {
    background: rgba(255,255,255,0.25);
}

/* ========================================
   ALLERGY BANNER
   ======================================== */

.ennu-allergy-banner {
    background: #FEE2E2;
    border-left: 4px solid #DC2626;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.allergy-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.allergy-text {
    flex: 1;
    font-size: 14px;
    color: #991B1B;
    line-height: 1.4;
}

.view-allergies-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    background: #DC2626;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    min-height: 44px;
    white-space: nowrap;
}

.view-allergies-btn:active {
    background: #B91C1C;
}

/* ========================================
   SWIPEABLE TABS NAVIGATION
   ======================================== */

.ennu-mobile-tabs-nav {
    background: white;
    border-bottom: 1px solid #E5E7EB;
    position: sticky;
    top: 84px; /* Below patient header */
    z-index: 99;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.mobile-tabs-swiper {
    padding: 8px 0;
}

.mobile-tabs-swiper .swiper-slide {
    width: auto;
}

.mobile-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    min-width: 80px;
    min-height: 60px;
    transition: all 0.2s;
    border-bottom: 3px solid transparent;
}

.mobile-tab-btn .tab-icon {
    font-size: 24px;
}

.mobile-tab-btn .tab-label {
    font-size: 12px;
    font-weight: 500;
    color: #6B7280;
}

.mobile-tab-btn.active {
    border-bottom-color: #7C3AED;
}

.mobile-tab-btn.active .tab-label {
    color: #7C3AED;
    font-weight: 600;
}

/* ========================================
   SWIPEABLE CONTENT SECTIONS
   ======================================== */

.mobile-content-swiper {
    margin-top: 16px;
    padding: 0 16px;
}

.mobile-section {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 16px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid #F3F4F6;
}

.section-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1F2937;
}

.refresh-btn,
.add-btn {
    width: 44px;
    height: 44px;
    border: 2px solid #E5E7EB;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.refresh-btn:active,
.add-btn:active {
    background: #F3F4F6;
    transform: scale(0.95);
}

.add-btn {
    border-color: #7C3AED;
    color: #7C3AED;
}

/* No Data State */
.no-data {
    text-align: center;
    padding: 40px 20px;
    color: #9CA3AF;
    font-size: 14px;
}

/* ========================================
   VITALS GRID
   ======================================== */

.vitals-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.vital-card {
    background: linear-gradient(135deg, #F9FAFB 0%, #F3F4F6 100%);
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.vital-card.full-width {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    border-color: #C7D2FE;
}

.vital-icon {
    font-size: 28px;
    margin-bottom: 4px;
}

.vital-data {
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.vital-value {
    font-size: 24px;
    font-weight: 700;
    color: #1F2937;
}

.vital-unit {
    font-size: 14px;
    color: #6B7280;
    font-weight: 500;
}

.vital-label {
    font-size: 12px;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* ========================================
   MOBILE CARDS (Problems, Meds, etc.)
   ======================================== */

.mobile-card {
    background: white;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    position: relative;
    transition: all 0.2s;
}

.mobile-card:active {
    transform: scale(0.98);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.card-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Severity Badges */
.severity-critical .card-badge,
.allergy-card.severity-critical {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #DC2626;
}

.severity-high .card-badge,
.allergy-card.severity-high {
    background: #FED7AA;
    color: #9A3412;
    border: 1px solid #EA580C;
}

.severity-moderate .card-badge,
.allergy-card.severity-moderate {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #F59E0B;
}

.severity-low .card-badge {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #10B981;
}

/* Problem Card */
.problem-title {
    margin: 0 0 8px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1F2937;
    padding-right: 80px; /* Space for badge */
}

.problem-meta {
    font-size: 13px;
    color: #6B7280;
    margin-bottom: 8px;
}

.problem-notes {
    font-size: 13px;
    color: #4B5563;
    margin: 8px 0 0 0;
    line-height: 1.5;
}

/* Medication Card */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 10px;
}

.med-name {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1F2937;
    flex: 1;
}

.med-status {
    padding: 4px 10px;
    background: #D1FAE5;
    color: #065F46;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    flex-shrink: 0;
}

.med-dosage {
    margin-bottom: 12px;
}

.dosage-value {
    font-size: 18px;
    font-weight: 700;
    color: #7C3AED;
}

.med-details {
    max-height: 200px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
}

.med-details.collapsed {
    max-height: 0;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid #F3F4F6;
    font-size: 13px;
}

.detail-label {
    color: #6B7280;
    font-weight: 500;
}

.detail-value {
    color: #1F2937;
    font-weight: 600;
    text-align: right;
}

/* Expand Button */
.expand-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.expand-btn .dashicons {
    font-size: 20px;
    color: #9CA3AF;
}

.expand-btn.expanded .dashicons {
    transform: rotate(180deg);
}

/* Allergy Card */
.allergy-card {
    border-left-width: 4px;
}

.allergy-name {
    margin: 0 0 8px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1F2937;
}

.allergy-reaction {
    font-size: 13px;
    color: #4B5563;
    margin-bottom: 8px;
}

.allergy-notes {
    font-size: 13px;
    color: #6B7280;
    margin: 0;
    line-height: 1.5;
}

/* Note Card */
.note-card {
    padding-bottom: 50px; /* Space for expand button */
}

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

.note-date {
    font-size: 12px;
    font-weight: 600;
    color: #7C3AED;
}

.note-author {
    font-size: 12px;
    color: #6B7280;
}

.note-preview {
    font-size: 13px;
    color: #4B5563;
    line-height: 1.5;
}

.note-full {
    max-height: 400px;
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    margin-top: 12px;
}

.note-full.collapsed {
    max-height: 0;
}

.soap-section {
    padding: 8px 0;
    border-top: 1px solid #F3F4F6;
    font-size: 13px;
    line-height: 1.6;
}

.soap-section:first-child {
    border-top: none;
}

.soap-section strong {
    color: #7C3AED;
    font-weight: 700;
    margin-right: 6px;
}

/* Lab Cards */
.lab-group-card {
    padding: 12px;
}

.lab-date-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 2px solid #F3F4F6;
}

.lab-icon {
    font-size: 20px;
}

.lab-count {
    font-size: 12px;
    color: #6B7280;
    margin-left: auto;
}

.lab-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.lab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #F9FAFB;
    border-radius: 8px;
    border-left: 3px solid #10B981;
}

.lab-item.abnormal {
    background: #FEF3C7;
    border-left-color: #F59E0B;
}

.lab-status-icon {
    font-size: 18px;
    flex-shrink: 0;
}

.lab-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lab-name {
    font-size: 13px;
    font-weight: 500;
    color: #1F2937;
}

.lab-value {
    font-size: 14px;
    font-weight: 700;
    color: #1F2937;
    display: flex;
    align-items: baseline;
    gap: 4px;
}

.lab-unit {
    font-size: 11px;
    color: #6B7280;
    font-weight: 500;
}

/* ========================================
   QUICK ACTION BUTTONS (FLOATING)
   ======================================== */

.ennu-mobile-quick-actions {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #E5E7EB;
    padding: 12px 16px;
    display: flex;
    justify-content: space-around;
    gap: 8px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
}

.quick-action-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
    background: white;
    border: 2px solid #E5E7EB;
    border-radius: 12px;
    cursor: pointer;
    min-height: 60px;
    min-width: 60px;
    transition: all 0.2s;
}

.quick-action-btn:active {
    transform: scale(0.95);
    background: #F9FAFB;
}

.quick-action-btn .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #6B7280;
}

.quick-action-btn .btn-label {
    font-size: 11px;
    font-weight: 600;
    color: #6B7280;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Button Color Variants */
.prescribe-btn {
    border-color: #7C3AED;
}

.prescribe-btn .dashicons,
.prescribe-btn .btn-label {
    color: #7C3AED;
}

.labs-btn {
    border-color: #3B82F6;
}

.labs-btn .dashicons,
.labs-btn .btn-label {
    color: #3B82F6;
}

.note-btn {
    border-color: #10B981;
}

.note-btn .dashicons,
.note-btn .btn-label {
    color: #10B981;
}

.more-btn {
    border-color: #6B7280;
}

/* ========================================
   LOADING OVERLAY
   ======================================== */

.mobile-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

/* Tablets (768px+) */
@media (min-width: 768px) {
    .ennu-mobile-chart-wrapper {
        max-width: 600px;
        border-left: 1px solid #E5E7EB;
        border-right: 1px solid #E5E7EB;
    }

    .patient-name {
        font-size: 20px;
    }

    .vitals-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .vital-card.full-width {
        grid-column: 1 / -1;
    }
}

/* Desktop (1024px+) - Full Chart Display */
@media (min-width: 1024px) {
    .ennu-mobile-chart-wrapper {
        max-width: 800px;
        padding-bottom: 20px;
    }

    .ennu-mobile-quick-actions {
        position: relative;
        margin-top: 20px;
        border-top: none;
        border: 1px solid #E5E7EB;
        border-radius: 12px;
    }

    .quick-action-btn {
        min-height: 80px;
    }

    .quick-action-btn .btn-label {
        font-size: 13px;
    }

    .mobile-content-swiper {
        padding: 0 24px;
    }
}

/* iOS Safe Area (for iPhone X+ with notch) */
@supports (padding: max(0px)) {
    .ennu-mobile-header {
        padding-top: max(12px, env(safe-area-inset-top));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }

    .ennu-mobile-quick-actions {
        padding-bottom: max(12px, env(safe-area-inset-bottom));
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    .ennu-mobile-chart-wrapper {
        background: #111827;
    }

    .mobile-section,
    .mobile-card {
        background: #1F2937;
        border-color: #374151;
    }

    .patient-name,
    .med-name,
    .problem-title,
    .allergy-name,
    .vital-value {
        color: #F9FAFB;
    }

    .patient-meta,
    .detail-label,
    .lab-name {
        color: #D1D5DB;
    }
}
