/**
 * Home - Styles mobile (smartphone)
 * Breakpoint: 768px
 * - Sidebar en drawer (hamburger)
 * - Cartes optimisées touch (min 44px)
 */

/* ========== SIDEBAR MOBILE : Drawer ========== */
@media (max-width: 767px) {
    .home-header {
        padding: 12px 16px;
    }

    .home-header-actions {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .home-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        border: none;
        background: transparent;
        color: var(--home-primary);
        cursor: pointer;
        border-radius: 8px;
        transition: background-color 0.2s ease;
    }

    .home-menu-btn:hover {
        background: rgba(44, 85, 69, 0.1);
    }

    .home-menu-btn:focus {
        outline: 2px solid var(--home-primary);
        outline-offset: 2px;
    }

    .home-menu-btn-icon {
        width: 24px;
        height: 24px;
    }

    /* Sidebar : masqué par défaut, drawer en overlay */
    .home-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 1000;
        width: 280px;
        max-width: 85vw;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        flex: none;
    }

    .home-sidebar--mobile-open {
        transform: translateX(0);
    }

    .home-sidebar-inner {
        height: 100%;
        border-radius: 0;
        padding: calc(64px + env(safe-area-inset-top, 0)) 16px 24px;
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .home-sidebar-toggle {
        display: none;
    }

    /* Overlay sombre */
    .home-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.4);
        z-index: 999;
        opacity: 0;
        transition: opacity 0.3s ease;
        pointer-events: none;
    }

    .home-sidebar-overlay--visible {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .home-main {
        padding: 16px;
    }

    .home-content {
        width: 100%;
    }

    .home-content-header {
        padding: 4px 0 12px;
    }

    .home-title {
        font-size: 1.35rem;
    }

    .home-subtitle {
        font-size: 0.9rem;
    }

    .home-panels {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .home-card {
        min-height: 80px;
        padding: 18px 20px;
        border-radius: 16px;
        gap: 10px;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .home-card-title {
        font-size: var(--home-card-text);
        gap: 10px;
    }

    .home-card-icon {
        width: 22px;
        height: 22px;
    }

    .home-card-text {
        font-size: var(--home-card-text);
    }

    .home-card-text--muted {
        font-size: var(--home-card-text);
    }

    .home-card-list-items li {
        font-size: var(--home-card-text);
        min-height: 24px;
    }

    .home-card-todo-item {
        min-height: 28px;
    }

    .home-card-todo-checkbox {
        width: 18px;
        height: 18px;
        margin-top: 3px;
    }

    .home-nav-item {
        min-height: 48px;
        padding: 12px 14px;
        font-size: 1rem;
    }

    .home-nav-icon {
        width: 22px;
        height: 22px;
    }

    .home-body {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}

/* Desktop : masquer hamburger sur home (sidebar dans layout) ; overlay masqué */
@media (min-width: 768px) {
    body:not(:has(.header-logged-drawer)) .home-menu-btn {
        display: none;
    }

    body:not(:has(.header-logged-drawer)) .home-sidebar-overlay {
        display: none !important;
    }
}

/* Header unifié (pages sans sidebar en layout) : drawer overlay sur tous les écrans */
/* z-index > 1500 pour passer au-dessus de la sidebar campaigns */
.header-logged-drawer {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1600;
    width: 280px;
    max-width: 85vw;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex: none !important;
}

.header-logged-drawer.home-sidebar--mobile-open {
    transform: translateX(0);
}

.header-logged-drawer .home-sidebar-inner {
    height: 100%;
    border-radius: 0;
    padding: calc(64px + env(safe-area-inset-top, 0)) 16px 24px;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
}

/* Quand header-logged-drawer existe : hamburger visible et overlay actif sur desktop */
body:has(.header-logged-drawer) .home-menu-btn {
    display: flex !important;
}

body:has(.header-logged-drawer) .header-logged-overlay,
body:has(.header-logged-drawer) .home-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1599;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

body:has(.header-logged-drawer) .header-logged-overlay.home-sidebar-overlay--visible,
body:has(.header-logged-drawer) .home-sidebar-overlay--visible {
    display: block !important;
    opacity: 1;
    pointer-events: auto;
}

/* Header unifié : réduire padding-top (le header est déjà dans le flux) */
body:has(.header-logged-drawer) .account-background {
    padding-top: var(--spacing-lg);
}

@media (max-width: 767px) {
    body:has(.header-logged-drawer) .account-background {
        padding-top: var(--spacing-md);
    }
}
