/* Mise en page commune pour téléphones et tablettes. */

/* Ancien composant : style_header.css */
@media (min-width: 821px) and (max-width: 1050px) {
    body.vk-theme-v2 #topbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 16px;
    }

    body.vk-theme-v2 #topbar .left,
    body.vk-theme-v2 #topbar .right {
        min-width: 0;
        flex-wrap: wrap;
    }

    body.vk-theme-v2 #topbar .center {
        grid-column: 1 / -1;
        grid-row: 2;
        min-width: 0;
    }
}

@media (max-width:768px){

    .logo img{

        width:38px;
        height:38px;
    }
}


/* Ancien composant : style_perso.css */
@media (max-width: 780px) {

    .perso-page {
        padding: 30px 12px;
    }

    .panel-header {
        padding: 20px 14px;
    }

    .perso-header {
        flex-direction: column;
        gap: 14px;
    }

    .perso-icone,
    .perso-symbole {
        width: 118px;
    }

    .perso-header h1 {
        font-size: 34px !important;
        letter-spacing: 0.045em !important;
    }

    .perso-header h2 {
        font-size: 11px !important;
        letter-spacing: 0.14em !important;
    }

    .perso-page th,
    .perso-page td {
        display: block;
        width: 100%;
        box-sizing: border-box;
    }

    .perso-page th {
        border-bottom: none;
        padding-bottom: 7px;
    }

    .perso-page td {
        padding-top: 7px;
    }
}


