/* =========================
   GLOBAL
========================= */

body {
    font-family: 'Segoe UI', Arial, sans-serif;
    margin: 0;
    background: #f5f6fa;
}

.container {
    padding: 20px;
}


/* =========================
   HEADER LAYOUT
========================= */

header {
    background: #2f3640;
    height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-sizing: border-box;
}

.header-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    flex-shrink: 0;
    line-height: 1.2;
}

.header-brand:visited {
    color: white;
}

.header-brand:hover {
    opacity: 0.85;
}

.brand-sigle {
    font-size: 15px;
    font-weight: 700;
    color: white;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.brand-subtitle {
    font-size: 10px;
    font-weight: 400;
    color: rgba(255,255,255,0.65);
    white-space: nowrap;
    letter-spacing: 0;
    padding-left: 1px;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}


/* =========================
   NAV
========================= */

.header-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.nav-link {
    color: #c8cdd6;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.nav-link:visited {
    color: #c8cdd6;
}

.nav-link:hover,
.dropdown:hover > .nav-link {
    background: rgba(255, 255, 255, 0.08);
    color: white;
}

.nav-link.active {
    background: #00a8ff;
    color: white;
    font-weight: 600;
}

.dropdown-toggle::after {
    content: '▾';
    font-size: 10px;
    opacity: 0.6;
}


/* =========================
   DROPDOWNS NAV
========================= */

.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    padding-top: 8px;
    background: transparent;
    min-width: 190px;
    z-index: 200;
}

.dropdown-menu::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: -1;
}

.dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 14px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.1s;
}

.dropdown-menu a:hover {
    background: #f5f6fa;
    color: #2f3640;
}


/* =========================
   SEARCH BAR
========================= */

.search-bar {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 11px;
    font-size: 13px;
    pointer-events: none;
    opacity: 0.45;
}

.search-bar input {
    width: 100%;
    padding: 8px 14px 8px 34px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 13px;
    box-sizing: border-box;
    outline: none;
    transition: background 0.2s;
}

.search-bar input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.search-bar input:focus {
    background: rgba(255, 255, 255, 0.16);
}

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    z-index: 1000;
}

.search-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    text-decoration: none;
    color: #2f3640;
    font-size: 13px;
    transition: background 0.1s;
}

.search-item:hover {
    background: #f5f6fa;
}

.search-item mark {
    background: #fff3a3;
    color: inherit;
    border-radius: 2px;
    padding: 0 1px;
}

.search-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

