/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* Header */
header {
    text-align: center;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header p {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* Main content */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Search section */
.search-section {
    margin-bottom: 2rem;
}

.search-container {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

#cardSearch {
    flex: 1;
    padding: 1rem;
    font-size: 1.1rem;
    border: none;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    outline: none;
    transition: box-shadow 0.3s ease;
}

#cardSearch:focus {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#searchBtn {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#searchBtn:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

/* Suggestions */
.suggestions-container {
    max-width: 600px;
    margin: 0 auto;
    position: relative;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
}

.suggestion-item {
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    transition: background 0.2s ease;
}

.suggestion-item:hover {
    background: #f5f5f5;
}

.suggestion-item:last-child {
    border-bottom: none;
}

/* Results section */
.results-section {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
    display: none;
}

.results-section.show {
    display: block;
}

/* Card info */
.card-display {
    display: flex;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

/* Card image container */
.card-image-container {
    position: relative;
    display: inline-block;
}

#cardImage, #cardImageBack {
    max-width: 300px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s ease;
}

#cardImageBack {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

#cardImageBack.show {
    opacity: 1;
}

#cardImage.hide {
    opacity: 0;
}

.flip-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.flip-btn:hover {
    background: rgba(102, 126, 234, 1);
    transform: scale(1.05);
}

.card-details {
    flex: 1;
    min-width: 300px;
}

.card-details h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: #333;
}

.card-details p {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
}

#cardText {
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

/* Price section */
.price-section {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
    margin-top: 2rem;
}

.price-item.loading {
    opacity: 0.6;
}

.price-item.loading .price-value {
    color: #999;
    font-style: italic;
}

.price-item.error .price-value {
    color: #dc3545;
    font-style: italic;
}

/* Card Rating Section */
.card-rating {
    margin-top: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.rating-buttons {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.vote-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: 2px solid #ddd;
    border-radius: 20px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

.vote-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.vote-btn.upvote {
    border-color: #28a745;
    color: #28a745;
}

.vote-btn.upvote:hover, .vote-btn.upvote.active {
    background: #28a745;
    color: white;
}

.vote-btn.downvote {
    border-color: #dc3545;
    color: #dc3545;
}

.vote-btn.downvote:hover, .vote-btn.downvote.active {
    background: #dc3545;
    color: white;
}

.vote-icon {
    font-size: 1.2em;
}

.rating-stats {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

/* Suggested Cards Section */
.suggestions-cards-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.suggestions-cards-section h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.3rem;
}

.suggested-cards-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.suggested-card {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.suggested-card:hover {
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.suggested-card-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 0.5rem;
}

.suggested-card-reason {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.loading-suggestions {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

/* Comments Section */
.comments-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.comments-section h3 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 1.3rem;
}

.add-comment {
    margin-bottom: 2rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.user-input {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

#userNameInput {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
}

#commentInput {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

#addCommentBtn {
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.3s ease;
}

#addCommentBtn:hover {
    background: #5a6fd8;
}

#addCommentBtn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.comment {
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.comment-author {
    font-weight: bold;
    color: #333;
}

.comment-date {
    font-size: 0.8rem;
    color: #666;
}

.comment-text {
    color: #444;
    line-height: 1.5;
}

.no-comments {
    text-align: center;
    color: #666;
    font-style: italic;
    padding: 2rem;
}

.current-prices h3,
.price-chart-container h3 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.5rem;
}

.price-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.price-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #28a745;
}

.price-source {
    font-weight: bold;
    color: #333;
}

.price-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #28a745;
}

.price-chart-container {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 8px;
    height: 280px;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    margin: 0;
}

.time-filter {
    display: flex;
    gap: 0.25rem;
    background: white;
    padding: 0.25rem;
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.time-btn {
    padding: 0.4rem 0.8rem;
    border: none;
    background: transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: #666;
    transition: all 0.2s ease;
}

.time-btn:hover {
    background: #f0f2ff;
    color: #667eea;
}

.time-btn.active {
    background: #667eea;
    color: white;
}

#priceChart {
    max-height: 200px;
}

/* Reprints section */
.reprints-section {
    margin: 2rem 0;
    padding: 1.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.reprints-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.reprints-section h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.filter-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-container label {
    font-weight: 500;
    color: #555;
    white-space: nowrap;
}

#printingFilter {
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    font-size: 0.9rem;
    min-width: 180px;
}

.reprints-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1rem;
}

.reprint-item {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.reprint-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.reprint-item.selected {
    border-color: #667eea;
    background: #f0f2ff;
}

.reprint-thumbnail {
    flex-shrink: 0;
    width: 60px;
    height: 84px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.reprint-thumbnail-front,
.reprint-thumbnail-back {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    transition: opacity 0.3s ease;
}

.reprint-thumbnail-back {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
}

.reprint-thumbnail-back.show {
    opacity: 1;
}

.reprint-thumbnail-front.hide {
    opacity: 0;
}

.reprint-thumbnail-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.6rem;
    color: #999;
    text-align: center;
    width: 100%;
    padding: 0.25rem;
}

.reprint-flip-btn {
    position: absolute;
    bottom: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 3px;
    padding: 2px 4px;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 2;
}

.reprint-thumbnail:hover .reprint-flip-btn {
    opacity: 1;
}

.reprint-content {
    flex: 1;
    min-width: 0;
}

.reprint-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.reprint-set {
    font-weight: bold;
    color: #333;
    font-size: 1.1rem;
}

.reprint-rarity {
    font-size: 0.9rem;
    color: #666;
    text-transform: capitalize;
}

.reprint-price {
    font-size: 1.1rem;
    font-weight: bold;
    color: #28a745;
}

.reprint-details {
    font-size: 0.9rem;
    color: #666;
    margin-top: 0.5rem;
}

.reprint-details span {
    margin-right: 1rem;
}

/* Loading spinner */
.loading {
    text-align: center;
    padding: 3rem;
    color: white;
}

.spinner {
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid white;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem auto;
}

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

/* Error section */
.error {
    background: #ff6b6b;
    color: white;
    padding: 2rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 2rem;
}

/* Footer */
footer {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
}

/* Responsive design */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .search-container {
        flex-direction: column;
    }
    
    .card-display {
        flex-direction: column;
        align-items: center;
    }
    
    .price-section {
        grid-template-columns: 1fr;
    }
    
    main {
        padding: 1rem;
    }
    
    .results-section {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    header {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    #cardImage {
        max-width: 100%;
    }
    
    .card-details h2 {
        font-size: 1.5rem;
    }
}