/* Ancien composant : style_vip.css */
@media (max-width: 768px) {

    /* Le conteneur principal passe en colonne */
    /* Les colonnes VIP passent sous leur navigation sans casser les autres pages. */
    .main-auth-zone div:has(> .vip-sidebar) {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* SIDEBAR : pleine largeur, marges réduites */
    .vip-sidebar {
        width: 100% !important;
        margin: 10px 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
    }

    /* PANELS : pleine largeur */
    .vip-panel {
        width: 100% !important;
        margin: 10px 0 20px 0 !important;
        padding: 15px !important;
        box-sizing: border-box;
    }

    /* TITRES : plus petits */
    .vip-title-section,
    .vip-title {
        font-size: 18px !important;
        margin-bottom: 15px !important;
        text-align: center !important;
    }

    /* BOUTONS : largeur totale */
    .vip-link {
        width: 100% !important;
        padding: 12px !important;
        font-size: 15px !important;
        margin: 8px 0 !important;
        box-sizing: border-box;
    }

    /* Bouton envoyer centré */
    /* Inputs : largeur totale */
    .vip-panel input[type="text"],
    .vip-panel input[type="number"],
    .vip-panel textarea {
        width: 100% !important;
        padding: 10px !important;
        margin-bottom: 10px !important;
        box-sizing: border-box !important;
    }

    /* Tableaux scrollables */
    .vip-table {
        display: block !important;
        overflow-x: auto !important;
        white-space: nowrap !important;
    }
}

@media (max-width: 768px) {

    .folders-container .perso-btn {
        height: auto !important;
        min-height: 0 !important;
        padding: 10px 5px 18px 5px !important;
        justify-content: flex-start !important;
        overflow: visible !important;
    }

    .folders-container .perso-btn img {
        max-width: 150px !important;
        width: 150px !important;
        height: auto !important;
        margin-bottom: 10px !important;
        display: block !important;
    }

    .folders-container .perso-btn div {
        position: relative !important;
        z-index: 2 !important;
        display: block !important;
        line-height: 1.25 !important;
        font-size: 1rem !important;
        white-space: normal !important;
        word-break: normal !important;
    }
}


/* Ancien composant : portable.css */
@media (max-width: 768px) {

  /* ===========================
     BODY
  ============================ */
  body {
    background-repeat: repeat;
  }

  /* ===========================
     HEADER MOBILE
  ============================ */
  #topbar {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    padding: 10px 0;
    background: rgba(0,0,0,0.5);
  }

  #topbar .left,
  #topbar .right {
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 15px;
  }

  #topbar .center {
    width: 100%;
    max-width: 100%;
    text-align: center;
  }

  #topbar .logo {
    font-size: 1.8rem;
  }

  /* ===========================
     NEWS CAROUSEL MOBILE
  ============================ */
  .news-carousel {
    position: relative;
    height: 45px;
    overflow: hidden;
  }

  .news-item {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    transition: opacity 0.4s linear;
  }

  .news-visible {
    opacity: 1;
  }

  /* ===========================
     MENU MOBILE
  ============================ */
  #menu-button {
    display: block;
    background: #111;
    color: #eee;
    padding: 12px;
    text-align: center;
    font-size: 1.3rem;
    cursor: pointer;
    border: 1px solid #333;
    margin: 10px auto;
    width: 100%;
  }

  #menu-toggle {
    display: none;
  }

  #menu {
    display: none;
    flex-direction: column;
    gap: 12px;
    text-align: center;
    padding: 10px 0;
    background: rgba(10,10,10,0.8);
    border-top: 1px solid #222;
  }

  #menu-toggle:checked + #menu {
    display: flex;
  }

  #menu a {
    padding: 10px 0;
    width: 100%;
    font-size: 1.1rem;
  }

  /* ===========================
     PERSONNAGES — FIX MOBILE
     Compatible avec le nouveau style_perso.css
  ============================ */
  .perso-page {
    padding: 30px 12px;
  }

  .perso-page .page {
    width: 100%;
    max-width: 100%;
    padding: 0;
    margin: 0 auto;
  }

  .panel-header {
    padding: 20px 14px;
    margin-bottom: 30px;
    border-radius: 18px;
  }

  .perso-header {
    flex-direction: column;
    text-align: center;
    gap: 14px;
  }

  .perso-icone,
  .perso-symbole {
    width: 118px;
    height: auto;
  }

  .perso-header h1 {
    font-size: 34px !important;
    line-height: 1.08 !important;
    letter-spacing: 0.045em !important;
  }

  .perso-header h2 {
    font-size: 11px !important;
    letter-spacing: 0.14em !important;
  }

  .perso-page .panel {
    margin-bottom: 24px;
    border-radius: 16px;
  }

  .perso-page .panel-title {
    padding: 14px 16px;
    font-size: 13px;
    letter-spacing: 0.12em;
  }

  .perso-page table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
  }

  .perso-page th,
  .perso-page td {
    display: block;
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.55;
    word-break: break-word;
  }

  .perso-page th {
    border-bottom: none;
    padding-bottom: 6px;
  }

  .perso-page td {
    padding-top: 6px;
  }

  .table-aura th,
  .table-aura td {
    font-size: 12px !important;
    padding: 9px 12px !important;
    line-height: 1.45 !important;
  }

  .table-aura th {
    white-space: normal !important;
  }

  .table-aura td {
    white-space: normal !important;
    word-break: break-word;
  }

  .perso-table-icon {
    max-width: 120px;
    max-height: 155px;
  }

  /* ===========================
     COMMANDEMENTS
  ============================ */
  .cmd-page {
    margin: 0;
    padding: 0;
    background: #000;
    text-align: center;
  }

  .cmd-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  .cmd-parchment {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
  }

  /* ===========================
     PAGE DRAKHAL'NUR
  ============================ */
  .dictionnaire {
    padding: 10px;
  }

  .dictionnaire h1 {
    font-size: 1.8rem;
  }

  .dictionnaire table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
  }

  .dictionnaire th,
  .dictionnaire td {
    padding: 8px;
    font-size: 12px;
    word-break: break-word;
  }

  #RUNES td:first-child {
    font-size: 1.2rem;
    text-align: center;
  }

  /* ===========================
     AUTRES PAGES
  ============================ */
  .form {
    width: min(100%, 420px);
    max-width: 100%;
    margin: 16px auto;
  }

  .romans-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .reader {
    width: 100%;
    margin: 0;
  }

  .reader iframe {
    height: calc(100vh - 120px);
    -webkit-overflow-scrolling: touch;
    overflow-y: scroll;
  }

  .folder-block {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 100%;
  }

  .gallery-section {
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  }

  .intro {
    width: auto;
    margin: 0 auto;
    padding: 0 1rem;
    font-size: 1rem;
    text-align: left;
  }

  .intro_head {
    font-size: 1.5rem;
    text-align: center;
    padding: 0 1rem;
  }

  .intro_feet {
    margin: 2rem 1rem;
    font-size: 0.9rem;
  }

  .bt {
    display: block;
    width: 100%;
    text-align: center;
    margin: 10px 0 !important;
    padding: 12px 0;
  }

  footer {
    font-size: 0.8rem;
  }
}


