/* Cat on a Fence - Enhanced CSS with Likes, Arena, and Leaderboard */

/* Base Styles */
.cof-form, .cof-gallery, .cof-arena, .cof-leaderboard {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Loading Spinner */
.cof-loading {
    text-align: center;
    padding: 40px;
}

.cof-spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form Styles */
.cof-form-group {
    margin-bottom: 20px;
}

.cof-form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.cof-form-group input, .cof-select {
    width: 100%;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.cof-form-group input:focus, .cof-select:focus {
    outline: none;
    border-color: #3498db;
}

.cof-submit-btn, .cof-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.cof-submit-btn:hover, .cof-btn:hover {
    background: #2980b9;
}

/* Result Messages */
.cof-result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 8px;
    font-weight: 500;
}

.cof-result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.cof-result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Gallery Styles */
.cof-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.cof-gallery-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cof-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.cof-gallery-item {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cof-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.cof-svg-display {
    width: 100%;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.cof-svg-display svg {
    max-width: 90%;
    max-height: 90%;
}

.cof-svg-error {
    color: #dc3545;
    text-align: center;
    padding: 20px;
    font-size: 14px;
}

.cof-gallery-item-info {
    padding: 15px;
}

.cof-gallery-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.cof-model-name {
    font-weight: 600;
    color: #333;
}

.cof-creator-name {
    color: #666;
    font-size: 14px;
}

.cof-gallery-item-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
}

/* Heart Like Button */
.cof-like-btn {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 20px;
    transition: all 0.3s ease;
}

.cof-like-btn:hover {
    background: rgba(255, 192, 203, 0.2);
}

.cof-like-btn.liked {
    color: #e74c3c;
}

.cof-like-btn.liked .cof-heart {
    animation: heartBeat 0.6s ease-in-out;
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.cof-like-count {
    font-size: 14px;
    font-weight: 500;
}

/* Code Toggle */
.cof-code-toggle {
    background: #6c757d;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
}

.cof-code-display {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 10px;
    margin-top: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.cof-code-display.visible {
    display: block;
}

/* Arena Styles */
.cof-arena-header {
    text-align: center;
    margin-bottom: 30px;
}

.cof-arena-battle {
    max-width: 1000px;
    margin: 0 auto;
}

.cof-battle-pair {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
    margin-bottom: 30px;
}

.cof-battle-option {
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    position: relative;
}

.cof-battle-option:hover {
    transform: scale(1.05);
}

.cof-svg-container {
    position: relative;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin-bottom: 15px;
}

.cof-battle-option .cof-svg-display {
    height: 250px;
    cursor: pointer;
}

.cof-battle-vs {
    font-size: 24px;
    font-weight: bold;
    color: #666;
    flex-shrink: 0;
}

.cof-battle-controls {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.cof-key-indicator {
    font-weight: bold;
    color: #3498db;
    font-size: 14px;
}

.cof-prefer-text {
    color: #666;
    font-size: 12px;
}

/* Model Reveal Animation */
.cof-model-reveal {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 14px;
    z-index: 10;
    animation: fadeInOut 5s ease-in-out;
}

.cof-model-reveal.winner {
    background: rgba(46, 204, 113, 0.9);
    color: white;
}

.cof-model-reveal.winner::before {
    content: "↑ ";
}

.cof-model-reveal.loser {
    background: rgba(231, 76, 60, 0.9);
    color: white;
}

.cof-model-reveal.loser::before {
    content: "↓ ";
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    10%, 90% { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Emoji Animation Styles */
.cof-emoji-animation {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 20;
}

.cof-emoji-floating {
    animation: floatingEmojis 3s ease-out;
}

.cof-emoji-fountain {
    animation: fountainEmojis 3s ease-out;
}

.cof-emoji-zoom {
    animation: zoomEmojis 3s ease-out;
}

.cof-emoji-popup {
    animation: popupEmojis 3s ease-out;
}

@keyframes floatingEmojis {
    0% { opacity: 0; transform: translate(-50%, -50%) translateY(0); }
    20% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -50%) translateY(-100px); }
}

@keyframes fountainEmojis {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.5); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.5) translateY(-50px); }
}

@keyframes zoomEmojis {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(2); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
}

@keyframes popupEmojis {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0) rotate(0deg); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.2) rotate(180deg); }
    100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8) rotate(360deg); }
}

/* Arena Stats */
.cof-arena-stats {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.cof-arena-stats h4 {
    margin-bottom: 15px;
    color: #333;
}

.cof-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.cof-stat-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cof-stat-number {
    font-size: 24px;
    font-weight: bold;
    color: #3498db;
}

.cof-stat-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Leaderboard Styles */
.cof-leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}

.cof-leaderboard-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cof-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.cof-table th,
.cof-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.cof-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
}

.cof-table th:hover {
    background: #e9ecef;
}

.cof-table th.sortable::after {
    content: " ↕";
    color: #ccc;
    font-size: 12px;
}

.cof-table th.sorted-asc::after {
    content: " ↑";
    color: #3498db;
}

.cof-table th.sorted-desc::after {
    content: " ↓";
    color: #3498db;
}

.cof-table tbody tr:hover {
    background: #f8f9fa;
}

.cof-table .rank-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.1), transparent);
}

.cof-table .rank-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.1), transparent);
}

.cof-table .rank-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.1), transparent);
}

.cof-elo-score {
    font-weight: bold;
    color: #3498db;
}

.cof-likes-count {
    color: #e74c3c;
}

.cof-appearances-count {
    color: #27ae60;
}

/* Pagination */
.cof-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
}

.cof-pagination button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.cof-pagination button:hover:not(:disabled) {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

.cof-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.cof-pagination .current {
    background: #3498db;
    color: white;
    border-color: #3498db;
}

/* Responsive Design */
@media (max-width: 768px) {
    .cof-battle-pair {
        flex-direction: column;
        gap: 20px;
    }
    
    .cof-battle-vs {
        transform: rotate(90deg);
        margin: 10px 0;
    }
    
    .cof-gallery-grid {
        grid-template-columns: 1fr;
    }
    
    .cof-table {
        font-size: 14px;
    }
    
    .cof-table th,
    .cof-table td {
        padding: 10px 8px;
    }
    
    .cof-leaderboard-header,
    .cof-gallery-header {
        flex-direction: column;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .cof-form, .cof-gallery, .cof-arena, .cof-leaderboard {
        padding: 15px;
    }
    
    .cof-battle-option .cof-svg-display {
        height: 200px;
    }
    
    .cof-table {
        font-size: 12px;
    }
    
    .cof-table th,
    .cof-table td {
        padding: 8px 5px;
    }
}

/* Accessibility */
.cof-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 styles for keyboard navigation */
.cof-battle-option:focus,
.cof-like-btn:focus,
.cof-btn:focus,
.cof-submit-btn:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cof-gallery-item,
    .cof-svg-container,
    .cof-table {
        border: 2px solid #000;
    }
    
    .cof-btn,
    .cof-submit-btn {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

