/* ==========================================================================
   ATX Solutions - Mobile Alert and Toast Styles
   Toast notifications and alert positioning for mobile devices
   ========================================================================== */

/* ==========================================================================
   Alert Component Optimizations
   ========================================================================== */

@media (max-width: 767px) {
    /* Base alert styling */
    .alert {
        border-radius: var(--mobile-radius-md);
        padding: var(--mobile-space-md);
        margin-bottom: var(--mobile-space-md);
        font-size: var(--mobile-font-base);
        line-height: var(--mobile-line-height-base);
    }
    
    /* Alert with icon */
    .alert i,
    .alert svg {
        margin-right: var(--mobile-space-sm);
        flex-shrink: 0;
    }
    
    /* Dismissible alert close button */
    .alert-dismissible {
        padding-right: calc(var(--mobile-space-md) + var(--mobile-touch-target-min));
    }
    
    .alert-dismissible .btn-close {
        min-width: var(--mobile-touch-target-min);
        min-height: var(--mobile-touch-target-min);
        padding: var(--mobile-touch-padding);
        position: absolute;
        right: 0;
        top: 50%;
        transform: translateY(-50%);
    }
    
    /* Alert headings */
    .alert-heading {
        font-size: var(--mobile-font-lg);
        margin-bottom: var(--mobile-space-sm);
    }
    
    /* Alert link */
    .alert-link {
        text-decoration: underline;
        font-weight: 600;
    }
}

/* ==========================================================================
   Toast Container and Positioning
   ========================================================================== */

@media (max-width: 767px) {
    /* Toast container positioning */
    .toast-container {
        position: fixed;
        z-index: var(--mobile-z-toast);
        padding: var(--mobile-space-md);
        width: 100%;
        max-width: calc(100vw - calc(var(--mobile-space-md) * 2));
        pointer-events: none;
    }
    
    /* Toast container positions with safe area support */
    .toast-container.top-0 {
        top: 0;
        padding-top: max(var(--mobile-space-md), var(--mobile-safe-area-top));
    }
    
    .toast-container.top-50 {
        top: 50%;
        transform: translateY(-50%);
    }
    
    .toast-container.bottom-0 {
        bottom: 0;
        padding-bottom: max(var(--mobile-space-md), var(--mobile-safe-area-bottom));
    }
    
    /* Horizontal positioning */
    .toast-container.start-0 {
        left: 0;
        padding-left: max(var(--mobile-space-md), var(--mobile-safe-area-left));
    }
    
    .toast-container.end-0 {
        right: 0;
        padding-right: max(var(--mobile-space-md), var(--mobile-safe-area-right));
    }
    
    .toast-container.start-50 {
        left: 50%;
        transform: translateX(-50%);
    }
    
    /* Combined transforms for center positioning */
    .toast-container.top-50.start-50 {
        transform: translate(-50%, -50%);
    }
}

/* ==========================================================================
   Toast Component
   ========================================================================== */

@media (max-width: 767px) {
    /* Base toast styling */
    .toast {
        width: 100%;
        max-width: 100%;
        border-radius: var(--mobile-radius-md);
        box-shadow: var(--mobile-shadow-lg);
        margin-bottom: var(--mobile-space-sm);
        pointer-events: auto;
        font-size: var(--mobile-font-base);
    }
    
    /* Toast header */
    .toast-header {
        padding: var(--mobile-space-md);
        border-top-left-radius: var(--mobile-radius-md);
        border-top-right-radius: var(--mobile-radius-md);
        min-height: var(--mobile-touch-target-comfortable);
        display: flex;
        align-items: center;
    }
    
    /* Toast body */
    .toast-body {
        padding: var(--mobile-space-md);
        line-height: var(--mobile-line-height-base);
    }
    
    /* Toast close button */
    .toast .btn-close {
        min-width: var(--mobile-touch-target-min);
        min-height: var(--mobile-touch-target-min);
        padding: var(--mobile-touch-padding-sm);
        margin-left: var(--mobile-space-sm);
        flex-shrink: 0;
    }
    
    /* Toast icon */
    .toast-header i,
    .toast-header svg,
    .toast-body i,
    .toast-body svg {
        margin-right: var(--mobile-space-sm);
        flex-shrink: 0;
    }
    
    /* Toast without header (body only) */
    .toast:not(.toast-header) .toast-body {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding-right: calc(var(--mobile-space-md) + var(--mobile-touch-target-min) + var(--mobile-space-sm));
    }
}

/* ==========================================================================
   Custom Alert Variants for Mobile
   ========================================================================== */

@media (max-width: 767px) {
    /* Alert with action button */
    .alert-with-action {
        display: flex;
        flex-direction: column;
        gap: var(--mobile-space-md);
    }
    
    .alert-with-action .alert-actions {
        display: flex;
        gap: var(--mobile-space-sm);
        flex-wrap: wrap;
    }
    
    .alert-with-action .btn {
        min-height: var(--mobile-touch-target-min);
        flex: 1;
        min-width: 100px;
    }
    
    /* Alert with progress bar */
    .alert .progress {
        margin-top: var(--mobile-space-sm);
        height: 8px;
        border-radius: var(--mobile-radius-full);
    }
    
    /* Compact alert (less padding) */
    .alert-compact {
        padding: var(--mobile-space-sm) var(--mobile-space-md);
        font-size: var(--mobile-font-sm);
    }
    
    /* Full-width alert (edge-to-edge) */
    .alert-full-width {
        border-radius: 0;
        margin-left: calc(-1 * var(--mobile-space-md));
        margin-right: calc(-1 * var(--mobile-space-md));
        width: calc(100% + calc(var(--mobile-space-md) * 2));
    }
}

