/**
 * MoreCore Charts - Public Styles
 */

/* CSS Variables for easy theming */
:root {
    --mcc-primary: #e63946;
    --mcc-primary-dark: #c5303c;
    --mcc-secondary: #1a1a2e;
    --mcc-text: #333;
    --mcc-text-light: #666;
    --mcc-bg: #fff;
    --mcc-bg-light: #f8f9fa;
    --mcc-border: #ddd;
    --mcc-success: #46b450;
    --mcc-error: #dc3232;
    --mcc-warning: #996800;
}

/* Voting Form Container */
.morecore-charts-voting {
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.morecore-charts-voting__header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--mcc-primary);
}

.morecore-charts-voting__title {
    font-size: 1.75rem;
    color: var(--mcc-secondary);
    margin: 0 0 0.5rem;
}

.morecore-charts-voting__subtitle {
    color: var(--mcc-text-light);
    margin: 0;
}

/* Messages */
.morecore-charts-message {
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.morecore-charts-message--success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.morecore-charts-message--error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.morecore-charts-message--info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Sections */
.morecore-charts-voting__section {
    margin-bottom: 2rem;
}

.morecore-charts-voting__section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    color: var(--mcc-secondary);
    margin: 0 0 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--mcc-border);
}

.morecore-charts-voting__icon {
    font-size: 1.5rem;
}

/* Song List */
.morecore-charts-voting__songs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.morecore-charts-voting__song {
    display: block;
    cursor: pointer;
}

.morecore-charts-voting__radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.morecore-charts-voting__song-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--mcc-bg-light);
    border: 2px solid transparent;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.morecore-charts-voting__song:hover .morecore-charts-voting__song-content {
    background: #fff;
    border-color: var(--mcc-border);
}

.morecore-charts-voting__radio:checked + .morecore-charts-voting__song-content {
    background: #fff;
    border-color: var(--mcc-primary);
    box-shadow: 0 2px 8px rgba(230, 57, 70, 0.15);
}

.morecore-charts-voting__position {
    font-weight: bold;
    color: var(--mcc-secondary);
    min-width: 2rem;
}

