/* ============================================================================
   BTP Manager — Dashboard CSS
   Design system mobile-first, terrain-friendly
   ============================================================================ */

:root {
    --primary: #2563EB;
    --primary-dark: #1E40AF;
    --primary-light: #DBEAFE;
    --success: #16A34A;
    --success-light: #DCFCE7;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #DC2626;
    --danger-light: #FEE2E2;
    --dark: #1E293B;
    --gray-700: #334155;
    --gray-500: #64748B;
    --gray-300: #CBD5E1;
    --gray-100: #F1F5F9;
    --bg: #F8FAFC;
    --white: #FFFFFF;
    --radius: 14px;
    --radius-sm: 10px;
    --shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
    --header-h: 68px;
    --bottomnav-h: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { -webkit-tap-highlight-color: transparent; box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--dark);
    font-size: 15px;
    line-height: 1.5;
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
    min-height: 100vh;
    overscroll-behavior-y: contain;
}

/* ─── HEADER ─────────────────────────────────────────────── */
.app-header {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--white);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: var(--header-h);
}
.app-header .header-main {
    flex: 1;
    min-width: 0;
    cursor: pointer;
}
.app-header .header-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--dark);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}
.app-header .header-title .chevron {
    font-size: 0.7rem;
    color: var(--gray-500);
}
.app-header .header-sub {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.app-header .header-sub i { font-size: 0.7rem; }
.app-header .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.pill {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 5px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.pill.gratuit { background: var(--warning-light); color: #92400E; }
.pill.expire { background: var(--danger-light); color: #991B1B; }
.pill.payant { background: var(--success-light); color: #166534; }
.icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
}
.icon-btn:active { background: var(--gray-300); }

/* ─── MAIN ───────────────────────────────────────────────── */
.main {
    max-width: 720px;
    margin: 0 auto;
    padding: 12px 16px;
}

/* ─── POULS DU CHANTIER ──────────────────────────────────── */
.pulse-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.stat-pulse {
    background: var(--white);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    text-decoration: none;
    color: var(--dark);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: transform 0.15s;
    border-top: 3px solid transparent;
}
.stat-pulse:active { transform: scale(0.97); }
.stat-pulse.variant-danger { border-top-color: var(--danger); }
.stat-pulse.variant-success { border-top-color: var(--success); }
.stat-pulse.variant-warning { border-top-color: var(--warning); }
.stat-pulse.variant-primary { border-top-color: var(--primary); }
.stat-pulse-value {
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    gap: 4px;
}
.stat-pulse.variant-danger .stat-pulse-value { color: var(--danger); }
.stat-pulse.variant-success .stat-pulse-value { color: var(--success); }
.stat-pulse.variant-warning .stat-pulse-value { color: var(--warning); }
.stat-pulse.variant-primary .stat-pulse-value { color: var(--primary); }
.stat-pulse-value i { font-size: 0.85rem; opacity: 0.8; }
.stat-pulse-label {
    font-size: 0.7rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    line-height: 1.2;
}

/* ─── CARD SECTION ───────────────────────────────────────── */
.card-section {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 14px;
    overflow: hidden;
}
.card-section.accent-danger { border-left: 3px solid var(--danger); }
.card-section.accent-warning { border-left: 3px solid var(--warning); }

.section-header {
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--gray-100);
}
.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    margin: 0;
    color: var(--dark);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.section-title i { color: var(--primary); font-size: 0.9rem; }
.section-link {
    font-size: 0.78rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.section-body {
    padding: 6px 0;
    transition: max-height 0.3s ease;
    overflow: hidden;
}
.section-body.collapsed { max-height: 0; padding: 0; }
.collapsible-toggle {
    background: none;
    border: none;
    color: var(--gray-500);
    font-size: 0.85rem;
    padding: 4px;
    cursor: pointer;
    transition: transform 0.2s;
}
.collapsible-toggle.open { transform: rotate(180deg); }

/* ─── TASK ROW ───────────────────────────────────────────── */
.task-row {
    position: relative;
    overflow: hidden;
    background: var(--white);
}
.task-swipe-bg {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    display: flex;
    align-items: center;
    color: white;
    font-size: 1.3rem;
    padding: 0 24px;
}
.task-swipe-complete {
    left: 0;
    background: var(--success);
    justify-content: flex-start;
}
.task-swipe-defer {
    right: 0;
    background: var(--warning);
    justify-content: flex-end;
}
.task-content {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--white);
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    transition: transform 0.2s ease, background 0.15s;
    will-change: transform;
}
.task-content:active { background: var(--gray-100); }
.task-row:last-child .task-content { border-bottom: none; }

.task-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--gray-300);
    background: var(--white);
    color: transparent;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 2px;
}
.task-check:active {
    background: var(--success);
    border-color: var(--success);
    color: white;
}
.task-info { flex: 1; min-width: 0; }
.task-title {
    font-size: 0.93rem;
    font-weight: 600;
    color: var(--dark);
    line-height: 1.35;
    margin-bottom: 4px;
}
.task-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.73rem;
    color: var(--gray-500);
}
.task-meta i { font-size: 0.7rem; margin-right: 3px; }
.task-artisan { color: var(--primary); font-weight: 600; }
.task-due.overdue { color: var(--danger); font-weight: 600; }
.task-overdue-tag {
    background: var(--danger-light);
    color: var(--danger);
    font-size: 0.65rem;
    padding: 1px 6px;
    border-radius: 8px;
    font-weight: 700;
    margin-left: 4px;
    text-transform: uppercase;
}
.task-arrow {
    color: var(--gray-300);
    font-size: 0.75rem;
    align-self: center;
    flex-shrink: 0;
}

