﻿/* =========================================================
   PromoTool Theme (ordered: generic -> specific)
   ========================================================= */

:root {
    --pt-red: #f8f8f8;
    --pt-red-hover: #ede9e9;
    --pt-black: #000000;
    --pt-bg: #0b0b0b;
    --pt-bg-soft: #121212;
    --pt-border: rgba(255, 255, 255, 0.12);
    --pt-text: #ffffff;
    --pt-text-muted: rgba(255, 255, 255, 0.65);
    --pt-focus: rgb(253, 238, 239);

    --pt-sidebar-width: 260px;
    --pt-sidebar-collapsed-width: 72px;
    --pt-mobile-header-h: 56px;
    /* Nouvelle variable: hauteur du header utilisée pour sticky positioning et overlay offsets.
       Par défaut sur mobile puis overridée en desktop via media query */
    --pt-header-h: 56px;
}

/* =======================
   Base
   ======================= */

html, body {
    height: 100%;
    margin: 0;
    background: var(--pt-bg);
    color: var(--pt-text);
    overflow-x: hidden;
}

* {
    box-sizing: border-box;
}

a {
    color: var(--pt-red);
    text-decoration: none;
}

a:hover {
    color: var(--pt-red-hover);
    text-decoration: underline;
}

/* =======================
   Login / Auth screens (home déconnectée + authentication)
   ======================= */

