/* CSS Variables */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary-color: #ec4899;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --border-radius: 12px;
    --border-radius-lg: 20px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s ease;
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
.header {
    text-align: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--surface) 0%, var(--background) 100%);
    border-bottom: 1px solid var(--surface-light);
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.logo {
    width: 48px;
    height: 48px;
    border-radius: 12px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 1rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* Emotion Input Section */
.emotion-input-section {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.emotion-input-section h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.emotion-methods {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Emoji Selection */
.emoji-selection h3,
.text-input-container h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 0.75rem;
    max-width: 600px;
    margin: 0 auto;
}

.emoji-btn {
    font-size: 2rem;
    padding: 0.75rem;
    background: var(--surface-light);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-btn:hover {
    transform: scale(1.1);
    border-color: var(--primary-color);
    background: var(--surface);
}

.emoji-btn.selected {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.2);
    transform: scale(1.1);
}

/* Divider */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    margin: 1rem 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--surface-light);
}

.divider span {
    padding: 0 1rem;
    font-size: 0.875rem;
    text-transform: uppercase;
}

/* Text Input */
.text-input-container {
    text-align: center;
}

#emotion-text {
    width: 100%;
    max-width: 600px;
    padding: 1rem;
    background: var(--surface-light);
    border: 2px solid transparent;
    border-radius: var(--border-radius);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    transition: var(--transition);
}

#emotion-text::placeholder {
    color: var(--text-muted);
}

#emotion-text:focus {
    outline: none;
    border-color: var(--primary-color);
}

.primary-btn {
    margin-top: 1rem;
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.primary-btn:active {
    transform: translateY(0);
}

/* Genre Filter Section */
.genre-filter-section {
    margin-bottom: 2rem;
}

.genre-filter-section h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    text-align: center;
}

.genre-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
}

.genre-tag {
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid var(--surface-light);
    border-radius: 50px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
}

.genre-tag:hover {
    border-color: var(--primary-color);
    color: var(--text-primary);
}

.genre-tag.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header {
    text-align: center;
    margin-bottom: 2rem;
}

.results-header h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
}

.emotion-detected {
    color: var(--text-secondary);
}

.emotion-detected span {
    color: var(--primary-light);
    font-weight: 600;
}

/* Books Grid */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* Book Card */
.book-card {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.book-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.book-cover {
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    position: relative;
    overflow: hidden;
}

.book-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.1;
}

.book-info {
    padding: 1.25rem;
}

.book-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.book-author {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.book-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.book-genre {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: var(--surface-light);
    border-radius: 50px;
    color: var(--text-secondary);
}

.book-rating {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--warning);
    font-size: 0.875rem;
}

.book-match {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--surface-light);
    font-size: 0.875rem;
    color: var(--success);
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.book-modal {
    background: var(--surface);
    border-radius: var(--border-radius-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .book-modal {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 40px;
    height: 40px;
    background: var(--surface-light);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--primary-color);
}

.modal-content {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.modal-book-cover {
    height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 6rem;
    border-radius: var(--border-radius-lg) var(--border-radius-lg) 0 0;
}

.modal-book-info {
    padding: 0 1.5rem 1.5rem;
}

.modal-book-info h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal-author {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.modal-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.modal-genre {
    padding: 0.25rem 0.75rem;
    background: var(--primary-color);
    border-radius: 50px;
    font-size: 0.875rem;
}

.modal-rating {
    color: var(--warning);
}

.modal-description {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}

.modal-preview {
    background: var(--surface-light);
    padding: 1.25rem;
    border-radius: var(--border-radius);
    margin-bottom: 1.5rem;
}

.modal-preview h4 {
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.preview-text {
    color: var(--text-secondary);
    font-style: italic;
    line-height: 1.8;
}

.modal-emotions h4 {
    margin-bottom: 0.75rem;
}

.emotion-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.emotion-tag {
    padding: 0.375rem 0.875rem;
    background: rgba(99, 102, 241, 0.2);
    border-radius: 50px;
    font-size: 0.875rem;
    color: var(--primary-light);
}

/* Footer */
.footer {
    text-align: center;
    padding: 1.5rem;
    background: var(--surface);
    border-top: 1px solid var(--surface-light);
    margin-top: auto;
}

.footer p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.footer a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

/* Responsive Design */
@media (min-width: 768px) {
    .header h1 {
        font-size: 2.5rem;
    }

    .modal-content {
        grid-template-columns: 250px 1fr;
    }

    .modal-book-cover {
        height: 100%;
        min-height: 400px;
        border-radius: var(--border-radius-lg) 0 0 var(--border-radius-lg);
    }

    .modal-book-info {
        padding: 1.5rem 1.5rem 1.5rem 0;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .tagline {
        font-size: 0.95rem;
    }

    .emotion-input-section {
        padding: 1.25rem;
    }

    .emoji-btn {
        font-size: 1.5rem;
        padding: 0.5rem;
    }

    .books-grid {
        grid-template-columns: 1fr;
    }

    .genre-tag {
        padding: 0.375rem 0.75rem;
        font-size: 0.8rem;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* No Results State */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.no-results-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.no-results h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