/* ==========================================================================
   Alert Stack (Multiple Alerts)
   ========================================================================== */

@media (max-width: 767px) {
    /* Alert container for stacking */
    .alert-stack {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: var(--mobile-z-toast);
        padding: var(--mobile-space-md);
        padding-top: max(var(--mobile-space-md), var(--mobile-safe-area-top));
        pointer-events: none;
    }
    
    .alert-stack .alert {
        pointer-events: auto;
        margin-bottom: var(--mobile-space-sm);
        animation: slideInDown var(--mobile-transition-base) ease-out;
    }
    
    /* Slide in animation */
    @keyframes slideInDown {
        from {
            transform: translateY(-100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }
    
    /* Slide out animation */
    .alert-stack .alert.removing {
        animation: slideOutUp var(--mobile-transition-base) ease-in forwards;
    }
    
    @keyframes slideOutUp {
        from {
            transform: translateY(0);
            opacity: 1;
        }
        to {
            transform: translateY(-100%);
            opacity: 0;
        }
    }
}

/* ==========================================================================
   Bottom Sheet Alert (Sheet that slides from bottom)
   ========================================================================== */

@media (max-width: 767px) {
    .alert-bottom-sheet {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top-left-radius: var(--mobile-radius-lg);
        border-top-right-radius: var(--mobile-radius-lg);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        padding: var(--mobile-space-lg);
        padding-bottom: max(var(--mobile-space-lg), var(--mobile-safe-area-bottom));
        transform: translateY(100%);
        transition: transform var(--mobile-transition-base) ease-out;
        z-index: var(--mobile-z-modal);
    }
    
    .alert-bottom-sheet.show {
        transform: translateY(0);
    }
    
    /* Bottom sheet handle */
    .alert-bottom-sheet::before {
        content: '';
        position: absolute;
        top: var(--mobile-space-sm);
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #dee2e6;
        border-radius: var(--mobile-radius-full);
    }
    
    /* Bottom sheet content */
    .alert-bottom-sheet-content {
        margin-top: var(--mobile-space-md);
    }
    
    /* Bottom sheet actions */
    .alert-bottom-sheet-actions {
        display: flex;
        gap: var(--mobile-space-sm);
        margin-top: var(--mobile-space-lg);
    }
    
    .alert-bottom-sheet-actions .btn {
        flex: 1;
        min-height: var(--mobile-touch-target-comfortable);
    }
}

/* ==========================================================================
   Alert Backdrop (for bottom sheet)
   ========================================================================== */

@media (max-width: 767px) {
    .alert-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--mobile-z-modal) - 1);
        opacity: 0;
        transition: opacity var(--mobile-transition-base) ease;
        pointer-events: none;
    }
    
    .alert-backdrop.show {
        opacity: 1;
        pointer-events: auto;
    }
}

/* ==========================================================================
   Success/Error/Warning/Info Alert Icons
   ========================================================================== */

@media (max-width: 767px) {
    /* Add icon spacing for Bootstrap alert icons */
    .alert-success::before,
    .alert-danger::before,
    .alert-warning::before,
    .alert-info::before {
        font-family: 'bootstrap-icons';
        font-size: 20px;
        margin-right: var(--mobile-space-sm);
        flex-shrink: 0;
    }
    
    /* Optional: Add icons via pseudo-elements */
    .alert.alert-with-icon {
        display: flex;
        align-items: flex-start;
    }
}

/* ==========================================================================
   Loading Alert / Spinner Alert
   ========================================================================== */

@media (max-width: 767px) {
    .alert-loading {
        display: flex;
        align-items: center;
        gap: var(--mobile-space-md);
    }
    
    .alert-loading .spinner-border,
    .alert-loading .spinner-grow {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
    }
    
    .alert-loading-text {
        flex: 1;
    }
}

/* ==========================================================================
   Alert with Virtual Keyboard Offset
   ========================================================================== */

@media (max-width: 767px) {
    /* When virtual keyboard is open, move alerts up */
    .keyboard-open .alert-stack,
    .keyboard-open .toast-container.bottom-0 {
        bottom: 300px; /* Approximate keyboard height */
        transition: bottom var(--mobile-transition-base) ease;
    }
}

/* ==========================================================================
   Swipe to Dismiss (Optional Enhancement)
   ========================================================================== */

@media (max-width: 767px) {
    .alert-dismissible.swipeable,
    .toast.swipeable {
        touch-action: pan-y;
        position: relative;
        transition: transform var(--mobile-transition-fast) ease;
    }
    
    .alert-dismissible.swipeable.swiping,
    .toast.swipeable.swiping {
        transition: none;
    }
    
    .alert-dismissible.swipeable.dismissed,
    .toast.swipeable.dismissed {
        transform: translateX(110%);
        opacity: 0;
    }
}