/* Plein écran, fond PromoTool, centrage */
.pt-login-hero,
.pt-loading-wrap {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
    box-sizing: border-box;
    overflow: hidden;
    color: #ffffff;
    background: radial-gradient(800px 400px at 50% 20%, rgba(227, 6, 19, 0.12), transparent 60%),
    linear-gradient(180deg, #000000, #0b0b0b);
}

/* Force full screen overlay when `.pt-loading-full` est appliqué (évite le padding blanc du layout) */
.pt-loading-full {
    position: fixed;
    inset: 0; /* top:0; right:0; bottom:0; left:0 */
    padding: 0; /* remove layout padding */
    display: grid;
    place-items: center;
    background: radial-gradient(800px 400px at 50% 20%, rgba(227, 6, 19, 0.12), transparent 60%),
    linear-gradient(180deg, #000000, #0b0b0b);
    z-index: 1200;
}

/* Carte */
.pt-login-card,
.pt-loading-card {
    width: min(520px, 92vw);
    border-radius: 20px;
    padding: 34px 34px 26px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.65);
    text-align: center;
}

/* Logo wrapper (évite logo cassé) */
.pt-login-logo-wrap,
.pt-loading-logo-wrap {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    display: grid;
    place-items: center;
    margin: 0 auto 16px;
}

/* Logo image */
.pt-login-logo,
.pt-loading-logo {
    width: 44px;
    height: 44px;
    object-fit: contain;
    display: block;
}

.pt-login-card h1 {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: 0.2px;
    color: #ffffff;
}

.pt-login-tagline {
    margin: 10px 0 22px;
    color: rgba(255, 255, 255, 0.78);
    font-size: 1rem;
}

/* Bouton login */
.pt-login-btn {
    width: 100%;
    padding: 0.85rem 1rem;
    font-size: 1rem;
    border-radius: 14px;
}

/* Spinner (si utilisé dans authorizing) */
.pt-spinner {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 3px solid rgba(255, 255, 255, 0.18);
    border-top-color: rgba(227, 6, 19, 0.95);
    margin: 10px auto 14px;
    animation: pt-spin 0.85s linear infinite;
}

@keyframes pt-spin {
    to {
        transform: rotate(360deg);
    }
}

.pt-loading-subtitle,
.pt-loading-hint {
    color: rgba(255, 255, 255, 0.78);
}

/* Mobile: centré propre, moins de padding */
@media (max-width: 767.98px) {
    .pt-login-hero,
    .pt-loading-wrap {
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* =======================
   Avatar (FIX: never huge)
   ======================= */

.pt-avatar {
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    border-radius: 999px !important;
    object-fit: cover !important;
    display: block !important;
    flex: 0 0 40px !important;
}

@media (min-width: 768px) {
    .pt-avatar {
        width: 2.5em !important;
        height: 2.5em !important;
        max-width: 2.5em !important;
        max-height: 2.5em !important;
        flex: 0 0 2.5em !important;
    }
}

.pt-top-user img {
    width: inherit;
    height: inherit;
    max-width: inherit;
    max-height: inherit;
}

/* Alignement avatar / nom / bouton */
.pt-top-user {
    display: inline-flex !important;
    align-items: center !important;
    gap: 12px;
}

.pt-top-user .pt-avatar {
    align-self: center !important;
}

.pt-top-user-link {
    display: inline-flex !important;
    align-items: center !important;
    line-height: 1 !important;
}

.pt-top-user .btn {
    align-self: center !important;
    line-height: 1.1;
}

.pt-top-username {
    display: inline-block;
    line-height: 1.1;
}

/* =======================
   Layout desktop
   ======================= */

.page {
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

.sidebar {
    display: flex;
    flex-direction: column;
    min-height: 100vh;

    width: var(--pt-sidebar-width);
    flex: 0 0 var(--pt-sidebar-width);
    flex-shrink: 0;

    background: #000000 !important;
    background-image: none !important;
    border-right: 1px solid var(--pt-border);
}

.nav-scrollable {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;

    background: #000000 !important;
    background-image: none !important;
}

.pt-main,
main {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.content,
.overflow-x-container {
    min-width: 0;
    overflow-x: auto;
    overflow-y: visible;
}

/* =======================
   Top rows (generic)
   ======================= */

.top-row {
    background: #f6f4f4;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.pt-top-row,
.pt-main-toprow {
    background: #f6f4f4 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12) !important;
}

.navbar-toggler {
    border-color: rgba(255, 255, 255, 0.25);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px var(--pt-focus);
}

/* =======================
   Sidebar header
   ======================= */

.sidebar .top-row {
    background: #000000 !important;
    background-image: none !important;
    border-bottom: 1px solid var(--pt-border);
}

.pt-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    overflow: hidden;
    white-space: nowrap;
}

.pt-brand-logo {
    width: 22px;
    height: 22px;
    object-fit: contain;
    border-radius: 6px;
}

/* =======================
   Sidebar nav
   ======================= */

.sidebar .nav-item a,
.sidebar .nav-item .nav-link {
    color: var(--pt-text-muted) !important;
    border-radius: 10px;
    margin: 4px 10px;
    padding: 10px 12px;
}

.sidebar .nav-item a:hover,
.sidebar .nav-item .nav-link:hover {
    color: var(--pt-text) !important;
    background: rgba(255, 255, 255, 0.06) !important;
}

.sidebar .nav-item a.active,
.sidebar .nav-item .nav-link.active {
    color: #ffffff !important;
    background: rgba(227, 6, 19, 0.16) !important;
    box-shadow: none !important;
}

.sidebar .nav-link {
    display: flex !important;
    align-items: center !important;
    gap: 12px;
    min-height: 42px;
    line-height: 1;
}

.sidebar .nav-link .bi,
.sidebar .nav-link .fa-solid,
.sidebar .nav-link .fa-regular,
.sidebar .nav-link .fa-light,
.sidebar .nav-link .fa-duotone,
.sidebar .nav-link .fa-brands {
    width: 22px;
    min-width: 22px;
    display: grid;
    place-items: center;
    font-size: 1.05rem;
    line-height: 1;
    color: var(--pt-red);
    opacity: 0.95;
}

.sidebar .pt-nav-text {
    white-space: nowrap;
}

/* =======================
   Desktop: sidebar collapsed
   ======================= */

.pt-sidebar-toggle {
    margin-left: 10px;
    gap: 8px;
    align-items: center;
    padding: 0.35rem 0.6rem;
}

.pt-collapse-icon {
    transition: transform 160ms ease;
    display: block;
    line-height: 1;
}

.pt-rot180 {
    transform: rotate(180deg);
}

@media (min-width: 768px) {
    .sidebar.pt-sidebar-collapsed {
        width: var(--pt-sidebar-collapsed-width) !important;
        flex-basis: var(--pt-sidebar-collapsed-width) !important;
        overflow-x: hidden;
    }

    .sidebar.pt-sidebar-collapsed .nav-item,
    .sidebar.pt-sidebar-collapsed .nav-item.px-3 {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .sidebar.pt-sidebar-collapsed .nav-link {
        justify-content: center !important;
        gap: 0 !important;
        width: calc(var(--pt-sidebar-collapsed-width) - 16px) !important;
        margin: 6px auto !important;
        padding: 12px 0 !important;
    }

    .sidebar.pt-sidebar-collapsed .pt-nav-text {
        display: none !important;
    }

    .sidebar.pt-sidebar-collapsed .nav-link .bi,
    .sidebar.pt-sidebar-collapsed .nav-link .fa-solid,
    .sidebar.pt-sidebar-collapsed .nav-link .fa-regular,
    .sidebar.pt-sidebar-collapsed .nav-link .fa-light,
    .sidebar.pt-sidebar-collapsed .nav-link .fa-duotone,
    .sidebar.pt-sidebar-collapsed .nav-link .fa-brands {
        width: 100%;
        min-width: 0;
        font-size: 1.1rem;
    }

    .sidebar.pt-sidebar-collapsed .pt-brand-text {
        display: none !important;
    }

    .sidebar.pt-sidebar-collapsed .top-row .container-fluid {
        position: relative;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar.pt-sidebar-collapsed .pt-sidebar-toggle {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        margin: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 6px;
        min-width: 36px;
        min-height: 36px;
    }
}

/* =======================
   Mobile (most specific last)
   ======================= */

@media (max-width: 767.98px) {
    .page {
        flex-direction: column;
        overflow-x: hidden;
    }

    .sidebar {
        width: 100%;
        flex: 0 0 auto;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid var(--pt-border);
    }

    /* Keep the top bar visible on mobile (override previous hide rules) */
    main > .top-row,
    .pt-main > .top-row,
    main .pt-main-toprow,
    .pt-main .pt-main-toprow {
        display: block !important;
    }

    .nav-scrollable.collapse {
        display: none !important;
    }

    .nav-scrollable:not(.collapse) {
        max-height: calc(100dvh - var(--pt-mobile-header-h));
        overflow-y: auto;
        overflow-x: hidden;
        padding: 10px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.10);
    }

    .sidebar .nav-item,
    .sidebar .nav-item.px-3 {
        padding: 0 !important;
        width: 100%;
    }

    .sidebar .nav-item a,
    .sidebar .nav-item .nav-link {
        display: flex !important;
        width: 100% !important;
        margin: 6px 0 !important;
        padding: 14px 14px !important;
        border-radius: 12px !important;
    }

    .sidebar .pt-nav-text {
        white-space: normal !important;
    }

    /* Ensure the loading/auth overlays don't cover the mobile header: leave space for header height */
    .pt-loading-full,
    .pt-authorizing-overlay {
        inset: var(--pt-mobile-header-h) 0 0 0; /* top right bottom left */
        padding-top: 8px; /* small breathing room under header */
    }

    /* Adjust splash / loading card sizing on small screens to avoid overflow */
    .pt-card,
    .pt-login-card,
    .pt-loading-card {
        width: calc(100% - 32px) !important;
        border-radius: 12px;
        padding: 16px !important;
        margin: 0 12px;
    }

    /* Slightly smaller title + tagline on mobile and force wrapping */
    .pt-name {
        font-size: 16px;
        line-height: 1.05;
        word-break: break-word;
    }

    .pt-tagline {
        font-size: 12px;
        color: rgba(255, 255, 255, 0.8);
        white-space: normal;
        overflow-wrap: anywhere;
        margin-top: 4px;
    }

    /* Reduce padding on the page content to better fit mobile */
    .content.px-4,
    article.content.px-4,
    .top-row.px-4 {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .mud-container {
        max-width: 100% !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    .mud-button-root {
        max-width: 100% !important;
        white-space: normal !important;
    }

    /* Mobile menu styling */
    .pt-mobile-menu {
        position: absolute;
        top: var(--pt-mobile-header-h);
        right: 12px;
        left: 12px;
        background: rgba(0, 0, 0, 0.85);
        border: 1px solid rgba(255, 255, 255, 0.06);
        border-radius: 8px;
        z-index: 1300;
    }

    .pt-mobile-menu-inner {
        padding: 8px;
    }

    .pt-mobile-menu .btn {
        width: 100%;
        text-align: left;
    }

    /* Remove border-top/white highlight on header for small screens */
    .top-row, .pt-top-row, .pt-main-toprow {
        border-bottom: 0 !important;
        box-shadow: none !important;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.98), rgba(0, 0, 0, 0.95));
    }

    /* Mobile hamburger button styling */
    .pt-mobile-hamburger {
        min-width: 44px;
        min-height: 44px;
        width: 44px;
        height: 44px;
        display: inline-grid;
        place-items: center;
        border-radius: 0;
        padding: 6px;
        margin-left: 8px;
        background: transparent !important;
        border: none !important;
    }

    .pt-mobile-hamburger:focus {
        outline: none;
        box-shadow: none;
    }

    /* Align hamburger to the far right inside the header */
    .top-row > .d-flex.d-md-none {
        margin-left: auto !important;
    }

    /* Ensure mobile menu sits below header height variable */
    .pt-mobile-menu {
        top: var(--pt-header-h);
    }

    /* Safety override at end to ensure no white border on top-row in mobile */
    .top-row, .pt-top-row, .pt-main-toprow {
        border-bottom: 0 !important;
        box-shadow: none !important;
        background: linear-gradient(180deg, rgba(0, 0, 0, 0.98), rgba(0, 0, 0, 0.95)) !important;
        padding-right: 68px !important; /* espace pour le bouton hamburger absolu */
        position: sticky !important; /* keep sticky */
    }

    /* Make hamburger absolute to avoid wrapping and force right alignment */
    .pt-mobile-hamburger {
        position: absolute !important;
        right: 12px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        margin-left: 0 !important;
    }

    /* Ensure that the logo/brand doesn't overlap the hamburger */
    .top-row > .d-flex:first-child {
        z-index: 1110; /* below hamburger */
    }
}

/* Top row sticky to keep header visible on scroll */
.top-row,
.pt-top-row,
.pt-main-toprow {
    position: sticky;
    top: 0;
    z-index: 1100; /* above main content but below modals/overlays */
    backdrop-filter: saturate(120%);
}

/* Ensure overlays and mobile menu appear below the sticky header */
.pt-loading-full,
.pt-authorizing-overlay {
    inset: var(--pt-header-h) 0 0 0; /* leave space on top equal to header height */
}

.pt-mobile-menu {
    position: absolute;
    top: var(--pt-header-h);
    right: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    z-index: 1300;
}

/* Desktop header height override */
@media (min-width: 768px) {
    :root {
        --pt-header-h: 72px; /* header generally taller on desktop */
    }

    .pt-mobile-menu {
        right: 18px;
        left: auto;
        width: 260px;
    }
}

/* Hamburger lines drawn with CSS for better contrast on dark backgrounds */
.pt-hamburger-lines {
    display: inline-block;
    width: 20px;
    height: 14px;
    position: relative;
}

.pt-hamburger-lines::before,
.pt-hamburger-lines::after,
.pt-hamburger-lines div {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 2px;
}

.pt-hamburger-lines::before {
    top: 0;
}

.pt-hamburger-lines div {
    top: 6px;
}

.pt-hamburger-lines::after {
    bottom: 0;
}

/* Small accessibility: increase contrast on hover/focus */
.pt-mobile-hamburger:hover .pt-hamburger-lines::before,
.pt-mobile-hamburger:hover .pt-hamburger-lines::after,
.pt-mobile-hamburger:hover .pt-hamburger-lines div,
.pt-mobile-hamburger:focus .pt-hamburger-lines::before,
.pt-mobile-hamburger:focus .pt-hamburger-lines::after,
.pt-mobile-hamburger:focus .pt-hamburger-lines div {
    background: rgba(255, 255, 255, 0.95);
}

/* Ensures hamburger lines are hidden on desktop only (sync with Mud breakpoint ~960px) */
@media (min-width: 960px) {
    .pt-hamburger-lines {
        display: none !important;
    }
}

/* Force visibility on mobile (show until 960px breakpoint) */
@media (max-width: 959.98px) {
    .pt-hamburger-lines {
        display: inline-block !important;
    }
}

/* Force absolute black background on header to eliminate any white border/glow effect */
@media (max-width: 767.98px) {
    .top-row, .pt-top-row, .pt-main-toprow {
        background-color: #000000 !important;
        background: #000000 !important;
        border: none !important;
        border-bottom: 0 !important;
        box-shadow: none !important;
        outline: none !important;
    }
}

/* Force authorizing overlay to be fully black without white padding/borders */
.pt-authorizing-overlay,
.pt-loading-full {
    background: #000000 !important;
    background-image: none !important;
    padding: 0 !important;
    border: none !important;
    box-shadow: none !important;
}
