/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

#app {
    max-width: 1200px;
    margin: 0 auto;
}

/* Container */
.container {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

/* Typography */
h1 {
    font-size: 2.5rem;
    color: #333;
    margin-bottom: 10px;
}

.subtitle {
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

/* History */
.history {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.history h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    border-left: 4px solid #667eea;
}

.history-item:hover {
    transform: translateX(5px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.history-info {
    flex: 1;
}

.history-date {
    font-weight: 600;
    color: #667eea;
    font-size: 0.95rem;
}

.history-stats {
    color: #666;
    font-size: 0.85rem;
    margin-top: 2px;
}

.history-arrow {
    color: #667eea;
    font-size: 1.5rem;
    font-weight: bold;
}

/* Upload Area */
.upload-area {
    border: 3px dashed #667eea;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 30px;
}

.upload-area:hover {
    background: #f8f9ff;
    border-color: #764ba2;
}

.upload-area.drag-over {
    background: #f0f4ff;
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-area input {
    display: none;
}

.upload-label {
    font-size: 1.2rem;
    color: #667eea;
    font-weight: 600;
}

/* Settings */
.settings {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    align-items: center;
    flex-wrap: wrap;
}

.settings label {
    font-weight: 600;
    color: #333;
}

.settings input[type="number"] {
    width: 80px;
    padding: 8px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
}

/* Buttons */
button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

button:hover:not(:disabled) {
    transform: translateY(-2px);
}

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

/* Stats */
.stats {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.stats h3 {
    color: #667eea;
    margin-bottom: 15px;
}

/* Collapsible Headers */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapse-icon {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

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

.stat-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #333;
}

/* Top Anime */
.top-anime {
    margin: 20px 0;
}

.top-anime h3 {
    color: #333;
    margin-bottom: 15px;
}

.anime-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.anime-item {
    background: #f8f9ff;
    padding: 12px;
    border-radius: 8px;
    display: flex;
    gap: 12px;
    align-items: center;
    transition: all 0.3s;
}

.anime-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.anime-cover {
    width: 60px;
    height: 85px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.anime-info {
    flex: 1;
    min-width: 0;
}

.anime-title {
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.anime-score {
    background: #667eea;
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
    flex-shrink: 0;
}

/* Progress */
.progress {
    background: #f8f9ff;
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s;
}

.progress-text {
    color: #666;
    font-size: 0.9rem;
}

/* Recommendations */
.recommendations {
    margin-top: 30px;
}

.recommendations h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 2rem;
}

/* Filter Controls */
.filter-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    background: #f8f9ff;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 25px;
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.filter-select {
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: all 0.3s;
}

.filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.result-count {
    color: #666;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 8px 15px;
    background: white;
    border-radius: 8px;
    white-space: nowrap;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-size: 1.1rem;
    background: #f8f9ff;
    border-radius: 12px;
}

/* Recommendation Grid */
.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
}

.rec-item {
    background: linear-gradient(135deg, #f8f9ff 0%, #fff 100%);
    padding: 16px;
    border-radius: 12px;
    border-left: 5px solid #667eea;
    transition: all 0.3s;
    display: flex;
    gap: 16px;
    align-items: center;
}

.rec-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.25);
}

.rec-cover {
    width: 100px;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

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

.rec-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.rec-rank {
    background: #667eea;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    text-align: center;
    line-height: 32px;
    font-weight: bold;
    flex-shrink: 0;
}

.rec-title {
    font-size: 1.1rem;
    color: #333;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rec-count {
    color: #764ba2;
    font-size: 0.9rem;
    font-weight: 500;
}

.rec-links {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.rec-link {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.mal-link {
    background: #2e51a2;
    color: white;
}

.mal-link:hover {
    background: #1e3a7a;
    transform: translateY(-1px);
}

.hianime-link {
    background: #ff6b6b;
    color: white;
}

.hianime-link:hover {
    background: #ee5a52;
    transform: translateY(-1px);
}

.rec-type {
    display: inline-block;
    background: #764ba2;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-top: 8px;
}

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

.page-btn {
    background: white;
    color: #667eea;
    border: 2px solid #667eea;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 44px;
}

.page-btn:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
}

.page-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.page-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

.page-numbers {
    display: flex;
    gap: 5px;
}

/* Error */
.error {
    background: #fee;
    color: #c00;
    padding: 15px;
    border-radius: 8px;
    margin: 20px 0;
}

/* Spinner Animation */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 10px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
        border-radius: 12px;
    }

    h1 {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .upload-area {
        padding: 20px;
    }

    .upload-label {
        font-size: 1rem;
    }

    .settings {
        gap: 10px;
    }

    .settings label {
        width: 100%;
        font-size: 0.9rem;
    }

    .settings input[type="number"] {
        width: 70px;
        padding: 6px;
        font-size: 0.9rem;
    }

    button {
        padding: 12px 20px;
        font-size: 0.95rem;
        width: 100%;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .stat-item {
        padding: 12px;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .anime-list {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .anime-cover {
        width: 50px;
        height: 71px;
    }

    .anime-item {
        padding: 10px;
    }

    .anime-title {
        font-size: 0.85rem;
    }

    .anime-score {
        padding: 3px 10px;
        font-size: 0.9rem;
    }

    .recommendations h2 {
        font-size: 1.5rem;
    }

    .top-anime h3,
    .stats h3 {
        font-size: 1.2rem;
    }

    .filter-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .filter-group {
        width: 100%;
        justify-content: space-between;
    }

    .filter-select {
        flex: 1;
    }

    .result-count {
        text-align: center;
    }

    .rec-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .rec-cover {
        width: 80px;
        height: 112px;
    }

    .rec-item {
        padding: 12px;
    }

    .rec-title {
        font-size: 1rem;
    }

    .pagination {
        gap: 5px;
    }

    .page-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 36px;
    }

    .page-numbers {
        gap: 3px;
    }
}
