/* MarketDG : complément de style pour le menu et le mode sombre.
   Le fichier style.css existant reste intact. */

.header-container {
    position: relative;
}

.theme-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 42px;
    width: 42px;
    height: 42px;
    border: 1px solid #dfe2e5;
    border-radius: 8px;
    background: #ffffff;
    color: #39785a;
    font-size: 23px;
    line-height: 1;
    cursor: pointer;
}

.theme-menu-button:hover {
    background: #edf5f1;
}

.theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 20px;
    z-index: 2000;
    width: 270px;
    padding: 18px;
    background: #ffffff;
    color: #252525;
    border: 1px solid #e1e4e6;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.theme-menu[hidden] {
    display: none !important;
}

.theme-menu h3 {
    margin: 0 0 15px;
    color: inherit;
    font-size: 17px;
}

.theme-switch {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: inherit;
    font-size: 14px;
    cursor: pointer;
}

.theme-switch input {
    width: 18px;
    height: 18px;
    accent-color: #39785a;
    cursor: pointer;
}

.theme-menu-note {
    margin: 12px 0 0;
    color: #70757a;
    font-size: 12px;
}

/* Mode sombre global : les règles ne s'activent que lorsque la classe est présente. */
body.dark-theme {
    background: #151a17;
    color: #e8eee9;
}

body.dark-theme .header,
body.dark-theme .nav {
    background: #202723;
    border-color: #37433b;
}

body.dark-theme .logo span,
body.dark-theme .section-title,
body.dark-theme .ad-title,
body.dark-theme .detail-title,
body.dark-theme .detail-info h2,
body.dark-theme .form-card h1 {
    color: #e8eee9;
}

body.dark-theme .nav-container a {
    color: #d0d9d3;
}

body.dark-theme .nav-container a:hover {
    color: #8ed0a9;
}

body.dark-theme input,
body.dark-theme select,
body.dark-theme textarea {
    background-color: #252d28;
    color: #e8eee9;
    border-color: #46534a;
}

body.dark-theme input::placeholder,
body.dark-theme textarea::placeholder {
    color: #a6b1a9;
}

body.dark-theme .header-search input,
body.dark-theme .search-box input,
body.dark-theme .search-box select {
    background: #252d28;
    color: #e8eee9;
    border-color: #46534a;
}

body.dark-theme .category,
body.dark-theme .ad-card,
body.dark-theme .form-card,
body.dark-theme .detail-gallery,
body.dark-theme .detail-info,
body.dark-theme .annonces-search,
body.dark-theme .advanced-search,
body.dark-theme .search-filters,
body.dark-theme main.container > form.form-card {
    background: #202723;
    color: #e8eee9;
    border-color: #37433b;
}

body.dark-theme .ad-image,
body.dark-theme .ad-image img,
body.dark-theme .detail-main-image,
body.dark-theme .detail-no-image,
body.dark-theme .detail-thumbnail,
body.dark-theme .image-preview-item {
    background: #252d28;
}

body.dark-theme .ad-location,
body.dark-theme .detail-location,
body.dark-theme .detail-description,
body.dark-theme .seller-box p,
body.dark-theme .form-intro,
body.dark-theme .form-bottom-text,
body.dark-theme .form-group label {
    color: #c0cbc3;
}

body.dark-theme .seller-box,
body.dark-theme .image-preview-item {
    background: #252d28;
    border-color: #37433b;
}

body.dark-theme .btn-login,
body.dark-theme .theme-menu-button {
    background: #252d28;
    color: #a8dfbd;
    border-color: #46534a;
}

body.dark-theme .btn-login:hover,
body.dark-theme .theme-menu-button:hover {
    background: #303b33;
}

body.dark-theme .theme-menu {
    background: #202723;
    color: #e8eee9;
    border-color: #46534a;
}

body.dark-theme .theme-menu-note {
    color: #b4c0b7;
}

body.dark-theme .detail-separator {
    background: #37433b;
}

body.dark-theme .ad-category,
body.dark-theme .detail-category {
    background: #293d30;
    color: #a8dfbd;
}

body.dark-theme .footer {
    background: #101411;
    border-top: 1px solid #37433b;
}

body.dark-theme .annonces-search,
body.dark-theme .advanced-search,
body.dark-theme .search-filters,
body.dark-theme main.container > form.form-card {
    color: #e8eee9;
}

body.dark-theme .annonces-search label,
body.dark-theme .advanced-search label,
body.dark-theme .search-filters label {
    color: #c0cbc3;
}