.priority-badge {
    font-size: 0.65rem;
    padding: 2px 8px;
    border-radius: 8px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.priority-urgent { background: var(--danger-light); color: #991B1B; }
.priority-high { background: var(--warning-light); color: #92400E; }
.priority-medium { background: var(--primary-light); color: #1E40AF; }
.priority-low { background: var(--gray-100); color: var(--gray-700); }

/* ─── WEEK ITEM ──────────────────────────────────────────── */
.week-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
}
.week-item:last-child { border-bottom: none; }
.week-day {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 44px;
}
.week-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.week-item.variant-info .week-icon { background: var(--primary-light); color: var(--primary); }
.week-item.variant-success .week-icon { background: var(--success-light); color: var(--success); }
.week-item.variant-warning .week-icon { background: var(--warning-light); color: var(--warning); }
.week-title { flex: 1; font-size: 0.88rem; font-weight: 500; }
.week-time {
    display: block;
    font-size: 0.72rem;
    color: var(--gray-500);
    margin-top: 2px;
}

/* ─── PHOTO STRIP ────────────────────────────────────────── */
.photo-strip {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 16px 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}
.photo-strip::-webkit-scrollbar { display: none; }
.photo-thumb {
    flex-shrink: 0;
    width: 96px;
    height: 96px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-100);
    scroll-snap-align: start;
    position: relative;
    text-decoration: none;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 4px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ─── PROGRESS BAR ───────────────────────────────────────── */
.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    margin-bottom: 8px;
    padding: 0 16px;
}
.progress-info strong { color: var(--dark); }
.progress-info span { color: var(--gray-500); }
.progress-custom {
    height: 8px;
    background: var(--gray-100);
    border-radius: 4px;
    overflow: hidden;
    margin: 0 16px 12px;
}
.progress-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}
.progress-fill.primary { background: linear-gradient(90deg, var(--primary), #3B82F6); }
.progress-fill.success { background: var(--success); }
.progress-fill.warning { background: var(--warning); }

.budget-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-top: 1px solid var(--gray-100);
    font-size: 0.85rem;
}
.budget-line strong { color: var(--dark); font-size: 0.95rem; }

/* ─── ALERTS ─────────────────────────────────────────────── */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 0.85rem;
}
.alert-banner.warning { background: var(--warning-light); color: #92400E; }
.alert-banner.danger { background: var(--danger-light); color: #991B1B; }
.alert-banner i:first-child { font-size: 1.1rem; flex-shrink: 0; }
.alert-banner-body { flex: 1; }
.alert-banner-title { font-weight: 700; margin-bottom: 2px; }
.alert-banner-btn {
    padding: 6px 14px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.78rem;
    text-decoration: none;
    white-space: nowrap;
    background: currentColor;
    color: white;
}
.alert-banner.warning .alert-banner-btn { color: #92400E; background: #FCD34D; }
.alert-banner.danger .alert-banner-btn { color: white; background: var(--danger); }

/* ─── EMPTY STATE ────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 24px 16px;
    color: var(--gray-500);
}
.empty-state i {
    font-size: 2rem;
    margin-bottom: 8px;
    display: block;
    color: var(--success);
    opacity: 0.6;
}
.empty-state p { margin: 0; font-size: 0.88rem; }

/* ─── FAB ────────────────────────────────────────────────── */
.fab-container {
    position: fixed;
    bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
    right: 16px;
    z-index: 95;
}
.fab-main {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    border: none;
    font-size: 1.3rem;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.fab-main.active { transform: rotate(135deg); }
.fab-actions {
    position: absolute;
    bottom: 68px;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: none;
}
.fab-action {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px) scale(0.9);
    transition: opacity 0.2s, transform 0.2s;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
}
.fab-container.open .fab-action {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.fab-action-label {
    background: var(--dark);
    color: white;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: var(--shadow);
}
.fab-action-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1rem;
    box-shadow: var(--shadow-lg);
}
.fab-action.variant-primary .fab-action-icon { background: var(--primary); }
.fab-action.variant-success .fab-action-icon { background: var(--success); }
.fab-action.variant-warning .fab-action-icon { background: var(--warning); }
.fab-action.variant-danger .fab-action-icon { background: var(--danger); }

/* ─── BOTTOM NAV ─────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottomnav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--white);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    z-index: 100;
}
.bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--gray-500);
    font-size: 0.65rem;
    font-weight: 600;
    border: none;
    background: none;
    padding: 0;
    cursor: pointer;
    transition: color 0.15s;
}
.bottom-nav .nav-item i { font-size: 1.15rem; }
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-item.active i { transform: scale(1.1); }

/* ─── BOTTOM SHEET ───────────────────────────────────────── */
.bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 200;
    pointer-events: none;
}
.bottom-sheet.open { pointer-events: auto; }
.bottom-sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    opacity: 0;
    transition: opacity 0.25s;
}
.bottom-sheet.open .bottom-sheet-backdrop { opacity: 1; }
.bottom-sheet-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: 85vh;
    background: var(--white);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
    display: flex;
    flex-direction: column;
    padding-bottom: var(--safe-bottom);
}
.bottom-sheet.open .bottom-sheet-panel { transform: translateY(0); }
.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 10px auto 0;
}
.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-100);
}
.bottom-sheet-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}
.bottom-sheet-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    background: var(--gray-100);
    color: var(--gray-700);
    cursor: pointer;
}
.bottom-sheet-body {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

/* Sheet: project picker */
.sheet-project-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-100);
    margin-bottom: 8px;
    text-decoration: none;
    color: var(--dark);
    background: var(--white);
    cursor: pointer;
    width: 100%;
    text-align: left;
    font-size: 0.92rem;
    font-weight: 500;
}
.sheet-project-item.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-dark);
    font-weight: 700;
}
.sheet-project-item i { color: var(--primary); }
.sheet-project-item .check { margin-left: auto; color: var(--success); }

