/* ================================================================
   MODAL PERSONNALISATION MOBILE v3 — Canvas + footer tabs + bottom sheets
================================================================ */

/* ── Structure globale ── */
#customizeModal.mob-modal .modal-content,
.mob-modal {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    background: #0e0e0e;
}

/* ── Header ── */
.mob-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: 52px;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: #111;
    gap: 8px;
}
.mob-header__left  { display: flex; align-items: center; gap: 6px; }
.mob-header__right { display: flex; align-items: center; gap: 6px; }
.mob-header__title {
    flex: 1;
    text-align: center;
    font-size: 14px;
    font-weight: 600;
    color: #f0f0f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mob-icon-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    transition: background .15s;
}
.mob-icon-btn:hover { background: rgba(255,255,255,0.1); }
.mob-icon-btn:disabled { opacity: 0.35; }
.close-button.mob-icon-btn { font-size: 22px; font-weight: 300; }

/* ── Canvas ── */
.mob-canvas-zone {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    background: #111;
}
.mob-canvas-zone #product2DContainer,
.mob-canvas-zone #product3DContainer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}
.mob-canvas-zone #product2DContainer img#product2DPlaceholderImage {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.mob-canvas-zone .fabric-wrapper {
    position: absolute;
    inset: 0;
}

/* ── Bottom sheets (panels) ── */
.mob-panel {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 1100;
    background: #181818;
    border-radius: 16px 16px 0 0;
    border-top: 1px solid rgba(255,255,255,0.08);
    transform: translateY(100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    max-height: 75vh;
    display: flex;
    flex-direction: column;
}
.mob-panel.mob-panel--open {
    transform: translateY(0);
}
.mob-panel__handle {
    width: 36px; height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    margin: 10px auto 0;
    flex-shrink: 0;
}
.mob-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
    flex-shrink: 0;
}
.mob-panel__title {
    font-size: 14px;
    font-weight: 700;
    color: #e3e3e3;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.mob-panel__close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.5);
    font-size: 22px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}
.mob-panel__close:hover { background: rgba(255,255,255,0.1); }
.mob-panel__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 16px 24px;
    -webkit-overflow-scrolling: touch;
}

/* Backdrop quand panel ouvert — injecté dans .mob-canvas-zone via JS */
.mob-panel-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 5;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s;
}
.mob-panel-backdrop.mob-panel-backdrop--visible {
    opacity: 1;
    pointer-events: all;
}

