/* ==========================================================================
   Playlist Submitter for Spotify — Frontend Styles
   ========================================================================== */

.sps-module {
    --sps-green: #1DB954;
    --sps-text: #191414;
    --sps-muted: #6a6a6a;
    --sps-bg: #ffffff;
    --sps-border: #e8e8e8;
    --sps-radius: 8px;

    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
    background: var(--sps-bg);
    border: 1px solid var(--sps-border);
    border-radius: var(--sps-radius);
    max-width: 360px;
    margin: 24px auto;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--sps-text);
}

.sps-module--dark {
    --sps-text: #ffffff;
    --sps-muted: #aaaaaa;
    --sps-bg: #191414;
    --sps-border: #333333;
}

.sps-module--minimal {
    background: transparent;
    border: none;
    padding: 12px;
}

.sps-module__cover img {
    width: 240px;
    height: 240px;
    max-width: 100%;
    object-fit: cover;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sps-module__meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sps-module__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.sps-module__title a {
    color: var(--sps-text);
    text-decoration: none;
}

.sps-module__title a:hover {
    text-decoration: underline;
}

.sps-module__owner {
    margin: 0;
    font-size: 14px;
    color: var(--sps-muted);
}

.sps-module__owner a {
    color: var(--sps-muted);
    text-decoration: none;
}

.sps-module__owner a:hover {
    text-decoration: underline;
}

.sps-module__followers {
    margin: 0;
    font-size: 13px;
    color: var(--sps-muted);
}

.sps-module__followers-hint {
    cursor: help;
    opacity: 0.6;
}

.sps-module__submit {
    background: var(--sps-green);
    color: #ffffff;
    border: none;
    border-radius: 24px;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
    font-family: inherit;
    min-height: 44px;
    min-width: 180px;
}

.sps-module__submit:hover {
    background: #1ed760;
}

.sps-module__submit:active {
    transform: scale(0.98);
}

.sps-module__submit:focus-visible {
    outline: 2px solid var(--sps-green);
    outline-offset: 2px;
}

.sps-module__branding {
    margin-top: 4px;
}

.sps-branding-link {
    display: inline-block;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.sps-branding-link:hover {
    opacity: 1;
}

/* ============= Popup ============= */
.sps-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.sps-popup {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #191414;
}

.sps-popup__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e8e8e8;
    position: sticky;
    top: 0;
    background: #ffffff;
    z-index: 1;
    border-radius: 12px 12px 0 0;
}

.sps-popup__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.sps-popup__close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    color: #6a6a6a;
    padding: 4px 8px;
    border-radius: 4px;
}

.sps-popup__close:hover {
    background: #f4f4f4;
    color: #191414;
}

.sps-popup__body {
    padding: 24px;
}

.sps-popup__section {
    margin-bottom: 20px;
}

.sps-popup__section:last-child {
    margin-bottom: 0;
}

.sps-popup__section-title {
    font-size: 13px;
    font-weight: 600;
    color: #6a6a6a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px;
}

.sps-search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #d4d4d4;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}

.sps-search-input:focus {
    outline: none;
    border-color: #1DB954;
    box-shadow: 0 0 0 2px rgba(29, 185, 84, 0.2);
}

.sps-search-results {
    margin-top: 12px;
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
}

.sps-search-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f4f4f4;
    text-align: left;
}

.sps-search-result:last-child {
    border-bottom: none;
}

.sps-search-result:hover,
.sps-search-result[aria-selected="true"] {
    background: #f4fff7;
}

.sps-search-result img {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    flex-shrink: 0;
}

.sps-search-result-meta {
    flex: 1;
    min-width: 0;
}

.sps-search-result-title {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sps-search-result-artist {
    font-size: 13px;
    color: #6a6a6a;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sps-search-loading,
.sps-search-empty {
    padding: 24px;
    text-align: center;
    color: #6a6a6a;
    font-size: 14px;
}

.sps-search-more {
    width: 100%;
    padding: 12px;
    background: #f4f4f4;
    border: none;
    cursor: pointer;
    font-size: 13px;
    color: #191414;
}

.sps-search-more:hover {
    background: #e8e8e8;
}

.sps-track-preview {
    background: #f8f8f8;
    border-radius: 8px;
    padding: 16px;
}

.sps-track-preview iframe {
    width: 100%;
    border: none;
    border-radius: 8px;
}

.sps-track-preview-change {
    margin-top: 8px;
    font-size: 13px;
    color: #1DB954;
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

.sps-auto-actions {
    background: #fff8e1;
    border: 1px solid #ffe082;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 13px;
}

.sps-auto-actions ul {
    margin: 8px 0 0;
    padding-left: 20px;
}

.sps-auto-actions li {
    margin-bottom: 4px;
}

.sps-login-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: #1DB954;
    color: #ffffff;
    border: none;
    border-radius: 24px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.sps-login-button:hover {
    background: #1ed760;
}

.sps-user-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #f4fff7;
    border: 1px solid #1DB954;
    border-radius: 8px;
    padding: 8px 16px;
    font-size: 14px;
}

.sps-user-info button {
    background: none;
    border: none;
    color: #6a6a6a;
    cursor: pointer;
    font-size: 13px;
    text-decoration: underline;
    font-family: inherit;
}

.sps-field {
    margin-bottom: 12px;
}

.sps-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.sps-field input[type="email"],
.sps-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d4d4d4;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    box-sizing: border-box;
}

.sps-field textarea {
    min-height: 70px;
    resize: vertical;
}

.sps-submit-button {
    width: 100%;
    background: #191414;
    color: #ffffff;
    border: none;
    border-radius: 24px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.sps-submit-button:hover {
    background: #333333;
}

.sps-submit-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sps-status {
    text-align: center;
    padding: 24px;
    border-radius: 8px;
}

.sps-status--success {
    background: #f4fff7;
    color: #1DB954;
}

.sps-status--error {
    background: #ffeef0;
    color: #c62828;
}

.sps-status h3 {
    margin: 0 0 8px;
    font-size: 18px;
}

.sps-spinner {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid #cccccc;
    border-top-color: #1DB954;
    border-radius: 50%;
    animation: sps-spin 0.6s linear infinite;
    vertical-align: middle;
}

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

@media (max-width: 600px) {
    .sps-popup {
        max-height: 100vh;
        max-width: 100%;
        border-radius: 0;
    }

    .sps-popup__header {
        border-radius: 0;
    }

    .sps-module__cover img {
        width: 180px;
        height: 180px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sps-module__submit,
    .sps-search-result,
    .sps-popup__close {
        transition: none;
    }

    .sps-spinner {
        animation: none;
    }
}