@media (max-width: 700px) {
    .theme-menu {
        right: 12px;
        width: min(270px, calc(100vw - 24px));
    }

    .header-container {
        position: relative;
    }
}

/* Sélecteur de langue : contraste cohérent en thème clair et sombre. */
.language-choice {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 15px;
    color: inherit;
    font-size: 14px;
}

.language-choice select {
    box-sizing: border-box;
    width: 100%;
    min-height: 40px;
    padding: 7px 10px;
    border: 1px solid #b8d2c3;
    border-radius: 7px;
    background-color: #edf5f0 !important;
    color: #20392b !important;
    color-scheme: light;
    font: inherit;
    outline-offset: 2px;
    cursor: pointer;
}

.language-select-wrap {
    position: relative;
    display: block;
}

.language-select-wrap select {
    padding-inline-start: 48px;
}

.language-flag-display {
    position: absolute;
    inset-inline-start: 10px;
    top: 50%;
    display: flex;
    width: 30px;
    height: 20px;
    transform: translateY(-50%);
    pointer-events: none;
}

.language-flag-display svg {
    display: block;
    width: 30px;
    height: 20px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, .16);
}

.language-flag-display svg[hidden] {
    display: none;
}

.language-choice select:focus {
    border-color: #39785a;
    box-shadow: 0 0 0 3px rgba(57, 120, 90, 0.16);
    outline: none;
}

.language-choice select option {
    background-color: #edf5f0;
    color: #20392b;
}

body.dark-theme .language-choice select {
    background-color: #252d28 !important;
    color: #e8eee9 !important;
    border-color: #46534a;
    color-scheme: dark;
}

body.dark-theme .language-choice select option {
    background-color: #202723;
    color: #e8eee9;
}

/* Ajustements de direction pour l'interface arabe */
html[dir="rtl"] body {
    direction: rtl;
}

html[dir="rtl"] .theme-menu {
    right: auto;
    left: 20px;
    text-align: right;
}

html[dir="rtl"] .theme-switch {
    flex-direction: row;
}

html[dir="rtl"] .header-search,
html[dir="rtl"] .search-box,
html[dir="rtl"] .nav-container,
html[dir="rtl"] .header-actions {
    direction: rtl;
}

@media (max-width: 700px) {
    html[dir="rtl"] .theme-menu {
        left: 12px;
        right: auto;
    }
}


html[dir="rtl"] .language-choice select {
    text-align: right;
}


