/* ========================================
   09) MODAL
======================================== */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(20, 24, 28, 0.58);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 18px 12px 22px;
    overflow-y: auto;
    overflow-x: hidden;
    text-align: center;
}

.modal-overlay.show {
    display: block;
}

.modal-panel {
    width: min(92vw, 760px);
    max-height: calc(100dvh - 24px);
    margin: auto;
    padding: 10px;
    border-radius: 20px;
    background: #f6f5f2;
    box-shadow: 0 24px 60px rgba(0,0,0,0.22);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
}

.modal-panel-summary {
    width: auto;
    max-width: 96vw;
    max-height: calc(100dvh - 24px);
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.modal-panel-layout {
    width: auto;
    max-width: 96vw;
    max-height: calc(100dvh - 24px);
    padding: 16px 16px 20px;
    background: rgba(246, 245, 242, 0.96);
    box-shadow: 0 22px 48px rgba(0,0,0,0.22);
    border-radius: 24px;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.modal-img-layout {
    width: auto;
    max-width: min(92vw, 720px);
    max-height: 72vh;
    height: auto;
    display: block;
    margin: 0 auto 14px;
    object-fit: contain;
    border-radius: 18px;
    background: transparent;
    box-shadow: none;
}

.layout-preview-caption {
    max-width: 92vw;
    margin: 0 auto 14px;
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    line-height: 1.5;
    white-space: nowrap;
    text-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

@media (max-width: 640px) {
    .modal-overlay {
        padding: 14px 10px 18px;
    }

    .modal-img-layout {
        max-width: 94vw;
        max-height: 68vh;
        margin-bottom: 12px;
        border-radius: 18px;
    }

    .layout-preview-caption {
        max-width: 94vw;
        font-size: 14px;
        line-height: 1.35;
        white-space: nowrap;
    }

    .modal-close {
        max-width: 280px;
        min-height: 48px;
        font-size: 16px;
    }
}

.modal-img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
}

.modal-img-summary {
    width: auto;
    max-width: 96vw;
    max-height: calc(100dvh - 92px);
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 18px;
    background: transparent;
}

.modal-close {
    width: 100%;
    max-width: 320px;
    min-height: 50px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #f7c978 0%, #f4b74a 100%);
    color: #fff;
    font-family: 'Kanit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow:
      0 10px 22px rgba(244, 183, 74, 0.22),
      0 4px 10px rgba(17, 24, 39, 0.06);
    transition:
      transform 0.18s ease,
      box-shadow 0.22s ease,
      filter 0.22s ease,
      background 0.22s ease;
    -webkit-tap-highlight-color: transparent;
}

.modal-close:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow:
      0 14px 28px rgba(244, 183, 74, 0.26),
      0 6px 14px rgba(17, 24, 39, 0.08);
}

.modal-close:active {
    transform: scale(0.98);
    box-shadow:
      0 6px 14px rgba(244, 183, 74, 0.18),
      0 3px 8px rgba(17, 24, 39, 0.05);
}

body.modal-open {
    overflow: hidden !important;
}

#layoutModal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(20, 24, 28, 0.58);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    overflow: auto;
    padding: 24px 12px;
    text-align: center;
}

#layoutModal.show {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#layoutModal .modal-panel-layout {
    width: auto;
    max-width: 96vw;
    max-height: calc(100dvh - 40px);
    padding: 16px 16px 20px;
    background: rgba(246, 245, 242, 0.96);
    box-shadow: 0 22px 48px rgba(0,0,0,0.22);
    border-radius: 24px;
    border: 1px solid rgba(255,255,255,0.38);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin: auto;
}

#layoutModal .modal-img-layout {
    width: auto;
    max-width: min(92vw, 720px);
    max-height: 68vh;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
    border-radius: 18px;
    background: transparent;
    box-shadow: none;
}

#layoutModal .layout-preview-caption {
    max-width: 92vw;
    margin: 0;
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    line-height: 1.45;
    white-space: nowrap;
    text-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

#layoutModal .modal-close {
    width: 100%;
    max-width: 320px;
    min-height: 50px;
    margin-top: 10px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(180deg, #f7c978 0%, #f4b74a 100%);
    color: #fff;
    font-family: 'Kanit', sans-serif;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    box-shadow:
      0 10px 22px rgba(244, 183, 74, 0.22),
      0 4px 10px rgba(17, 24, 39, 0.06);
    transition:
      transform 0.18s ease,
      box-shadow 0.22s ease,
      filter 0.22s ease;
    -webkit-tap-highlight-color: transparent;
}

#layoutModal .modal-close:hover {
    transform: translateY(-1px);
    filter: brightness(1.02);
    box-shadow:
      0 14px 28px rgba(244, 183, 74, 0.26),
      0 6px 14px rgba(17, 24, 39, 0.08);
}

#layoutModal .modal-close:active {
    transform: scale(0.98);
    box-shadow:
      0 6px 14px rgba(244, 183, 74, 0.18),
      0 3px 8px rgba(17, 24, 39, 0.05);
}

@media (max-width: 640px) {
    #layoutModal {
        padding: 14px 10px 18px;
    }

    #layoutModal .modal-panel-layout {
        max-width: 94vw;
        padding: 14px 14px 18px;
        border-radius: 22px;
        gap: 10px;
    }

    #layoutModal .modal-img-layout {
        max-width: 94vw;
        max-height: 66vh;
        border-radius: 18px;
    }

    #layoutModal .layout-preview-caption {
        max-width: 94vw;
        font-size: 14px;
        line-height: 1.35;
        white-space: nowrap;
    }

    #layoutModal .modal-close {
        max-width: 280px;
        min-height: 48px;
        font-size: 16px;
    }
}
