/**
 * Top 100 Voting Plugin - Frontend Styles
 * Mobile-First Responsive Design
 */

/* Reset and Base Styles */
.top100-chart-wrapper *,
.top100-request-form-wrapper * {
    box-sizing: border-box;
}

/* Movement Indicators - Global */
.movement-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 12px;
    text-align: center;
    min-width: 50px;
    justify-content: center;
}

.movement-up {
    background: rgba(34, 197, 94, 0.1);
    color: #166534;
}

.movement-up .arrow {
    color: #22c55e;
}

.movement-down {
    background: rgba(239, 68, 68, 0.1);
    color: #991b1b;
}

.movement-down .arrow {
    color: #ef4444;
}

.movement-new {
    background: rgba(59, 130, 246, 0.1);
    color: #1e40af;
}

.movement-same {
    background: rgba(107, 114, 128, 0.1);
    color: #374151;
}

/* Arrow Icons */
.movement-arrow {
    font-size: 14px;
    font-weight: bold;
}

/* Utility Classes */
.top100-hidden {
    display: none !important;
}

.top100-loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive Images */
.top100-thumbnail {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
}

/* Accessibility */
.top100-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States */
.vote-btn:focus,
.submit-btn:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .vote-btn,
    .submit-btn,
    .form-submit-section {
        display: none !important;
    }
    
    .top100-chart-wrapper,
    .top100-request-form-wrapper {
        box-shadow: none !important;
        background: white !important;
    }
    
    .track-card,
    .top100-table {
        break-inside: avoid;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .vote-btn {
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #fff !important;
    }
    
    .submit-btn {
        background: #000 !important;
        color: #fff !important;
        border: 2px solid #fff !important;
    }
    
    .movement-indicator {
        border: 1px solid currentColor;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .top100-chart-wrapper,
    .top100-request-form-wrapper {
        color: #f3f4f6;
    }
    
    .track-card,
  .top100-request-form {
        background: #f3f3f3 !important;
        border-color: #363636 !important;
    }
    
    .form-input,
    .form-textarea {
        background: #b2b0b0 !important;
        border-color: #4b5563 !important;
        color: #050505 !important;
    }
    
    .form-input:focus,
    .form-textarea:focus {
        border-color: #667eea !important;
        background: #cbcbcb !important;
    }
    
    .top100-table {
        background: #1f2937 !important;
    }
    
    .top100-table th {
        background: #374151 !important;
        color: #f3f4f6 !important;
    }
    
    .top100-table td {
        border-color: #4b5563 !important;
    }
}

/* Animation Keyframes */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Entry Animations */
.track-card {
    animation: fadeIn 0.3s ease-out;
}

.track-card:nth-child(1) { animation-delay: 0.1s; }
.track-card:nth-child(2) { animation-delay: 0.2s; }
.track-card:nth-child(3) { animation-delay: 0.3s; }
.track-card:nth-child(4) { animation-delay: 0.4s; }
.track-card:nth-child(5) { animation-delay: 0.5s; }

/* Loading States */
.track-card.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

.vote-btn.loading {
    position: relative;
}

.vote-btn.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Error States */
.form-input.error,
.form-textarea.error {
    border-color: #dc2626 !important;
    background: rgba(220, 38, 38, 0.05) !important;
}

.error-message {
    color: #dc2626;
    font-size: 14px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.error-message::before {
    content: "⚠";
    font-size: 16px;
}

/* Success States */
.form-input.success,
.form-textarea.success {
    border-color: #16a34a !important;
    background: rgba(22, 163, 74, 0.05) !important;
}

.success-message {
    color: #16a34a;
    font-size: 14px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.success-message::before {
    content: "✓";
    font-size: 16px;
}

/* Custom Scrollbar */
.top100-chart-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.top100-chart-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.top100-chart-container::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.top100-chart-container::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Notification Styles */
.top100-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-left: 4px solid #16a34a;
    padding: 15px 20px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 9999;
    max-width: 300px;
    animation: slideIn 0.3s ease-out;
}

.top100-notification.error {
    border-left-color: #dc2626;
}

.top100-notification.warning {
    border-left-color: #f59e0b;
}

/* Mobile Specific Optimizations */
@media (max-width: 767px) {
    .top100-chart-wrapper,
    .top100-request-form-wrapper {
        padding: 10px;
    }
    
    .track-card {
        margin-bottom: 8px;
        padding: 12px;
    }
    
    .form-header,
    .top100-request-form {
        padding: 20px;
    }
    
    .submit-btn {
        width: 100%;
        max-width: none;
    }
}

/* Tablet Optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    .top100-chart-wrapper {
        padding: 20px;
    }
    
    .track-card {
        padding: 18px;
    }
}

/* Large Screen Optimizations */
@media (min-width: 1200px) {
    .top100-chart-wrapper {
        padding: 40px;
    }
    
    .desktop-chart .top100-table {
        font-size: 16px;
    }
    
    .desktop-chart .position {
        font-size: 20px;
    }
}

/* RTL Support */
[dir="rtl"] .top100-chart-wrapper,
[dir="rtl"] .top100-request-form-wrapper {
    direction: rtl;
}

[dir="rtl"] .track-card {
    flex-direction: row-reverse;
}

[dir="rtl"] .form-row {
    flex-direction: row-reverse;
}

/* ========================================
   MULTI-GENRE SYSTEM STYLES
   ======================================== */

/* Genre Badges */
.genre-badge,
.genre-badge-mobile {
    display: inline-flex;
    align-items: center;
    background: #6D4BE9;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1;
    transition: all 0.2s ease;
}

.genre-badge-mobile {
    padding: 2px 8px;
    font-size: 10px;
    border-radius: 10px;
}

/* Genre-specific colors */
.genre-pop { background: linear-gradient(45deg, #ff6b9d, #ff8e53); }
.genre-rock { background: linear-gradient(45deg, #4a90e2, #357abd); }
.genre-hip-hop { background: linear-gradient(45deg, #f39c12, #e67e22); }
.genre-jazz { background: linear-gradient(45deg, #9b59b6, #8e44ad); }
.genre-classical { background: linear-gradient(45deg, #34495e, #2c3e50); }
.genre-electronic { background: linear-gradient(45deg, #1abc9c, #16a085); }
.genre-country { background: linear-gradient(45deg, #e74c3c, #c0392b); }
.genre-r-b { background: linear-gradient(45deg, #2ecc71, #27ae60); }
.genre-reggae { background: linear-gradient(45deg, #f1c40f, #f39c12); }
.genre-blues { background: linear-gradient(45deg, #3498db, #2980b9); }

/* YouTube Play Buttons */
.youtube-play,
.youtube-play-mobile {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #ff0000;
    color: white;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    line-height: 1;
    border: none;
    cursor: pointer;
}

.youtube-play-mobile {
    padding: 3px 8px;
    font-size: 10px;
    border-radius: 10px;
    gap: 4px;
}

.youtube-play:hover,
.youtube-play-mobile:hover {
    background: #cc0000;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(255, 0, 0, 0.3);
}

.youtube-play svg,
.youtube-play-mobile svg {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.youtube-play-mobile svg {
    width: 12px;
    height: 12px;
}

/* Track Meta Container */
.track-meta,
.track-meta-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.track-meta-mobile {
    gap: 6px;
    margin-top: 4px;
}

/* Multi-genre chart specific styles */
.top100-multi-genre-chart {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    overflow: hidden;
    margin: 20px auto;
    max-width: 900px;
}

.chart-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px;
    text-align: center;
}

.genre-info {
    margin: 15px 0;
}

.genre-description {
    margin: 8px 0 0 0;
    opacity: 0.9;
    font-size: 14px;
    line-height: 1.4;
}

/* Chart refresh button */
.refresh-chart-btn {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.refresh-chart-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-1px);
}

/* ========================================
   THUMBNAIL STYLES
   ======================================== */

/* Thumbnail Container */
.track-thumbnail {
    flex-shrink: 0;
    margin-right: 12px;
}

[dir="rtl"] .track-thumbnail {
    margin-right: 0;
    margin-left: 12px;
}

/* Thumbnail Images */
.thumbnail-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
}

.thumbnail-image:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Mobile Chart Thumbnails */
.mobile-chart .track-card {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mobile-chart .track-position {
    order: 1;
}

.mobile-chart .track-thumbnail {
    order: 2;
    margin-right: 0;
}

.mobile-chart .track-info {
    order: 3;
    flex: 1;
}

.mobile-chart .track-movement {
    order: 4;
}

.mobile-chart .track-votes {
    order: 5;
}

/* Desktop Table Thumbnails */
.desktop-chart .thumbnail {
    width: 80px;
    text-align: center;
    padding: 8px;
}

.desktop-chart .thumbnail .thumbnail-image {
    width: 64px;
    height: 64px;
    border-radius: 6px;
}

/* Responsive Thumbnail Sizes */
@media (max-width: 480px) {
    .thumbnail-image {
        width: 48px;
        height: 48px;
    }
    
    .mobile-chart .track-card {
        gap: 8px;
    }
    
    .track-thumbnail {
        margin-right: 8px;
    }
    
    [dir="rtl"] .track-thumbnail {
        margin-right: 0;
        margin-left: 8px;
    }
}

@media (min-width: 768px) {
    .thumbnail-image {
        width: 64px;
        height: 64px;
    }
}

@media (min-width: 1024px) {
    .desktop-chart .thumbnail .thumbnail-image {
        width: 72px;
        height: 72px;
    }
}

/* Loading and Error States */
.thumbnail-image.loading {
    opacity: 0.6;
    animation: pulse 2s infinite;
}

.thumbnail-image.error {
    opacity: 0.5;
    filter: grayscale(100%);
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 0.3;
    }
}

/* Accessibility */
.thumbnail-image:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .thumbnail-image {
        border: 2px solid currentColor;
    }
    
    .genre-badge,
    .genre-badge-mobile {
        border: 2px solid currentColor;
    }
    
    .youtube-play,
    .youtube-play-mobile {
        border: 2px solid currentColor;
    }
}

/* ========================================
   MULTI-GENRE RESPONSIVE STYLES
   ======================================== */

/* Mobile optimizations for multi-genre */
@media (max-width: 480px) {
    .track-meta-mobile {
        gap: 4px;
        margin-top: 3px;
    }
    
    .genre-badge-mobile {
        font-size: 9px;
        padding: 2px 6px;
        border-radius: 8px;
    }
    
    .youtube-play-mobile {
        font-size: 9px;
        padding: 2px 6px;
        border-radius: 8px;
    }
    
    .youtube-play-mobile svg {
        width: 10px;
        height: 10px;
    }
    
    .top100-multi-genre-chart {
        margin: 10px;
        border-radius: 8px;
    }
    
    .chart-header {
        padding: 20px 15px;
    }
}

/* Tablet optimizations */
@media (min-width: 768px) and (max-width: 1023px) {
    .genre-badge,
    .genre-badge-mobile {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .youtube-play,
    .youtube-play-mobile {
        padding: 8px 14px;
        font-size: 13px;
    }
    
    .youtube-play svg,
    .youtube-play-mobile svg {
        width: 16px;
        height: 16px;
    }
}

/* Large screen optimizations */
@media (min-width: 1024px) {
    .genre-badge {
        padding: 8px 16px;
        font-size: 13px;
        border-radius: 14px;
    }
    
    .youtube-play {
        padding: 10px 18px;
        font-size: 14px;
        border-radius: 14px;
    }
    
    .youtube-play svg {
        width: 18px;
        height: 18px;
    }
}

/* Dark mode support for multi-genre */
@media (prefers-color-scheme: dark) {
    .top100-multi-genre-chart {
        background: #1f2937;
        color: #f3f4f6;
    }
    
    .chart-header {
        background: linear-gradient(135deg, #4c51bf 0%, #553c9a 100%);
    }
    
    .genre-badge,
    .genre-badge-mobile {
        box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    }
}

/* Animation for genre badges and YouTube buttons */
@keyframes genreBadgeFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-2px); }
}

.genre-badge:hover,
.genre-badge-mobile:hover {
    animation: genreBadgeFloat 0.6s ease-in-out;
    transform: scale(1.05);
}

/* Loading states for multi-genre elements */
.genre-badge.loading,
.youtube-play.loading {
    opacity: 0.6;
    animation: pulse 1.5s ease-in-out infinite;
}