/* Ancien composant : style_admin.css */
@media (max-width: 768px) {

    .admin-layout {
        display: block;
        margin: 10px 0;
        padding: 0 10px;
        width: 100%;
        box-sizing: border-box;
    }

    body.vk-appearance .admin-layout {
        max-width: 100%;
        margin: 12px auto;
    }

    .admin-sidebar {
        width: 100%;
        margin-bottom: 20px;
        padding: 15px;
    }

    .admin-content {
        width: 100%;
        padding: 15px;
        margin: 0;
    }

    .admin-content h1 {
        font-size: 20px;
        margin-bottom: 20px;
    }

    .admin-textarea {
        height: 220px;
        font-size: 14px;
    }

    .admin-save {
        width: 100%;
        max-width: 260px;
        padding: 12px;
        font-size: 16px;
    }

    .admin-link {
        width: 100%;
        padding: 12px;
        font-size: 15px;
    }

    .admin-block {
        padding: 15px;
        margin-bottom: 20px;
    }

    /* TABLEAUX */
    .admin-table-wrapper {
        border: 1px solid #550000;
    }

    .admin-table {
        min-width: 900px;
    }

    .admin-table th,
    .admin-table td {
        padding: 8px;
        font-size: 14px;
        white-space: nowrap;
    }

    .admin-table td.ua-col {
        max-width: 250px;
        white-space: normal;
        word-break: break-word;
    }
    /* Seul le tableau défile : le reste du panneau reste correctement cadré. */
    .admin-content,
    .admin-block {
        min-width: 0;
        max-width: 100%;
        overflow: visible;
    }

    .admin-table-wrapper {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* On empêche la compression */
    .admin-table {
        width: max-content !important;
        table-layout: auto !important;
        white-space: nowrap !important;
    }

    /* On garantit que les colonnes existent */
    .admin-table th,
    .admin-table td {
        display: table-cell !important;
        white-space: nowrap !important;
    }
}


/* Ancien composant : style_mon_compte.css */
@media (max-width: 768px) {

    .moncompte-container {
        margin: 20px auto;
        padding: 18px;
        max-width: 95%;
    }

    #editForm {
        padding: 15px;
    }

    #editForm input,
    #editForm select {
        padding: 12px;
        font-size: 16px;
    }

    #editForm .pass-field input {
        height: 48px;
        padding-right: 55px !important;
        font-size: 16px;
        width: 100% !important;
        max-width: 100% !important;
    }

    .pass-toggle {
        width: 40px;
        height: 40px;
        right: 6px;
        font-size: 20px;
    }

    .btn-toggle,
    #editForm button[type="submit"] {
        width: 100%;
        text-align: center;
        padding: 14px;
        font-size: 16px;
    }
}


/* Ancien composant : style_hors-serie.css */
@media (max-width: 620px) {

.hors-serie-page {
    padding-top: 30px;
}

.hs-card {
    min-height: auto;
}

.hs-card-top {
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 20px;
}

.hs-view-gallery {
    max-width: 100%;
}

.hs-page-img img {
    max-height: none;
}
}

