/* #region 1: ORTAK MODAL KABUĞU */
.auth-modal,
.image-cropper-modal,
.tag-picker-modal,
.tops-setup-modal,
.tops-search-modal,
.block-delete-modal,
.trophy-picker-modal,
.theme-market-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--modal-pad);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--modal-dur-close, 0.14s) ease, visibility 0s linear var(--modal-dur-close, 0.14s);
}

:is(.auth-modal, .image-cropper-modal, .tag-picker-modal,
    .tops-setup-modal, .tops-search-modal, .block-delete-modal, .trophy-picker-modal,
    .theme-market-modal).is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--modal-dur, 0.2s) ease, visibility 0s linear 0s;
}
/* #endregion */

/* #region 2: BACKDROP */
.auth-modal-backdrop,
.cropper-backdrop,
.tag-picker-backdrop,
.tops-modal-backdrop,
.block-delete-backdrop,
.trophy-picker-backdrop,
.theme-market-backdrop {
    position: absolute;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(var(--modal-blur));
    -webkit-backdrop-filter: blur(var(--modal-blur));
}
/* #endregion */

/* #region 3: PANEL */
.auth-modal-box,
.cropper-box,
.section-picker-panel,
.tag-picker-panel,
.tops-modal-panel,
.block-delete-panel,
.trophy-picker-panel,
.theme-market-box {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: var(--modal-w, var(--modal-w-md));
    max-height: 88vh;
    max-height: 88dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
    background: var(--modal-bg);
    border: var(--modal-border);
    border-radius: var(--radius-modal);
    box-shadow: var(--modal-shadow);
    transform: scale(0.96) translateY(8px);
    transition: transform var(--modal-dur-close, 0.14s) ease;
    animation: none; /* eski modalScaleIn / modalPop iptal */
}

/* Cropper modalı boyutlandırma hesaplama hatasını önlemek için ölçek dönüşümünden muaf tutulur */
.cropper-box {
    transform: translateY(8px);
}

:is(.auth-modal, .image-cropper-modal, .tag-picker-modal,
    .tops-setup-modal, .tops-search-modal, .block-delete-modal, .trophy-picker-modal,
    .theme-market-modal).is-open
:is(.auth-modal-box, .cropper-box, .section-picker-panel,
    .tag-picker-panel, .tops-modal-panel, .block-delete-panel, .trophy-picker-panel,
    .theme-market-box) {
    transform: none;
    transition: transform var(--modal-dur, 0.2s) var(--ease-spring);
}

/* Panel Genişlikleri */
.auth-modal-box       { --modal-w: min(400px, 92vw); }
.cropper-box          { --modal-w: var(--modal-w-lg); }
.section-picker-panel { --modal-w: var(--modal-w-lg); }
.tops-modal-panel     { --modal-w: var(--modal-w-lg); }
.tag-picker-panel     { --modal-w: var(--modal-w-md); }
.block-delete-panel   { --modal-w: var(--modal-w-sm); }
.trophy-picker-panel  { --modal-w: var(--modal-w-lg); }
.theme-market-box     { --modal-w: min(640px, 94vw); }

@media (max-width: 480px) {
    :root {
        --modal-pad: 12px;
    }
    
    .auth-modal-box,
    .cropper-box,
    .section-picker-panel,
    .tag-picker-panel,
    .tops-modal-panel,
    .block-delete-panel,
    .trophy-picker-panel,
    .theme-market-box {
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: 18px;
    }
}
/* #endregion */

/* #region 5: TEMA MARKETİ ÖZEL STİLLERİ */
.theme-market-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
}

.theme-market-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.theme-market-title {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.theme-market-close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.6rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
    transition: color 0.15s ease, transform 0.15s ease;
}

.theme-market-close-btn:hover {
    color: #ffffff;
    transform: scale(1.15);
}

.theme-market-content {
    padding: 18px;
}

.theme-market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

/* Tema Paket Kartı */
.theme-market-card {
    background: var(--bg-card-subtle);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-item, 14px);
    overflow: hidden;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    transition: transform 0.22s var(--ease-spring), border-color 0.2s ease, box-shadow 0.2s ease;
}

.theme-market-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 16px var(--accent-glow);
}

.theme-card-banner {
    width: 100%;
    height: 105px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(0, 0, 0, 0.4) 100%);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-soft);
}

.theme-card-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-card-banner-placeholder {
    font-size: 2.2rem;
    opacity: 0.85;
}

.theme-card-body {
    padding: 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 6px;
}

.theme-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.theme-card-name {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.theme-card-price {
    font-size: 0.82rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    background: rgba(59, 91, 219, 0.18);
    color: var(--accent-light, #748ffc);
    border: 1px solid rgba(59, 91, 219, 0.35);
}

.theme-card-price.is-free {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.35);
}

.theme-card-desc {
    font-size: 0.82rem;
    color: var(--text-tertiary);
    line-height: 1.4;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Detay Görünümü */
.theme-market-detail-view {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.theme-detail-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    transition: color 0.15s ease, transform 0.15s ease;
    align-self: flex-start;
}

.theme-detail-back-btn:hover {
    color: #ffffff;
    transform: translateX(-3px);
}

.theme-detail-hero {
    width: 100%;
    height: 160px;
    border-radius: var(--radius-item);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(0, 0, 0, 0.6) 100%);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-soft);
}