/* Sheet: task details */
.sheet-task-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 12px;
    line-height: 1.3;
}
.sheet-task-meta {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.sheet-task-meta-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.88rem;
    color: var(--gray-700);
}
.sheet-task-meta-row i {
    width: 28px;
    height: 28px;
    background: var(--gray-100);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: var(--primary);
    flex-shrink: 0;
}
.sheet-task-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.sheet-task-actions .btn {
    padding: 14px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-complete {
    background: var(--success);
    color: white;
}
.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}
.btn-danger-outline {
    background: white;
    color: var(--danger);
    border: 1px solid var(--danger-light);
}

/* Sheet: menu "Plus" */
.sheet-menu-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.sheet-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 8px;
    border-radius: var(--radius-sm);
    background: var(--gray-100);
    text-decoration: none;
    color: var(--dark);
    font-size: 0.72rem;
    font-weight: 600;
    text-align: center;
    transition: background 0.15s;
}
.sheet-menu-item:active { background: var(--gray-300); }
.sheet-menu-item i {
    font-size: 1.3rem;
    color: var(--primary);
}
.sheet-divider {
    height: 1px;
    background: var(--gray-100);
    margin: 16px 0;
}
.sheet-danger-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    color: var(--danger);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: var(--radius-sm);
}
.sheet-danger-link:active { background: var(--danger-light); }

/* ─── SNACKBAR (undo) ────────────────────────────────────── */
.snackbar {
    position: fixed;
    bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
    left: 16px;
    right: 16px;
    background: var(--dark);
    color: white;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-size: 0.88rem;
    box-shadow: var(--shadow-lg);
    z-index: 150;
    transform: translateY(120%);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.snackbar.show { transform: translateY(0); }
.snackbar-action {
    color: var(--warning);
    font-weight: 700;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.88rem;
    padding: 4px 8px;
}

/* ─── EXPIRED BANNER ─────────────────────────────────────── */
.expired-banner {
    background: linear-gradient(135deg, var(--danger), #B91C1C);
    color: white;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
    position: sticky;
    top: var(--header-h);
    z-index: 89;
}
.expired-banner i { font-size: 1rem; }
.expired-banner-text { flex: 1; }
.expired-banner a {
    background: white;
    color: var(--danger);
    padding: 6px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 700;
    font-size: 0.78rem;
    white-space: nowrap;
}

/* ─── DESKTOP ────────────────────────────────────────────── */
@media (min-width: 769px) {
    body { padding-bottom: 16px; }
    .bottom-nav, .fab-container { display: none; }
    .app-header { max-width: 720px; margin: 0 auto; }
    .main { max-width: 720px; }
    .pulse-grid { gap: 14px; }
    .stat-pulse { padding: 18px; }
    .stat-pulse-value { font-size: 1.6rem; }
}