/* Ajustements complémentaires, sans règles globales sur les formulaires VIP. */
@media (max-width: 900px) {
    body .main-auth-zone { min-width: 0; width: 100%; max-width: 100%; }
    body :is(.admin-layout,.admin-content,.vip-panel,.vip-sidebar,.login-box,.form,.vk-home,.perso-page,.moncompte-container,.romans-grid,.folders-container,.gallery-section) {
        min-width: 0;
        max-width: 100%;
    }
    body :is(.admin-table-wrapper,.vip-table-wrapper,.data-sql-table-wrapper) {
        max-width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    body img, body video, body iframe { max-width: 100%; }
}

@media (max-width: 768px) {
    #menu-button {
        width: calc(100% - 24px);
        margin: 8px auto;
        min-height: 48px;
        border-color: var(--theme-outline,var(--v3-border,#5c2723));
        border-radius: var(--vk-nav-radius,4px);
        background: var(--extreme-nav,var(--v3-coal,#211b1b));
        color: var(--extreme-ink,var(--v3-parchment,#eee4de));
    }
    /* La case à cocher reste utilisable au clavier. */
    #menu-toggle {
        display: block !important;
        position: absolute;
        width: 1px;
        height: 1px;
        opacity: 0;
        clip-path: inset(50%);
    }
    #menu-button:has(+ #menu-toggle:focus-visible) {
        outline: 3px solid var(--v3-gold,#c2a89c);
        outline-offset: 2px;
    }
    #menu {
        width: 100%;
        gap: 3px;
        padding: 8px 12px 12px;
        overflow-x: clip;
    }
    #menu a { min-height: 46px; align-content: center; overflow-wrap: anywhere; }
    body .folders-container { gap: 10px; }
    body .folders-container > .vk-gallery-tile { min-width: 0; }
    body :is(input,select,textarea) { font-size: max(16px, 1em); }
}

@media (max-width: 480px) {
    body #topbar .right { justify-content: center; gap: 7px; }
    body .main-auth-zone { padding-inline: 8px; }
    body :is(.admin-content,.vip-panel,.form,.login-box) { padding-inline: min(4vw,16px); }
    body .gallery-section > img[data-full] { height: 150px; }
    body .folders-container > .vk-gallery-tile .vk-gallery-icon { max-width: 100px; }
}

/* L'ancienne marge de l'introduction élargissait la page sur tablette. */
@media (max-width: 1250px) {
    body .intro {
        width: min(100%, 960px);
        max-width: 100%;
        margin-inline: auto;
        padding-inline: clamp(12px, 3vw, 24px);
    }
}

/* Espace VIP : navigation compacte et contenu à la largeur de l'écran. */
@media (max-width: 900px) {
    body .main-auth-zone :is(
        [data-vk-s="ac89d51305fe"],
        .vip-bookmarks-layout,
        .hors-serie-vip-layout,
        .resume-vip-layout
    ) {
        display: block !important;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    body .main-auth-zone :is(
        [data-vk-s="ac89d51305fe"],
        .vip-bookmarks-layout,
        .hors-serie-vip-layout,
        .resume-vip-layout
    ) > div {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    body .main-auth-zone .vip-sidebar {
        display: block;
        width: 100% !important;
        max-width: 100%;
        margin: 0 0 18px !important;
        padding: 10px !important;
        box-sizing: border-box;
    }

    body .main-auth-zone .vip-sidebar > summary {
        display: block;
        position: relative;
        list-style: none;
        min-height: 44px;
        margin: 0 !important;
        padding: 10px 32px 10px 8px;
        box-sizing: border-box;
        font-size: 1rem !important;
        line-height: 1.35;
        cursor: pointer;
    }

    body .main-auth-zone .vip-sidebar > summary::-webkit-details-marker {
        display: none;
    }

    body .main-auth-zone .vip-sidebar > summary::after {
        content: '▾';
        position: absolute;
        right: 8px;
        top: 50%;
        transform: translateY(-50%);
    }

    body .main-auth-zone .vip-sidebar[open] > summary::after {
        content: '▴';
    }

    body .main-auth-zone .vip-sidebar:not([open]) .vip-nav {
        display: none;
    }

    body .main-auth-zone .vip-sidebar[open] .vip-nav {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding-top: 10px;
    }

    body .main-auth-zone .vip-sidebar .vip-link {
        display: block;
        width: 100% !important;
        min-width: 0;
        min-height: 44px;
        margin: 0 !important;
        padding: 11px 12px !important;
        box-sizing: border-box;
        font-size: .92rem !important;
        line-height: 1.35;
        text-align: left;
        overflow-wrap: break-word;
    }

    body .main-auth-zone .vip-sidebar .vip-link-chroniques {
        gap: 5px;
    }

    body .main-auth-zone .vip-sidebar .vip-link-chroniques > span:first-child {
        min-width: 0;
    }

    body .main-auth-zone .vip-panel,
    body .main-auth-zone .vip-ann-card {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
        overflow-wrap: anywhere;
    }

    body .main-auth-zone .vip-panel {
        margin: 0 0 16px !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body .main-auth-zone .vip-table {
        display: table !important;
        width: max-content;
        min-width: 100%;
        max-width: none;
        overflow: visible !important;
        white-space: normal !important;
    }

    body .main-auth-zone .vip-table :is(th, td) {
        max-width: 260px;
        overflow-wrap: anywhere;
    }

    body .main-auth-zone :is(.vip-bookmarks-table-wrap, .vip-ann-wrap, .resume-vip-main, .hors-serie-vip-main) {
        min-width: 0;
        max-width: 100%;
    }

    body .main-auth-zone .vip-ann-filters > div {
        min-width: 0;
    }
}

@media (max-width: 620px) {
    body .main-auth-zone .vip-panel,
    body .main-auth-zone .vip-ann-card {
        padding: 12px !important;
    }

    body .main-auth-zone .vip-title-section,
    body .main-auth-zone [data-vk-s="6253876a649a"] h1 {
        font-size: clamp(1.3rem, 6vw, 1.8rem) !important;
        line-height: 1.2;
        overflow-wrap: anywhere;
    }
}