.morecore-charts-voting__cover {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.morecore-charts-voting__song-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.morecore-charts-voting__band {
    font-weight: 600;
    color: var(--mcc-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.morecore-charts-voting__title {
    font-size: 0.9rem;
    color: var(--mcc-text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Movement Indicators */
.morecore-charts-voting__movement {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.morecore-charts-voting__movement--new,
.movement-new {
    background: var(--mcc-primary);
    color: #fff;
}

.morecore-charts-voting__movement--up,
.movement-up {
    color: var(--mcc-success);
}

.morecore-charts-voting__movement--down,
.movement-down {
    color: var(--mcc-error);
}

.morecore-charts-voting__movement--same,
.movement-same {
    color: var(--mcc-text-light);
}

.morecore-charts-voting__badge {
    background: var(--mcc-primary);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

/* Free Choice */
.morecore-charts-voting__free-choice {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.morecore-charts-voting__free-choice-option {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.morecore-charts-voting__select,
.morecore-charts-voting__input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 2px solid var(--mcc-border);
    border-radius: 8px;
    background: var(--mcc-bg);
    transition: border-color 0.2s ease;
}

.morecore-charts-voting__select:focus,
.morecore-charts-voting__input:focus {
    outline: none;
    border-color: var(--mcc-primary);
}

.morecore-charts-voting__select:disabled,
.morecore-charts-voting__input:disabled {
    background: var(--mcc-bg-light);
    opacity: 0.6;
    cursor: not-allowed;
}

.morecore-charts-voting__new-song-fields {
    display: flex;
    gap: 0.5rem;
}

.morecore-charts-voting__new-song-fields .morecore-charts-voting__input {
    flex: 1;
}

/* Email Section */
.morecore-charts-voting__section--email {
    background: var(--mcc-bg-light);
    padding: 1.5rem;
    border-radius: 8px;
}

.morecore-charts-voting__label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--mcc-secondary);
}

.morecore-charts-voting__required {
    color: var(--mcc-error);
}

.morecore-charts-voting__input--email {
    max-width: 400px;
}

.morecore-charts-voting__hint {
    font-size: 0.85rem;
    color: var(--mcc-text-light);
    margin: 0.5rem 0 0;
}

/* Consent Section */
.morecore-charts-voting__section--consent {
    background: var(--mcc-bg-light);
    padding: 1.25rem;
    border-radius: 8px;
    margin-top: 1rem;
}

.morecore-charts-voting__checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.morecore-charts-voting__checkbox:last-child {
    margin-bottom: 0;
}

.morecore-charts-voting__checkbox input[type="checkbox"] {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: var(--mcc-primary);
    cursor: pointer;
}

.morecore-charts-voting__checkbox-text {
    font-size: 0.9rem;
    color: var(--mcc-text);
}

.morecore-charts-voting__checkbox-text a {
    color: var(--mcc-primary);
    text-decoration: underline;
}

.morecore-charts-voting__checkbox-text a:hover {
    color: var(--mcc-primary-dark);
}

.morecore-charts-voting__checkbox--newsletter {
    padding-top: 0.75rem;
    border-top: 1px solid var(--mcc-border);
}

.morecore-charts-voting__checkbox--newsletter .morecore-charts-voting__checkbox-text {
    color: var(--mcc-text-light);
}

/* Submit */
.morecore-charts-voting__submit {
    text-align: center;
    margin-top: 2rem;
}

.morecore-charts-voting__button {
    display: inline-block;
    padding: 1rem 3rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: #fff;
    background: var(--mcc-primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.1s ease;
}

.morecore-charts-voting__button:hover {
    background: var(--mcc-primary-dark);
}

.morecore-charts-voting__button:active {
    transform: scale(0.98);
}

.morecore-charts-voting__button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Response Area */
.morecore-charts-voting__response {
    margin-top: 1rem;
    text-align: center;
}

/* Accessibility - Screen Reader Only */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Loading State */
.morecore-charts-voting__form.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.morecore-charts-voting__form.is-loading .morecore-charts-voting__button::after {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-left: 0.5em;
    border: 2px solid #fff;
    border-right-color: transparent;
    border-radius: 50%;
    animation: mcc-spin 0.75s linear infinite;
    vertical-align: middle;
}

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

/* Focus styles for accessibility */
.morecore-charts-voting__radio:focus + .morecore-charts-voting__song-content {
    outline: 2px solid var(--mcc-primary);
    outline-offset: 2px;
}

.morecore-charts-voting__input:focus,
.morecore-charts-voting__select:focus,
.morecore-charts-voting__button:focus {
    outline: 2px solid var(--mcc-primary);
    outline-offset: 2px;
}

/* Fieldset reset (for accessibility structure) */
.morecore-charts-voting__section[role="radiogroup"] {
    border: none;
    padding: 0;
    margin: 0 0 2rem;
}

/* =========================
   Chart Display Styles
   ========================= */

.morecore-charts-display {
    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.morecore-charts-display--empty {
    text-align: center;
    padding: 2rem;
    background: var(--mcc-bg-light);
    border-radius: 8px;
}

.morecore-charts-display__header {
    text-align: center;
    margin-bottom: 2rem;
}

.morecore-charts-display__title {
    font-size: 2rem;
    color: var(--mcc-secondary);
    margin: 0;
}

.morecore-charts-display__week {
    font-size: 1.125rem;
    color: var(--mcc-text-light);
    margin: 0.5rem 0 0;
}

/* Chart List */
.morecore-charts-display__list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.morecore-charts-display__entry {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--mcc-bg);
    border: 1px solid var(--mcc-border);
    border-radius: 8px;
    transition: box-shadow 0.2s ease;
}

.morecore-charts-display__entry:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Position */
.morecore-charts-display__position {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 3rem;
}

.morecore-charts-display__position-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--mcc-secondary);
}

.morecore-charts-display__movement {
    font-size: 0.75rem;
    font-weight: 600;
}

.movement-badge {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.65rem;
}

.movement-badge--new {
    background: var(--mcc-primary);
    color: #fff;
}

.movement-arrow--up {
    color: var(--mcc-success);
}

.movement-arrow--down {
    color: var(--mcc-error);
}

.movement-arrow--same {
    color: var(--mcc-text-light);
}

/* Cover */
.morecore-charts-display__cover {
    flex-shrink: 0;
}

.morecore-charts-display__cover img {
    width: 64px;
    height: 64px;
    object-fit: cover;
    border-radius: 4px;
}

/* Info */
.morecore-charts-display__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.morecore-charts-display__band {
    font-weight: 600;
    color: var(--mcc-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.morecore-charts-display__song {
    color: var(--mcc-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.morecore-charts-display__stats {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--mcc-text-light);
}

.stat--new {
    color: var(--mcc-primary);
    font-weight: 600;
}

/* Links */
.morecore-charts-display__links {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.morecore-charts-display__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    transition: opacity 0.2s ease;
}

.morecore-charts-display__link:hover {
    opacity: 0.8;
}

.morecore-charts-display__link--spotify {
    background: #1DB954;
    color: #fff;
}

.morecore-charts-display__link--apple {
    background: #FA233B;
    color: #fff;
}

.morecore-charts-display__link--youtube {
    background: #FF0000;
    color: #fff;
}

.morecore-charts-display__link svg {
    width: 18px;
    height: 18px;
}

/* Footer */
.morecore-charts-display__footer {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--mcc-border);
}

.morecore-charts-display__total-votes {
    font-size: 0.9rem;
    color: var(--mcc-text-light);
    margin: 0;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 600px) {
    .morecore-charts-voting__song-content {
        flex-wrap: wrap;
    }

    .morecore-charts-voting__cover {
        width: 40px;
        height: 40px;
    }

    .morecore-charts-voting__movement {
        order: -1;
        margin-left: auto;
    }

    .morecore-charts-voting__new-song-fields {
        flex-direction: column;
    }

    .morecore-charts-display__entry {
        flex-wrap: wrap;
    }

    .morecore-charts-display__cover img {
        width: 48px;
        height: 48px;
    }

    .morecore-charts-display__links {
        width: 100%;
        justify-content: center;
        margin-top: 0.5rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--mcc-border);
    }
}
