/* =========================================================
   MUSIKPOSTER CREATOR
   ========================================================= */

.musikposter-app {
    display: flex;
    gap: 40px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ---- Controls panel ---- */
.mp-controls {
    flex: 0 0 380px;
    max-width: 380px;
}

.mp-page-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 6px;
    color: #111;
}

.mp-page-desc {
    font-size: 14px;
    color: #666;
    margin: 0 0 28px;
}

.mp-section {
    margin-bottom: 24px;
}

.mp-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Inputs ---- */
.mp-input,
.mp-textarea {
    display: block;
    width: 100%;
    padding: 10px 14px;
    font-size: 15px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background: #fff;
    color: #111;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.mp-input:focus,
.mp-textarea:focus {
    border-color: #333;
}

.mp-input-mt {
    margin-top: 8px;
}

.mp-textarea {
    resize: vertical;
    min-height: 100px;
    font-family: inherit;
}

.mp-textarea.mp-loading {
    animation: mp-pulse 1.2s ease-in-out infinite;
    background: #f9f9f9;
}

@keyframes mp-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.mp-hint {
    display: block;
    font-size: 12px;
    color: #888;
    margin-top: 6px;
}

.mp-char-count {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ---- Search ---- */
.mp-search-wrap {
    position: relative;
}

.mp-search-spinner {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 10;
}

.mp-spinner-small {
    width: 20px;
    height: 20px;
    border: 2px solid #e0e0e0;
    border-top-color: #333;
    border-radius: 50%;
    animation: mp-spin 0.8s linear infinite;
}

.mp-search-results {
    position: absolute;
    z-index: 100;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 360px;
    overflow-y: scroll;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}

.mp-search-results::-webkit-scrollbar {
    width: 6px;
}

.mp-search-results::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.mp-search-results::-webkit-scrollbar-thumb:hover {
    background: #999;
}

.mp-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
}

.mp-result-item:hover,
.mp-result-item.active {
    background: #f5f5f5;
}

.mp-result-item img {
    width: 44px;
    height: 44px;
    border-radius: 4px;
    object-fit: cover;
    flex-shrink: 0;
}

.mp-result-item div {
    min-width: 0;
}

.mp-result-item strong {
    display: block;
    font-size: 14px;
    color: #111;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-result-item span {
    display: block;
    font-size: 12px;
    color: #888;
}

.mp-no-res {
    padding: 14px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

.mp-search-results .mp-loading-state {
    background: transparent;
    padding: 24px 14px;
    margin: 0;
}

/* ---- Selected song ---- */
.mp-selected-song {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #f0f0f0;
    border-radius: 8px;
    margin-bottom: 20px;
}

.mp-selected-song img {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    object-fit: cover;
}

.mp-selected-info {
    flex: 1;
    min-width: 0;
}

.mp-selected-info strong {
    display: block;
    font-size: 15px;
    color: #111;
}

.mp-selected-info span {
    display: block;
    font-size: 13px;
    color: #666;
}

.mp-btn-clear {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border: none;
    background: #ddd;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.mp-btn-clear:hover {
    background: #ccc;
}

/* ---- Colors ---- */
.mp-color-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mp-color-btn {
    width: 40px;
    height: 40px;
    border: 2px solid #ccc;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s, transform 0.15s;
    padding: 0;
}

.mp-color-btn:hover {
    transform: scale(1.1);
}

.mp-color-btn.active {
    border-color: #333;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(0,0,0,0.1);
}

.mp-color-dot {
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

/* ---- Sizes Dropdown ---- */
.mp-size-grid {
    position: relative;
}

.mp-size-dropdown {
    position: relative;
    width: 100%;
}

.mp-size-selected {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    background: #fff;
    color: #333;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
    user-select: none;
}

.mp-size-selected:hover {
    border-color: #999;
}

.mp-size-dropdown.open .mp-size-selected {
    border-color: #999;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.mp-dropdown-arrow {
    margin-left: 8px;
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.mp-size-dropdown.open .mp-dropdown-arrow {
    transform: rotate(180deg);
}

.mp-size-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 100;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.mp-size-dropdown.open .mp-size-options {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #999;
    border-top: none;
}

.mp-size-option {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #f0f0f0;
}

.mp-size-option:last-child {
    border-bottom: none;
}

.mp-size-option:hover {
    background: #f5f5f5;
}

.mp-size-option.active {
    background: #f0f0f0;
}

.mp-size-label {
    font-weight: 600;
    white-space: nowrap;
    color: #111;
    flex-shrink: 0;
}

.mp-size-price {
    font-size: 13px;
    color: #666;
    margin-left: auto;
    white-space: nowrap;
    flex-shrink: 0;
}

/* ---- Price & Cart ---- */
.mp-cart-section {
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.mp-price-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    font-size: 18px;
}

#mp-price-label {
    font-weight: 600;
    color: #333;
}

#mp-price-value {
    font-weight: 700;
    color: #111;
}

.mp-btn {
    display: block;
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.mp-btn-cart {
    background: #111;
    color: #fff;
    margin-bottom: 10px;
}

.mp-btn-cart:hover {
    background: #333;
}

.mp-btn-cart:disabled {
    background: #999;
    cursor: not-allowed;
}

.mp-btn-download {
    background: #fff;
    color: #333;
    border: 1px solid #d0d0d0;
}

.mp-btn-download:hover {
    background: #f5f5f5;
}

.mp-btn-download:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Preview ---- */
.mp-preview-wrap {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: sticky;
    top: 100px;
}

.mp-preview {
    width: 100%;
    max-width: 580px;
    aspect-ratio: 5 / 7;
    box-shadow: 0 8px 40px rgba(0,0,0,0.15), 0 2px 8px rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.mp-preview svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* ---- Responsive ---- */
@media (max-width: 900px) {
    .musikposter-app {
        flex-direction: column;
        padding: 20px 16px;
        gap: 24px;
    }

    .mp-controls {
        flex: none;
        max-width: 100%;
    }

    .mp-preview-wrap {
        position: static;
        order: -1; /* Preview on top on mobile */
    }

    .mp-preview {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .mp-page-title {
        font-size: 20px;
    }
}

/* ---- Loading States ---- */
.mp-loading-state {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 12px !important;
    padding: 20px 14px !important;
    color: #555 !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    text-align: center !important;
    background: #f9f9f9 !important;
    border-radius: 6px !important;
}

.mp-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e0e0e0;
    border-top-color: #333;
    border-radius: 50%;
    animation: mp-spin 0.8s linear infinite;
}

@keyframes mp-spin {
    to { transform: rotate(360deg); }
}

.mp-hint .mp-loading-state {
    padding: 12px 0;
    gap: 8px;
}

.mp-hint .mp-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}