/* ===== Extension multilingue pour les pages internes ===== */
.dzmarket-settings-anchor {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 6000;
}
.dzmarket-settings-anchor .theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
}
body.dark-theme .dzmarket-settings-anchor .theme-menu-button {
    background: #252d28;
    color: #a8dfbd;
    border-color: #46534a;
}
body.dark-theme .dzmarket-settings-anchor .theme-menu {
    background: #202723;
    color: #e8eee9;
    border-color: #46534a;
}
body.dark-theme .dzmarket-settings-anchor .theme-menu-note { color: #b4c0b7; }

/* Compléments du mode sombre pour les pages qui utilisent leur propre CSS. */
body.dark-theme .box,
body.dark-theme .card,
body.dark-theme .form-card,
body.dark-theme .form-message,
body.dark-theme .info-row,
body.dark-theme .details {
    background-color: #202723;
    color: #e8eee9;
    border-color: #37433b;
}
body.dark-theme .description,
body.dark-theme .label,
body.dark-theme .date,
body.dark-theme footer,
body.dark-theme .help,
body.dark-theme .container p {
    color: #c0cbc3;
}
body.dark-theme .favorite-btn {
    background: #303b33;
    color: #e8eee9;
}
body.dark-theme .main-image,
body.dark-theme .no-image,
body.dark-theme .preview,
body.dark-theme .thumbnail {
    background: #252d28;
    color: #c0cbc3;
}
body.dark-theme .owner-notice.pending { background: #3a2b1e; color: #fed7aa; border-color: #7c4a21; }
body.dark-theme .owner-notice.rejected { background: #3a2023; color: #fecaca; border-color: #7f3038; }
body.dark-theme .dzmarket-settings-anchor { color-scheme: auto; }

/* Arabe : direction de lecture et alignement des champs. */
html[dir="rtl"] body { direction: rtl; text-align: right; }
html[dir="rtl"] .dzmarket-settings-anchor { right: auto; left: 14px; }
html[dir="rtl"] .dzmarket-settings-anchor .theme-menu { right: auto; left: 0; }
html[dir="rtl"] input[type="email"],
html[dir="rtl"] input[type="password"],
html[dir="rtl"] input[type="tel"],
html[dir="rtl"] input[type="url"],
html[dir="rtl"] input[inputmode="numeric"],
html[dir="rtl"] input[autocomplete="username"],
html[dir="rtl"] [dir="ltr"] {
    direction: ltr;
    text-align: left;
    unicode-bidi: plaintext;
}
html[dir="rtl"] .header-inner,
html[dir="rtl"] .header-container { direction: rtl; }
html[dir="rtl"] .nav,
html[dir="rtl"] .nav-container,
html[dir="rtl"] .header-actions,
html[dir="rtl"] .actions { direction: rtl; }
html[dir="rtl"] input,
html[dir="rtl"] select,
html[dir="rtl"] textarea { text-align: right; }
html[dir="rtl"] .theme-menu-button { margin-inline-start: 8px; }
html[dir="rtl"] .layout { direction: rtl; }

@media (max-width: 600px) {
    .dzmarket-settings-anchor { top: 10px; right: 10px; }
    html[dir="rtl"] .dzmarket-settings-anchor { right: auto; left: 10px; }
}

.dzmarket-settings-anchor.dzmarket-in-header {
    position: relative;
    top: auto;
    right: auto;
    left: auto;
    flex: 0 0 auto;
    align-self: center;
}
.dzmarket-settings-anchor.dzmarket-in-header .theme-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    left: auto;
}
html[dir="rtl"] .dzmarket-settings-anchor.dzmarket-in-header .theme-menu {
    right: auto;
    left: 0;
}
@media (max-width: 600px) {
    .dzmarket-settings-anchor.dzmarket-in-header { top: auto; right: auto; left: auto; }
}


body.dark-theme .description-counter { color: #aeb8c6; }
body.dark-theme .description-counter.limit-reached { color: #fca5a5; }

/* Transparent horizontal MarketDG logo lockup supplied 2026-10-31. */
.logo,
.dzmarket-brand-logo,
.store-brand {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    min-width: 0 !important;
    max-width: min(280px, 76vw) !important;
    height: min(44px, 10.5vw) !important;
    padding: 0 !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    font-size: 0 !important;
    line-height: 1 !important;
    text-indent: -100vw !important;
    white-space: nowrap !important;
}

.logo::before,
.dzmarket-brand-logo::before,
.store-brand::before {
    content: "";
    display: block;
    flex: 0 0 auto;
    width: min(190px, 46vw);
    height: min(44px, 10.5vw);
    border-radius: 7px;
    background-color: transparent;
    background-image: url("../images/marketdg-logo-horizontal-transparent.png");
    background-image: image-set(url("../images/marketdg-logo-horizontal-transparent.webp") type("image/webp"), url("../images/marketdg-logo-horizontal-transparent.png") type("image/png"));
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
}

.logo > img[src*="dzmarket-logo.svg"],
.dzmarket-brand-logo > img[src*="dzmarket-logo.svg"],
.store-brand > img[src*="dzmarket-logo.svg"] {
    display: none !important;
}

.logo > span:not(.dzmarket-brand-context),
.dzmarket-brand-logo > span:not(.dzmarket-brand-context),
.store-brand > span:not(.dzmarket-brand-context) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.logo > .dzmarket-brand-context,
.dzmarket-brand-logo > .dzmarket-brand-context,
.store-brand > .dzmarket-brand-context,
.store-brand > small {
    position: static !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    overflow: visible !important;
    clip: auto !important;
    border: 0 !important;
    color: inherit !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    text-indent: 0 !important;
}

img[src*="dzmarket-logo.svg"] {
    display: block;
    width: min(190px, 46vw) !important;
    height: min(44px, 10.5vw) !important;
    max-width: 76vw !important;
    object-fit: contain !important;
    object-position: center !important;
    border-radius: 7px;
    background-color: transparent;
}

@media (max-width: 600px) {
    .logo::before,
    .dzmarket-brand-logo::before,
    .store-brand::before {
        width: min(160px, 46vw);
        height: min(38px, 10.5vw);
    }
    img[src*="dzmarket-logo.svg"] {
        width: min(160px, 46vw) !important;
        height: min(38px, 10.5vw) !important;
    }
}

@media (max-width: 340px) {
    .store-page-top > .store-brand::before {
        width: min(120px, 38vw);
        height: min(29px, 9vw);
    }
}

/* The artwork is transparent; use a compact backing only where dark mode needs contrast. */
body.dark-theme .logo::before,
body.dark-theme .dzmarket-brand-logo::before,
body.dark-theme .store-brand::before,
body.dark-theme img[src*="dzmarket-logo.svg"] {
    background-color: rgba(255, 255, 255, 0.96);
}
