/**
 * MC Skin Editor — Community styles (gallery, creators, modals, account bar)
 */

/* ------------------------------------------------------------ Shared */

.mcse-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    color: #1f2937;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, border-color .15s ease, transform .1s ease;
}

.mcse-btn:hover {
    background: #f3f4f6;
    color: #111827;
    text-decoration: none;
}

.mcse-btn:active {
    transform: translateY(1px);
}

.mcse-btn.mcse-primary {
    background: #16a34a;
    border-color: #15803d;
    color: #fff;
}

.mcse-btn.mcse-primary:hover {
    background: #15803d;
    color: #fff;
}

.mcse-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: #eef2ff;
    color: #4338ca;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .3px;
    white-space: nowrap;
}

.mcse-empty {
    padding: 40px 16px;
    text-align: center;
    color: #6b7280;
    grid-column: 1 / -1;
}

/* ------------------------------------------------------- Account bar */

.mcse-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.mcse-header .mcse-title {
    margin: 0;
    text-align: left;
}

.mcse-account-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mcse-account-user {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: #374151;
}

.mcse-account-user img {
    border-radius: 50%;
}

.mcse-account-link {
    background: none;
    border: none;
    padding: 4px 2px;
    color: #16a34a;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.mcse-account-link:hover {
    text-decoration: underline;
    color: #15803d;
}

/* ------------------------------------------------------------ Gallery */

.mcse-gallery {
    margin: 24px 0;
}

.mcse-gallery-title {
    margin: 0 0 16px;
}

.mcse-gallery-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.mcse-gallery-tabs {
    display: inline-flex;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.mcse-gallery-tab {
    border: none;
    background: transparent;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
    transition: background .15s ease, color .15s ease;
}

.mcse-gallery-tab:hover {
    color: #111827;
}

.mcse-gallery-tab.active {
    background: #fff;
    color: #16a34a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.mcse-gallery-filter {
    padding: 8px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
}

.mcse-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 16px;
}

.mcse-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: transform .15s ease, box-shadow .15s ease;
}

.mcse-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .1);
}

.mcse-card-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    border: none;
    padding: 16px 0 8px;
    background:
        linear-gradient(180deg, #dbeafe 0%, #eff6ff 60%, #f8fafc 100%);
    cursor: pointer;
}

.mcse-card-preview canvas {
    width: 96px;
    height: 192px;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .25));
    transition: transform .15s ease;
}

.mcse-card:hover .mcse-card-preview canvas {
    transform: scale(1.05);
}

.mcse-card-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px 14px;
}

.mcse-card-name {
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mcse-card-author {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: #6b7280;
    min-width: 0;
}

.mcse-card-author img {
    border-radius: 50%;
    flex-shrink: 0;
}

.mcse-card-author span:not(.mcse-badge) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mcse-card-author .mcse-badge {
    margin-left: auto;
}

.mcse-card-stats {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: #9ca3af;
}

.mcse-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 2px;
}

.mcse-card-actions .mcse-btn {
    flex: 1;
    padding: 7px 10px;
    font-size: 13px;
}

.mcse-gallery-footer {
    text-align: center;
    margin-top: 20px;
}

/* ----------------------------------------------------------- Creators */

.mcse-creators {
    margin: 24px 0;
}

.mcse-creators-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mcse-creator {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px 16px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
}

.mcse-creator-rank {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f3f4f6;
    color: #4b5563;
    font-weight: 800;
    flex-shrink: 0;
}

.mcse-creator-top:nth-child(1) .mcse-creator-rank { background: #fef3c7; color: #b45309; }
.mcse-creator-top:nth-child(2) .mcse-creator-rank { background: #e5e7eb; color: #374151; }
.mcse-creator-top:nth-child(3) .mcse-creator-rank { background: #ffedd5; color: #c2410c; }

.mcse-creator-avatar {
    border-radius: 50%;
    flex-shrink: 0;
}

.mcse-creator-name {
    font-weight: 700;
    color: #111827;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mcse-creator-stats {
    margin-left: auto;
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: #6b7280;
    flex-shrink: 0;
}

/* ------------------------------------------------------------- Modals */

body.mcse-modal-open {
    overflow: hidden;
}

.mcse-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.mcse-modal[hidden] {
    display: none;
}

.mcse-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(17, 24, 39, .6);
    backdrop-filter: blur(2px);
}

.mcse-modal-dialog {
    position: relative;
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .3);
}

.mcse-view-dialog {
    max-width: 640px;
}

.mcse-modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    border: none;
    background: none;
    font-size: 26px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
}

.mcse-modal-close:hover {
    color: #111827;
}

/* Auth + publish forms */

.mcse-auth-tabs {
    display: flex;
    gap: 4px;
    background: #f3f4f6;
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.mcse-auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px;
    border-radius: 8px;
    font-weight: 600;
    color: #4b5563;
    cursor: pointer;
}

.mcse-auth-tab.active {
    background: #fff;
    color: #16a34a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.mcse-auth-form,
#mcse-publish-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.mcse-auth-form label,
#mcse-publish-form label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.mcse-auth-form input,
#mcse-publish-form input,
#mcse-publish-form select {
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.mcse-auth-form input:focus,
#mcse-publish-form input:focus,
#mcse-publish-form select:focus {
    outline: 2px solid #86efac;
    border-color: #16a34a;
}

.mcse-form-msg {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    background: #f3f4f6;
    color: #374151;
}

.mcse-form-msg.mcse-msg-error {
    background: #fef2f2;
    color: #b91c1c;
}

.mcse-form-msg.mcse-msg-success {
    background: #f0fdf4;
    color: #15803d;
}

.mcse-publish-preview {
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.mcse-publish-preview canvas {
    width: 80px;
    height: 160px;
    image-rendering: pixelated;
}

/* Skin viewer modal */

.mcse-view-layout {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
}

.mcse-view-previews {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex: 1 1 260px;
    background: linear-gradient(180deg, #dbeafe 0%, #f8fafc 100%);
    border-radius: 12px;
    padding: 20px 12px 8px;
}

.mcse-view-previews figure {
    margin: 0;
    text-align: center;
}

.mcse-view-previews figcaption {
    font-size: 12px;
    color: #6b7280;
    margin-top: 6px;
}

.mcse-view-previews canvas {
    width: 104px;
    height: 208px;
    image-rendering: pixelated;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, .25));
}

.mcse-view-info {
    flex: 1 1 220px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.mcse-view-name {
    margin: 0;
    font-size: 22px;
    line-height: 1.25;
    word-wrap: break-word;
}

.mcse-view-author {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.mcse-view-meta {
    margin: 0;
}

.mcse-view-stats {
    margin: 0;
    font-size: 14px;
    color: #4b5563;
}

.mcse-view-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
    padding-top: 12px;
    flex-wrap: wrap;
}

/* --------------------------------------------------------- Responsive */

@media (max-width: 600px) {
    .mcse-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 10px;
    }

    .mcse-card-preview canvas {
        width: 72px;
        height: 144px;
    }

    .mcse-creator-stats {
        gap: 10px;
        font-size: 12px;
    }

    .mcse-view-layout {
        gap: 16px;
    }
}
