/* ============================================
   redPoint Native App Experience CSS
   Inspired by Cal.ai mobile design
   ============================================ */

/* ── Safe Area & Base ── */
html {
    /* Extend background under status bar */
    background-color: #f5f5f7;
}

body {
    /* Safe Area Insets for iOS Notch & Home Indicator */
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);

    /* Disable text selection to mimic native apps */
    -webkit-user-select: none;
    user-select: none;

    /* Smooth scrolling */
    -webkit-overflow-scrolling: touch;

    /* Remove tap highlight color on mobile */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;

    background-color: #f5f5f7;
}

/* Re-enable text selection for input fields */
input, textarea, select {
    -webkit-user-select: auto !important;
    user-select: auto !important;
}

/* Disable drag on images */
img {
    -webkit-user-drag: none;
    user-drag: none;
}

/* Interactive feel */
a, button, .btn, .card[onclick] {
    cursor: pointer;
    touch-action: manipulation;
}

/* Prevent double-tap zoom */
* {
    touch-action: manipulation;
}

/* ── Mobile App Top Bar (Cal.ai style) ── */
.mobile-topbar {
    background: #ffffff;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: 1rem;
    padding-right: 1rem;
    padding-bottom: 0;
    position: sticky;
    top: 0;
    z-index: 1030;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}

.mobile-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

/* App brand: icon + name */
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.mobile-brand-icon {
    width: 34px;
    height: 34px;
    background: #dc3545;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-brand-icon img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.mobile-brand-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1a1a1a;
    letter-spacing: -0.3px;
}

/* Action buttons on right */
.mobile-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mobile-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #f5f5f7;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1a1a1a;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s;
    text-decoration: none;
}

.mobile-action-btn:hover, .mobile-action-btn:active {
    background: #e9ecef;
    color: #dc3545;
}

/* ── Mobile Bottom Tab Bar (Cal.ai style) ── */
.mobile-bottom-nav {
    display: none; /* hidden on desktop */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    background: #ffffff;
    border-top: 1px solid rgba(0,0,0,0.07);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}

.mobile-bottom-nav-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    padding: 8px 0 6px;
    position: relative;
}

.mobile-tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #9ca3af;
    font-size: 0.65rem;
    font-weight: 500;
    padding: 4px 0;
    transition: color 0.15s;
    background: none;
    border: none;
    cursor: pointer;
    min-height: 44px;
}

.mobile-tab-item i {
    font-size: 1.3rem;
    line-height: 1;
}

.mobile-tab-item.active {
    color: #dc3545;
}

/* Center FAB */
.mobile-tab-fab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    padding-bottom: 2px;
}

.mobile-fab-btn {
    width: 56px;
    height: 56px;
    background: #dc3545;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.4);
    cursor: pointer;
    transform: translateY(-12px); /* Float above the bar */
    transition: transform 0.15s, box-shadow 0.15s;
    text-decoration: none;
}

.mobile-fab-btn:active {
    transform: translateY(-10px) scale(0.96);
    box-shadow: 0 3px 12px rgba(220, 53, 69, 0.4);
}

/* Show bottom nav only on mobile */
@media (max-width: 767px) {
    .mobile-bottom-nav {
        display: block;
    }
    
    /* Push content above bottom nav */
    body {
        padding-bottom: calc(70px + env(safe-area-inset-bottom, 0px));
    }
    
    /* Show topbar only on mobile */
    .mobile-topbar {
        display: block !important;
    }
}

@media (min-width: 768px) {
    .mobile-topbar {
        display: none !important;
    }
    .mobile-bottom-nav {
        display: none !important;
    }
    body {
        padding-bottom: 0;
        background-color: #f8f9fa;
    }
}

/* ── Dark Mode ── */
[data-bs-theme="dark"] .mobile-topbar,
[data-bs-theme="dark"] .mobile-bottom-nav {
    background: #0f172a;
    border-color: rgba(255,255,255,0.06);
}

[data-bs-theme="dark"] .mobile-brand-name {
    color: #f1f5f9;
}

[data-bs-theme="dark"] .mobile-action-btn {
    background: #1e293b;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .mobile-tab-item {
    color: #475569;
}

[data-bs-theme="dark"] .mobile-tab-item.active {
    color: #dc3545;
}

[data-bs-theme="dark"] body {
    background-color: #0f172a;
}

/* ── Mobile Content Wrapper ── */
.mobile-content {
    padding: 1rem;
}

/* ── Mobile Stat Cards (Cal.ai style — clean white) ── */
@media (max-width: 767px) {
    .stat-card-mobile {
        background: #ffffff;
        border-radius: 16px;
        padding: 1rem 1.2rem;
        border: none;
        box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    }

    .stat-card-mobile .stat-label {
        font-size: 0.7rem;
        font-weight: 600;
        color: #9ca3af;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 4px;
    }

    .stat-card-mobile .stat-value {
        font-size: 1.8rem;
        font-weight: 700;
        color: #1a1a1a;
        line-height: 1;
    }

    .stat-card-mobile .stat-icon {
        width: 36px;
        width: 36px;
        height: 36px;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 1.1rem;
    }
}

/* ── Safe Area for Fullscreen Modals on Mobile (iOS Notch & Home Bar) ── */
@media (max-width: 767.98px) {
    .modal-fullscreen-sm-down .modal-header,
    .modal-fullscreen-md-down .modal-header {
        padding-top: calc(1rem + env(safe-area-inset-top, 0px)) !important;
    }
    
    .modal-fullscreen-sm-down .modal-footer,
    .modal-fullscreen-md-down .modal-footer {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Fallback if a modal has no footer */
    .modal-fullscreen-sm-down .modal-body:last-child,
    .modal-fullscreen-md-down .modal-body:last-child {
        padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)) !important;
    }
}
