/**
 * Mobile UX Enhancements - WhenBRRR V12
 * Fixes for mobile navigation, FAB, alerts, and responsive layout
 */

/* ===================================
   Global Alert Bar
   =================================== */

.global-alert {
    position: fixed;
    top: var(--header-height, 70px);
    left: 0;
    right: 0;
    z-index: 1050;
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
    border-radius: 0 0 12px 12px;
    animation: slideDown 0.3s ease;
}

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

.global-alert-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.global-alert-icon {
    font-size: 20px;
}

.global-alert-message {
    font-weight: 500;
    font-size: 14px;
}

.alert-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: grid;
    place-items: center;
    font-size: 20px;
    line-height: 1;
    transition: all 0.2s ease;
}

.alert-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* ===================================
   Floating Action Button (FAB)
   =================================== */

.hs-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    display: grid;
    place-items: center;
    z-index: 1040;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.hs-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.hs-fab:active {
    transform: scale(0.95);
}

.hs-fab svg {
    transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.hs-fab.is-expanded svg {
    transform: rotate(45deg);
}

/* FAB Actions Menu */
.hs-fab-actions {
    position: fixed;
    bottom: 92px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1039;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.hs-fab-actions.is-expanded {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.hs-fab-action {
    display: flex;
    align-items: center;
    gap: 12px;
    background: white;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 12px 16px;
    border-radius: 28px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    transition: all 0.2s ease;
    transform: scale(0.8);
    opacity: 0;
}

.hs-fab-actions.is-expanded .hs-fab-action {
    transform: scale(1);
    opacity: 1;
}

.hs-fab-action:nth-child(1) { transition-delay: 0ms; }
.hs-fab-action:nth-child(2) { transition-delay: 50ms; }
.hs-fab-action:nth-child(3) { transition-delay: 100ms; }

.hs-fab-action:hover {
    background: var(--color-surface-alt);
    transform: translateX(-4px) scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.hs-fab-action-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.hs-fab-action-label {
    font-size: 14px;
    font-weight: 500;
}

[data-theme="dark"] .hs-fab-action {
    background: var(--color-surface);
    border-color: var(--color-border);
}

[data-theme="dark"] .hs-fab-action:hover {
    background: var(--color-surface-alt);
}

/* ===================================
   Mobile Navigation Improvements
   =================================== */

/* Prevent body scroll when nav is open */
body.is-nav-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Hamburger Menu */
.hamburger {
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    z-index: 1110;
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Hamburger animation */
.hamburger.is-active span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger.is-active span:nth-child(2) {
    opacity: 0;
    transform: scaleX(0);
}

.hamburger.is-active span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Sidebar close button */
.sidebar__close {
    display: none;
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar__close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar__close svg {
    color: white;
}

/* Mobile overlay */
.app-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1090;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.app-overlay.is-active {
    opacity: 1;
    visibility: visible;
}

/* ===================================
   Responsive Layout Improvements
   =================================== */

/* Wider content on mobile */
@media (max-width: 768px) {
    .app-content {
        padding: 16px 12px !important;
        max-width: 100% !important;
    }
    
    .container {
        width: 100% !important;
        max-width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }
    
    .page-stack {
        gap: 16px !important;
    }
    
    /* Show hamburger and hide desktop sidebar */
    .hamburger {
        display: flex;
    }
    
    .sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    }
    
    .sidebar.is-open {
        transform: translateX(0);
    }
    
    .sidebar__close {
        display: flex;
    }
    
    .app-header {
        padding-left: 68px !important; /* Make room for hamburger */
    }
    
    /* Adjust FAB position to avoid bottom nav */
    .hs-fab {
        bottom: 84px;
    }
    
    .hs-fab-actions {
        bottom: 152px;
    }
}

/* ===================================
   Visual Hierarchy Improvements
   =================================== */

/* Enhanced headings */
h1, .page-heading__title {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}

h2 {
    font-size: 18px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
    margin-top: 24px;
    margin-bottom: 12px;
}

h3 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--color-text);
}

/* Enhanced cards */
.card, .metric-card, .kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.card:hover, .metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* Card grid */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Enhanced spacing */
.section-spacing {
    margin-top: 24px;
    margin-bottom: 24px;
}

/* ===================================
   Theme Toggle Positioning
   =================================== */

.theme-toggle {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--color-text);
}

.theme-toggle:hover {
    background: var(--color-surface-alt);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* ===================================
   Button Improvements
   =================================== */

button, .btn {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

button:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Keyboard accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===================================
   Tablet Adjustments
   =================================== */

@media (min-width: 769px) and (max-width: 1023px) {
    .app-content {
        padding: 20px 24px;
    }
    
    h1, .page-heading__title {
        font-size: 24px;
    }
    
    h2 {
        font-size: 20px;
    }
}