.search-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-badge--reference  { background: #d6eeff; color: #005fa3; }
.search-badge--produit    { background: #d4f5e2; color: #1a6b3a; }
.search-badge--kit        { background: #ede0ff; color: #5c2d91; }
.search-badge--dm         { background: #fde0d8; color: #c0330a; }
.search-badge--medicament { background: #fef3cd; color: #7a5200; }

.search-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 5px;
    margin-right: 8px;
    flex-shrink: 0;
}

.search-thumb-placeholder {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f3f8;
    border-radius: 5px;
    margin-right: 8px;
    font-size: 16px;
    flex-shrink: 0;
}


/* =========================
   SCAN BUTTON
========================= */

.btn-scan {
    background: #00a8ff;
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
    box-shadow: 0 2px 8px rgba(0, 168, 255, 0.35);
}

.btn-scan:visited {
    color: white;
}

.btn-scan:hover {
    background: #0097e6;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 168, 255, 0.45);
}

.btn-scan.active {
    background: #273c75;
    box-shadow: none;
}


/* =========================
   USER MENU
========================= */

.user-dropdown {
    position: relative;
    flex-shrink: 0;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    white-space: nowrap;
    transition: background 0.15s;
    user-select: none;
}

.user-trigger:hover {
    background: rgba(255, 255, 255, 0.08);
}

.badge-role {
    background: #273c75;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.badge-company {
    background: #2980b9;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    letter-spacing: 0.3px;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 8px;
    background: transparent;
    min-width: 190px;
    z-index: 200;
}

.dropdown-content::after {
    content: '';
    position: absolute;
    top: 8px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: -1;
}

.user-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-company {
    padding: 12px 14px;
    font-weight: 700;
    font-size: 13px;
    color: #2f3640;
    background: #f5f6fa;
}

.dropdown-divider {
    height: 1px;
    background: #eee;
}

.dropdown-content a {
    display: block;
    padding: 10px 14px;
    color: #333;
    text-decoration: none;
    font-size: 13px;
    transition: background 0.1s;
}

.dropdown-content a:hover {
    background: #f5f6fa;
}

.dropdown-logout {
    display: block;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    border-radius: 0;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    color: #c0392b;
    transition: background 0.1s;
}

.dropdown-logout:hover {
    background: #fff5f5;
}

.dropdown-section-title {
    padding: 8px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #999;
}

.dropdown-item-btn {
    display: block;
    width: 100%;
    padding: 8px 14px;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    color: #333;
    transition: background 0.1s;
}
.dropdown-item-btn:hover { background: #f5f6fa; }
.dropdown-item-btn.current { font-weight: 700; color: #4f8ef7; }


/* =========================
   LOGIN BUTTON
========================= */

.login-btn {
    background: #00a8ff;
    color: white;
    padding: 7px 14px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.15s;
}

.login-btn:hover {
    background: #0097e6;
}


/* =========================
   STRUCTURE SWITCHER
========================= */

.structure-switcher {
    position: relative;
}

.structure-trigger {
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: default;
}

.structure-switcher.switchable .structure-trigger {
    cursor: pointer;
    border-radius: 8px;
    padding: 2px 4px;
    transition: background .15s;
}

.structure-switcher.switchable .structure-trigger:hover,
.structure-switcher.switchable:focus-within .structure-trigger {
    background: rgba(255,255,255,.12);
}

.switch-caret {
    font-size: 10px;
    color: rgba(255,255,255,.7);
    line-height: 1;
    margin-top: 1px;
}

.structure-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    padding-top: 10px;
    background: transparent;
    min-width: 220px;
    z-index: 300;
}

.structure-dropdown::after {
    content: '';
    position: absolute;
    top: 10px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    z-index: -1;
}

.structure-switcher.switchable:hover .structure-dropdown,
.structure-switcher.switchable:focus-within .structure-dropdown {
    display: block;
}

.switch-code {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .05em;
    color: white;
    background: #4f8ef7;
    border-radius: 4px;
    padding: 2px 6px;
    margin-right: 6px;
    flex-shrink: 0;
}

.dropdown-item-link {
    display: block;
    padding: 8px 14px;
    color: #555;
    text-decoration: none;
    font-size: 13px;
    transition: background .1s;
}

.dropdown-item-link:hover {
    background: #f5f6fa;
}


/* =========================
   RESPONSIVE MOBILE (≤900px)
========================= */

/* Hamburger button */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,0.8);
    padding: 7px 8px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    line-height: 0;
    align-items: center;
    justify-content: center;
}
.menu-toggle:hover { background: rgba(255,255,255,0.1); color: white; }

/* Mobile drawer (slide depuis la droite) */
.mobile-drawer {
    position: fixed;
    top: 56px;
    left: 0; right: 0; bottom: 0;
    background: #2f3640;
    z-index: 400;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-overflow-scrolling: touch;
}
.mobile-drawer.open { transform: translateX(0); }

/* User info strip */
.mdr-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 18px;
    background: rgba(0,0,0,0.15);
    color: white;
    font-size: 14px;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

/* Section title */
.mdr-section-title {
    padding: 14px 18px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: rgba(255,255,255,0.35);
}

/* Nav link */
.mdr-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 13px 18px;
    color: #c8cdd6;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.1s, color 0.1s;
    border-bottom: 1px solid rgba(255,255,255,0.04);
}
.mdr-link:last-child { border-bottom: none; }
.mdr-link:hover  { background: rgba(255,255,255,0.06); color: white; }
.mdr-link.active { background: rgba(0,168,255,0.12); color: #4fc3f7; }

/* Button reset for form buttons inside drawer */
.mdr-btn {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    font-size: 14px;
}
.mdr-logout { color: #e57373 !important; }
.mdr-logout:hover { background: rgba(229,115,115,0.08) !important; }

/* Bottom section (theme + settings + logout) */
.mdr-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
    margin-top: 8px;
    padding-top: 4px;
}

/* Theme icon swap in mobile drawer */
#mobile-theme-toggle .icon-sun  { display: none; }
#mobile-theme-toggle .icon-moon { display: inline-block; }
[data-theme="dark"] #mobile-theme-toggle .icon-sun  { display: inline-block; }
[data-theme="dark"] #mobile-theme-toggle .icon-moon { display: none; }

/* Masquer les éléments desktop sur mobile */
@media (max-width: 900px) {
    .header-nav          { display: none !important; }
    .search-bar          { display: none !important; }
    .user-dropdown       { display: none !important; }
    .structure-switcher  { display: none !important; }
    #theme-toggle        { display: none !important; }
    .menu-toggle         { display: flex !important; }
}