/* ── Footer ── */
.mob-footer {
    flex-shrink: 0;
    background: #111;
    border-top: 1px solid rgba(255,255,255,0.07);
    padding: 8px 12px max(8px, env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
}
.mob-footer__tools {
    display: flex;
    flex: 1;
    overflow-x: auto;
    gap: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.mob-footer__tools::-webkit-scrollbar { display: none; }

.mob-tool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 14px;
    background: none;
    border: none;
    border-radius: 10px;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.mob-tool-btn i { font-size: 18px; }
.mob-tool-btn svg { flex-shrink: 0; }
.mob-tool-btn:hover,
.mob-tool-btn.is-active {
    background: rgba(255,255,255,0.08);
    color: #1abc9c;
}

.mob-validate-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: #1abc9c;
    border: none;
    border-radius: 999px;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
    letter-spacing: .04em;
    transition: opacity .15s;
}
.mob-validate-btn:hover { opacity: 0.9; }

/* ── Panel content styles ── */
.mob-panel__body .design-dropzone {
    border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 12px;
    padding: 32px 16px;
    text-align: center;
    color: rgba(255,255,255,0.5);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.mob-panel__body .design-dropzone i { font-size: 28px; color: #1abc9c; }
.mob-panel__body .design-dropzone__label { font-weight: 600; color: #e3e3e3; }

/* Styles inline pour panels produit */
.mob-panel__body .modal-product-header { padding: 4px 0 12px; }
.mob-panel__body .modal-product-name { font-size: 16px; font-weight: 700; color: #e3e3e3; margin: 0 0 6px; }
.mob-panel__body .product-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 0 0 14px; }

/* Réutilise les styles TF du desktop dans les panels mobile */
.mob-panel__body .tf-section { margin-bottom: 18px; }
.mob-panel__body .tf-label { color: #e3e3e3; }
.mob-panel__body .text-content-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: #e3e3e3;
    padding: 10px 12px;
    font-size: 15px;
    resize: none;
    margin-bottom: 14px;
}
.mob-panel__body .layers-list { display: flex; flex-direction: column; gap: 8px; }

/* ── Mode clair mobile ── */
[data-theme="light"] .mob-modal,
[data-theme="light"] #customizeModal.mob-modal .modal-content { background: #f4efe6; }
[data-theme="light"] .mob-header { background: #fff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .mob-header__title { color: #16221f; }
[data-theme="light"] .mob-icon-btn { color: #45524e; }
[data-theme="light"] .mob-canvas-zone { background: #ece4d6; }
[data-theme="light"] .mob-footer { background: #fff; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .mob-tool-btn { color: #6c7873; }
[data-theme="light"] .mob-tool-btn.is-active,
[data-theme="light"] .mob-tool-btn:hover { background: rgba(14,156,128,0.08); color: #0e9c80; }
[data-theme="light"] .mob-panel { background: #f9fafb; border-color: rgba(0,0,0,0.08); }
[data-theme="light"] .mob-panel__title { color: #16221f; }
[data-theme="light"] .mob-panel__close { color: #6c7873; }
[data-theme="light"] .mob-panel__body .text-content-input { background: #fff; border-color: rgba(0,0,0,0.1); color: #16221f; }
[data-theme="light"] .mob-validate-btn { background: #2c3b37; }

/* ── Corrections visuelles ── */
/* Reset button : pas de highlight par défaut */
.mob-icon-btn#resetDesignButton { color: rgba(255,255,255,0.5); }
.mob-icon-btn#resetDesignButton:focus { outline: none; background: none; }

/* Gradient scroll indicator pour les onglets */
.mob-footer { position: relative; }
.mob-footer__tools::after {
  content: '';
  position: sticky;
  right: 0;
  flex-shrink: 0;
  width: 24px;
  background: linear-gradient(to right, transparent, #111);
  pointer-events: none;
}

/* s'assurer que le modal mobile occupe tout l'écran */
#customizeModal.mob-modal { position: fixed; inset: 0; z-index: 1000; }
#customizeModal.mob-modal .modal-content.mob-modal { height: 100dvh; }

/* ── Barre VZH mobile ── */
.mob-vzh-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 8px 16px;
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}
.mob-vzh-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s;
  flex: 1;
  justify-content: center;
}
.mob-vzh-btn:not([disabled]):hover { color: #1abc9c; }
.mob-vzh-btn.is-active { color: #1abc9c; }
.mob-vzh-btn[disabled] { opacity: 0.3; cursor: not-allowed; }
.mob-vzh-sep {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

/* ── Footer 2 niveaux ── */
.mob-footer { flex-direction: column; align-items: stretch; gap: 0; padding: 0; }

/* Masquage selon état */
.mob-footer--steps .mob-n2-tools  { display: none; }
.mob-footer--steps .mob-n1-tools  { display: none; }
.mob-footer--tools .mob-n2-steps  { display: none; }
.mob-footer--tools .mob-n1-steps  { display: none; }

/* ── Niveau 2 haut : sous-total (état steps) ── */
.mob-n2-steps {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.mob-subtotal-price { color: #1abc9c; }

/* ── Niveau 2 haut : outils (état design) ── */
.mob-n2-tools { width: 100%; border-bottom: 1px solid rgba(255,255,255,0.06); }
.mob-footer__tools {
  display: flex;
  overflow-x: auto;
  gap: 0;
  padding: 6px 8px;
  scrollbar-width: none;
}
.mob-footer__tools::-webkit-scrollbar { display: none; }

/* ── Niveau 1 bas : barre navigation + valider ── */
.mob-footer__n1 {
  display: flex;
  align-items: stretch;
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  min-height: 68px;
}

/* Étapes (état steps) */
.mob-n1-steps {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.mob-n1-steps::-webkit-scrollbar { display: none; }
.mob-step-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 28px;
  background: none;
  border: none;
  border-radius: 10px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.mob-step-btn i { font-size: 24px; }
.mob-step-btn.is-active,
.mob-step-btn:hover { background: rgba(255,255,255,0.08); color: #1abc9c; }

/* Retour (état design) */
.mob-n1-tools { flex: 1; display: flex; align-items: stretch; }
.mob-back-btn {
  width: 68px;
  align-self: stretch;
  padding: 0;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.08);
  background: transparent;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  transition: color .15s;
}
.mob-back-btn i { font-size: 16px; }
.mob-back-btn:hover { color: #fff; }

/* Valider (toujours à droite du N1) */
.mob-validate-btn {
  width: 68px;
  align-self: stretch;
  border-radius: 0;
  padding: 0;
  background: #1abc9c;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
.mob-validate-btn:hover { opacity: 0.88; }

/* Mode clair VZH */
[data-theme="light"] .mob-vzh-bar { background: rgba(0,0,0,0.02); border-color: rgba(0,0,0,0.07); }
[data-theme="light"] .mob-vzh-btn { color: #6c7873; }
[data-theme="light"] .mob-vzh-btn:not([disabled]):hover,
[data-theme="light"] .mob-vzh-btn.is-active { color: #0e9c80; }
[data-theme="light"] .mob-vzh-sep { background: rgba(0,0,0,0.08); }
[data-theme="light"] .mob-n2-steps { border-color: rgba(0,0,0,0.06); color: rgba(0,0,0,0.7); }
[data-theme="light"] .mob-n2-tools { border-color: rgba(0,0,0,0.06); }
[data-theme="light"] .mob-footer__n1 { border-color: rgba(0,0,0,0.07); }
[data-theme="light"] .mob-back-btn { border-right-color: rgba(0,0,0,0.08); color: rgba(0,0,0,0.4); }
[data-theme="light"] .mob-back-btn:hover { color: #000; }
[data-theme="light"] .mob-validate-btn { background: #2c3b37; }
