/* Mobile-First Styles for App-like Experience */

@media (max-width: 768px) {
    .msp-container {
        padding: 0;
    }

    .msp-dashboard {
        border-radius: 0;
        min-height: 100vh;
    }

    .msp-header {
        position: sticky;
        top: 0;
        z-index: 100;
        border-radius: 0;
    }

    .msp-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .msp-button {
        width: 100%;
        padding: 16px;
        font-size: 18px;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    .msp-form-input,
    .msp-form-textarea,
    .msp-form-select {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 14px;
    }

    /* Bottom Navigation */
    .msp-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--msp-primary);
        display: flex;
        justify-content: space-around;
        padding: 10px 0;
        box-shadow: 0 -2px 10px var(--msp-shadow);
        z-index: 1000;
    }

    .msp-nav-item {
        flex: 1;
        text-align: center;
        color: var(--msp-white);
        text-decoration: none;
        padding: 10px;
    }

    .msp-nav-item.active {
        background: var(--msp-primary-dark);
    }

    /* Swipe gestures */
    .msp-swipeable {
        touch-action: pan-y;
    }

    /* Large touch targets */
    .msp-touch-target {
        min-height: 48px;
        min-width: 48px;
    }

    .msp-card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .msp-card-date {
        margin-top: 5px;
    }

    /* Larger touch targets for checkboxes/radios on mobile */
    .msp-record-checkbox,
    .msp-record-item input[type="checkbox"] {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
    }

    .msp-record-checkbox:checked::after,
    .msp-record-item input[type="checkbox"]:checked::after {
        left: 7px;
        top: 3px;
        width: 7px;
        height: 13px;
    }

    .msp-share-option input[type="radio"] {
        width: 26px;
        height: 26px;
        min-width: 26px;
        min-height: 26px;
    }

    .msp-share-option input[type="radio"]:checked::after {
        width: 14px;
        height: 14px;
    }

    .msp-share-options {
        grid-template-columns: 1fr;
    }

    /* Filters stack on mobile */
    .msp-filter-row {
        flex-direction: column;
        gap: 10px;
    }

    .msp-filter-field {
        min-width: 100%;
    }

    /* Medication form rows stack on mobile */
    .msp-med-fields {
        grid-template-columns: 1fr;
    }

    .msp-med-ongoing-label {
        padding-top: 0;
    }

    .msp-med-remove {
        padding-top: 0;
    }

    /* Medication table scrolls horizontally */
    .msp-medications-table {
        font-size: 13px;
    }

    .msp-medications-table th,
    .msp-medications-table td {
        padding: 8px;
        white-space: nowrap;
    }

    /* Ensure table wrapper scrolls on mobile */
    .msp-medications-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 10px -20px;
        padding: 0 20px;
    }

    /* Prescription images must stay within viewport */
    .msp-prescription-image {
        max-width: 100% !important;
        width: auto;
        height: auto;
    }

    /* Prevent any child from breaking out of the card */
    .msp-card img {
        max-width: 100%;
        height: auto;
    }

    /* Dashboard padding reduction on mobile */
    .msp-dashboard {
        padding: 15px;
    }

    /* Inline meds wrap */
    .msp-medications-inline {
        flex-direction: column;
    }

    /* Share URL box stacks on mobile */
    .msp-share-url-row {
        flex-direction: column;
    }

    .msp-copy-btn {
        width: 100%;
    }

    /* Share action buttons stack on mobile */
    .msp-share-actions {
        flex-direction: column;
    }

    .msp-share-action-btn {
        width: 100%;
        padding: 14px 20px;
        font-size: 16px;
    }

    /* Medication share block on mobile */
    .msp-meds-share-title-label {
        font-size: 15px;
        flex-wrap: wrap;
    }

    .msp-med-share-details {
        font-size: 12px;
    }

    /* Autocomplete dropdown on mobile */
    .msp-autocomplete-dropdown {
        max-height: 180px;
    }

    .msp-autocomplete-item {
        padding: 12px;
        font-size: 15px;
    }

    /* Registration form grid stacks on mobile */
    #msp-register-form [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Auth gate on mobile */
    .msp-auth-actions {
        flex-direction: column;
        align-items: center;
    }

    .msp-auth-actions .msp-button {
        width: 100%;
        max-width: 280px;
    }
}

/* PWA Splash Screen */
@media screen and (display-mode: standalone) {
    body {
        padding-bottom: 60px; /* Space for bottom nav */
    }
}