.theme-detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.theme-detail-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.theme-detail-title {
    font-size: 1.25rem;
    font-weight: 750;
    color: var(--text-primary);
    margin: 0;
}

.theme-detail-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin: 0;
}

.theme-detail-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.theme-detail-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--radius-btn, 12px);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.theme-detail-btn.is-buy {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.theme-detail-btn.is-buy:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.theme-detail-btn.is-apply {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
}

.theme-detail-btn.is-apply:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.theme-detail-btn.is-preview {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-highlight);
}

.theme-detail-btn.is-preview:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* #region 6: CANLI ÖNİZLEME YÜZEN BARI (LIVE PREVIEW BAR) */
.theme-preview-bar {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    z-index: var(--z-modal, 10000);
    width: auto;
    max-width: 90vw;
    background: rgba(15, 18, 28, 0.88);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-pill);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.6), 0 0 20px var(--accent-glow);
    padding: 8px 14px 8px 18px;
    animation: previewBarSlideUp 0.3s var(--ease-spring);
}

@keyframes previewBarSlideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.theme-preview-bar-inner {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-preview-bar-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.theme-preview-pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 10px #38bdf8;
    animation: previewDotPulse 1.8s infinite;
}

@keyframes previewDotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

.theme-preview-bar-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.theme-preview-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-preview-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.theme-preview-btn.is-cancel {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border-soft);
}

.theme-preview-btn.is-cancel:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #ffffff;
}

.theme-preview-btn.is-action {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.theme-preview-btn.is-action:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.theme-preview-btn.is-apply-action {
    background: #10b981;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}
/* #endregion */

/* #region 7: GÖRÜNÜM & TEMA DÜZENLEME MODALI (APPEARANCE MODAL) */
.theme-appearance-modal {
    position: fixed;
    inset: 0;
    z-index: var(--z-modal, 10000);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.theme-appearance-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    animation: modalBackdropFadeIn 0.22s ease;
}

.theme-appearance-box {
    position: relative;
    width: 100%;
    max-width: 480px;
    background: var(--bg-card, #12141c);
    border: 1px solid var(--border-highlight, rgba(255, 255, 255, 0.14));
    border-radius: var(--radius-modal, 20px);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: modalBoxPopIn 0.28s var(--ease-spring);
    display: flex;
    flex-direction: column;
}

.theme-appearance-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border-soft);
}

.theme-appearance-title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
}

.theme-appearance-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.theme-appearance-close-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.theme-appearance-close-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.08);
}

.theme-appearance-content {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    max-height: 65vh;
    overflow-y: auto;
}

.appearance-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.appearance-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.appearance-section-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.appearance-color-hex {
    font-family: var(--font-body, inherit);
    font-size: 0.82rem;
    color: var(--accent-color, var(--text-tertiary));
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: color 0.25s ease, text-shadow 0.25s ease;
    text-shadow: 0 0 10px var(--accent-glow, rgba(168, 85, 247, 0.4)), 0 0 20px color-mix(in oklch, var(--accent-color, #a855f7) 40%, transparent);
}

.appearance-color-hex.is-custom {
    font-family: var(--font-mono, monospace);
    letter-spacing: 0.02em;
    color: var(--text-tertiary);
    text-shadow: none;
}

/* Tema Seçim Kartları */
.appearance-theme-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.appearance-theme-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1.5px solid var(--border-soft);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.appearance-theme-card:hover {
    background: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.appearance-theme-card.is-selected {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--accent-color);
    box-shadow: 0 0 16px var(--accent-glow);
}

.appearance-card-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.appearance-card-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

.appearance-card-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.appearance-card-desc {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.appearance-card-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-color);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.6);
    transition: all 0.2s var(--ease-spring);
}

.appearance-theme-card.is-selected .appearance-card-check {
    opacity: 1;
    transform: scale(1);
}

/* Renk Paleti */
.appearance-color-palette {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.35);
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--border-soft);
}

.appearance-color-palette .color-swatch-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    outline: none;
    position: relative;
}

.appearance-color-palette .color-swatch-btn:hover {
    transform: scale(1.15);
}

.appearance-color-palette .color-swatch-btn.is-active {
    border-color: #ffffff;
    transform: scale(1.18);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* Footer Butonları */
.theme-appearance-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 22px;
    border-top: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.2);
}

.appearance-footer-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.appearance-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.appearance-btn.is-preview {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-soft);
}

.appearance-btn.is-preview:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.appearance-btn.is-cancel {
    background: transparent;
    color: var(--text-tertiary);
}

.appearance-btn.is-cancel:hover {
    color: var(--text-primary);
}

.appearance-btn.is-save {
    background: var(--accent-color);
    color: #ffffff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.appearance-btn.is-save:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.theme-preview-bar-hint {
    font-size: 0.74rem;
    color: var(--text-tertiary);
    font-weight: 500;
}
/* #endregion */

/* #region 4: KATMAN İSTİSNALARI + SCROLL KİLİDİ */
.tops-search-modal { z-index: var(--z-modal-stacked); }
.block-delete-modal { z-index: var(--z-confirm); }
.nook-toast         { z-index: var(--z-toast); }
.is-drag-clone      { z-index: var(--z-drag) !important; }

body:has(:is(.auth-modal, .image-cropper-modal, .tag-picker-modal,
             .tops-setup-modal, .tops-search-modal, .block-delete-modal, .trophy-picker-modal, .theme-appearance-modal).is-open) {
    overflow: hidden;
}
/* #endregion */
