/* ==========================================================================
   Modern Layer Popup System (Design Tokens & WCAG 2.2 Compliant)
   OpTheme Decoupled Modal Component
   ========================================================================== */

.op-modal-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10500;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    text-align: center;
    outline: 0;
}

/* Vertical Centering Anchor (Ghost Element) */
.op-modal-backdrop::before {
    content: '';
    display: inline-block;
    height: 100%;
    vertical-align: middle;
    margin-right: -4px;
}

.op-modal-dim {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 10501;
}

.op-modal-dialog {
    display: inline-block;
    vertical-align: middle;
    position: relative;
    width: calc(100% - 32px);
    max-width: 440px; /* 디자이너 권장 슬림 황금비율 */
    margin: 24px auto;
    text-align: left;
    z-index: 10502;
    pointer-events: auto;
    box-sizing: border-box;
}

/* Floating Modal Card */
.pop-layer.op-modal-card {
    position: relative !important;
    display: block !important;
    width: 100% !important;
    max-width: 440px !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 0 auto !important;
    padding: 0 !important;
    background-color: var(--op-surface, #ffffff) !important;
    color: var(--op-text, #333333) !important;
    border-radius: 14px !important;
    border: 1px solid var(--op-border, #e2e8f0) !important;
    box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.25), 0 10px 12px -5px rgba(0, 0, 0, 0.08) !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    animation: opModalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes opModalPop {
    0% {
        opacity: 0;
        transform: scale(0.94) translateY(10px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Modal Header Bar (100% Full Width Strip) */
.op-modal-header {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 14px 18px !important;
    margin: 0 !important;
    border: none !important;
    border-bottom: 1px solid var(--op-border-light, #edf2f7) !important;
    background-color: var(--op-surface-muted, #f8fafc) !important;
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

.op-modal-title-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.op-modal-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 5px;
    letter-spacing: -0.2px;
    white-space: nowrap;
}

.badge-partner {
    background-color: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.badge-notice {
    background-color: #ecfdf5;
    color: #059669;
    border: 1px solid #a7f3d0;
}

.badge-event {
    background-color: #fff7ed;
    color: #ea580c;
    border: 1px solid #fed7aa;
}

.op-modal-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--op-text, #1e293b);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.op-modal-btn-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--op-text-muted, #64748b);
    padding: 6px;
    margin: -4px -6px -4px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
    line-height: 1;
}

.op-modal-btn-close:hover {
    background-color: rgba(0, 0, 0, 0.06);
    color: var(--op-text, #0f172a);
}

.op-modal-btn-close:focus-visible {
    outline: 2px solid var(--op-primary, #3dbf62);
    outline-offset: 2px;
}

/* Modal Body (Natural Height & Scroll Guard) */
.op-modal-body {
    width: 100% !important;
    padding: 22px 22px !important;
    margin: 0 !important;
    max-height: calc(85vh - 120px) !important;
    overflow-y: auto !important;
    font-size: 14.5px !important;
    line-height: 1.65 !important;
    color: var(--op-text, #334155) !important;
    word-break: break-word !important;
    box-sizing: border-box !important;
    text-align: left !important;
}

/* Custom Slim Scrollbar */
.op-modal-body::-webkit-scrollbar {
    width: 5px;
}

.op-modal-body::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.op-modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.op-modal-body a {
    color: var(--op-link, #2563eb);
    text-decoration: underline;
    word-break: break-all;
}

.op-modal-body a:hover {
    color: var(--op-link-hover, #1d4ed8);
}

/* Soften Harsh Red Font Tags inside popup content */
.op-modal-content font[color="red"],
.op-modal-content font[color="#ff0000"],
.op-modal-content font[color="RED"] {
    color: #e11d48 !important; /* 모던 로즈 크림슨 액센트 */
    font-weight: 700;
}

/* Modal Footer Bar (100% Full Width Strip) */
.op-modal-footer {
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 11px 18px !important;
    margin: 0 !important;
    border: none !important;
    border-top: 1px solid var(--op-border-light, #edf2f7) !important;
    background-color: var(--op-surface-muted, #f8fafc) !important;
    border-radius: 0 !important;
    gap: 12px !important;
    box-sizing: border-box !important;
}

.op-modal-btn-today {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: var(--op-text-muted, #64748b);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    margin: -4px 0 -4px -6px;
    border-radius: 6px;
    transition: color 0.15s ease, background-color 0.15s ease;
    user-select: none;
    min-height: 38px;
    text-decoration: none;
}

.op-modal-btn-today svg {
    color: var(--op-text-muted, #64748b);
    transition: color 0.15s ease, transform 0.15s ease;
    flex-shrink: 0;
}

.op-modal-btn-today:hover {
    color: var(--op-text, #1e293b);
    background-color: rgba(0, 0, 0, 0.05);
}

.op-modal-btn-today:hover svg {
    color: var(--op-primary, #3dbf62);
    transform: scale(1.1);
}

.op-modal-btn-today:active {
    transform: scale(0.97);
}

.op-modal-btn-today:focus-visible {
    outline: 2px solid var(--op-primary, #3dbf62);
    outline-offset: 2px;
}

.op-modal-check-today {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: var(--op-text-muted, #64748b);
    cursor: pointer;
    user-select: none;
    margin: 0;
    min-height: 40px; /* WCAG 2.2 AA 터치 타깃 */
}

.op-modal-check-today input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--op-primary, #3dbf62);
}

.op-modal-btn-confirm {
    min-height: 36px;
    min-width: 68px;
    padding: 0 18px;
    background-color: var(--op-primary, #3dbf62);
    color: #ffffff !important;
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background-color 0.15s, transform 0.1s;
}

.op-modal-btn-confirm:hover {
    background-color: var(--op-primary-dark, #2f9a4f);
}

.op-modal-btn-confirm:active {
    transform: scale(0.97);
}

.op-modal-btn-confirm:focus-visible {
    outline: 2px solid var(--op-primary, #3dbf62);
    outline-offset: 2px;
}

/* ==========================================================================
   Dark Mode Pairings
   ========================================================================== */
html.theme-dark .pop-layer.op-modal-card,
body.theme-dark .pop-layer.op-modal-card,
body[data-theme="dark"] .pop-layer.op-modal-card {
    background-color: #1e2430 !important;
    border-color: #334155 !important;
    color: #f1f5f9 !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6) !important;
}

html.theme-dark .op-modal-header,
html.theme-dark .op-modal-footer,
body.theme-dark .op-modal-header,
body.theme-dark .op-modal-footer,
body[data-theme="dark"] .op-modal-header,
body[data-theme="dark"] .op-modal-footer {
    background-color: #151b23 !important;
    border-color: #2e3846 !important;
}

html.theme-dark .op-modal-title,
body.theme-dark .op-modal-title,
body[data-theme="dark"] .op-modal-title {
    color: #f8fafc !important;
}

html.theme-dark .op-modal-body,
body.theme-dark .op-modal-body,
body[data-theme="dark"] .op-modal-body {
    color: #cbd5e1 !important;
}

html.theme-dark .op-modal-body::-webkit-scrollbar-thumb,
body.theme-dark .op-modal-body::-webkit-scrollbar-thumb,
body[data-theme="dark"] .op-modal-body::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2) !important;
}

html.theme-dark .op-modal-check-today,
body.theme-dark .op-modal-check-today,
body[data-theme="dark"] .op-modal-check-today {
    color: #94a3b8 !important;
}

html.theme-dark .op-modal-btn-today,
body.theme-dark .op-modal-btn-today,
body[data-theme="dark"] .op-modal-btn-today {
    color: #94a3b8 !important;
}

html.theme-dark .op-modal-btn-today svg,
body.theme-dark .op-modal-btn-today svg,
body[data-theme="dark"] .op-modal-btn-today svg {
    color: #94a3b8 !important;
}

html.theme-dark .op-modal-btn-today:hover,
body.theme-dark .op-modal-btn-today:hover,
body[data-theme="dark"] .op-modal-btn-today:hover {
    color: #f1f5f9 !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
}

html.theme-dark .op-modal-btn-today:hover svg,
body.theme-dark .op-modal-btn-today:hover svg,
body[data-theme="dark"] .op-modal-btn-today:hover svg {
    color: var(--op-primary, #3dbf62) !important;
}

html.theme-dark .op-modal-btn-close,
body.theme-dark .op-modal-btn-close,
body[data-theme="dark"] .op-modal-btn-close {
    color: #94a3b8 !important;
}

html.theme-dark .op-modal-btn-close:hover,
body.theme-dark .op-modal-btn-close:hover,
body[data-theme="dark"] .op-modal-btn-close:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #f8fafc !important;
}

/* ==========================================================================
   Mobile Responsiveness
   ========================================================================== */
@media (max-width: 625px) {
    .op-modal-dialog {
        width: calc(100% - 24px);
        margin: 16px auto;
    }
    .op-modal-header {
        padding: 12px 16px !important;
    }
    .op-modal-body {
        padding: 18px 16px !important;
        font-size: 14px !important;
        line-height: 1.6 !important;
    }
    .op-modal-footer {
        padding: 10px 16px !important;
    }
}
