/* CSS Variables for Theming */
:root {
    --primary-color: #8B4513;
    --secondary-color: #D2B48C;
    --tertiary-color: #F4A460;
    --bg-primary: #FDF5E6;
    --bg-secondary: #F5DEB3;
    --bg-tertiary: #DEB887;
    --shelf-color: #CD853F;
    --accent-color: #A0522D;
    --border-color: #8B4513;
    --hover-color: #D2691E;
    --book-color-1: #8B4513;
    --book-color-2: #A0522D;
    --book-color-3: #CD853F;
    --book-color-4: #D2691E;
    --book-color-5: #B8860B;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Georgia, serif;
    background: var(--bg-primary);
    color: var(--primary-color);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: 80px;
    background: var(--bg-secondary);
    border-right: 3px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 30px;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
}

.sidebar-btn {
    width: 60px;
    height: 60px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: linear-gradient(145deg, var(--bg-tertiary), var(--secondary-color));
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    transition: all 0.3s ease;
    position: relative;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.sidebar-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    background: linear-gradient(145deg, var(--hover-color), var(--tertiary-color));
}

.sidebar-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.trophy-btn {
    position: relative;
}

.plant-trophy {
    position: absolute;
    top: -5px;
    right: -5px;
    font-size: 16px;
    background: var(--bg-primary);
    border-radius: 50%;
    padding: 2px;
    border: 1px solid var(--border-color);
}

/* SVG Icon Styling */
.trophy-icon svg,
.add-icon svg,
.theme-icon svg,
.chat-icon svg,
.music-icon svg,
.auth-icon svg {
    width: 28px;
    height: 28px;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.sidebar-btn:hover .trophy-icon svg,
.sidebar-btn:hover .add-icon svg,
.sidebar-btn:hover .theme-icon svg,
.sidebar-btn:hover .music-icon svg,
.sidebar-btn:hover .auth-icon svg {
    color: var(--accent-color);
}

/* User Status Badge */
.user-status {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-primary);
}

.user-status.hidden {
    display: none;
}

/* Main Bookshelf Container */
.bookshelf-container {
    flex: 1;
    display: flex;
    padding: 15px;
    gap: 15px;
    background: var(--bg-primary);
    overflow: hidden;
}

.shelf-section {
    flex: 1;
    background: var(--bg-secondary);
    border: 3px solid var(--border-color);
    border-radius: 15px;
    padding: 15px;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.1);
}

.shelf-title {
    text-align: center;
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--primary-color);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.shelf-rows {
    height: calc(100% - 50px);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.shelf-row {
    flex: 1;
    background: linear-gradient(180deg, var(--tertiary-color), var(--secondary-color));
    border: 2px solid var(--secondary-color);
    border-radius: 8px;
    padding: 12px;
    min-height: 170px; /* Adjusted for 120-140px book height range */
    display: flex;
    align-items: flex-end;
    gap: 1px; /* Reduced gap for narrow books */
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.15);
}

.shelf-row::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--secondary-color), var(--bg-tertiary), var(--secondary-color));
    border-radius: 0 0 6px 6px;
    opacity: 0.7;
}

/* Book Styling */
.book {
    /* Default dimensions - will be overridden by JavaScript */
    width: 22px;
    height: 130px;
    min-width: 15px;
    max-width: 30px;
    min-height: 120px;
    max-height: 140px;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.4);
    margin: 0 1px; /* Reduced spacing for narrow books */
    /* No border for clean look */
    /* Background will be set by JavaScript with random colors */
}

.book:hover {
    transform: translateY(-5px);
    box-shadow: 2px 7px 10px rgba(0,0,0,0.4);
}

.book.dragging {
    opacity: 0.7;
    transform: rotate(5deg);
    z-index: 1000;
}

.book-title {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'EB Garamond', serif;
    font-size: 12px; /* Increased font size for better readability */
    font-weight: 400; /* Regular weight, not bold */
    color: white;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
    text-align: center;
    padding: 12px 2px; /* Increased padding for larger font */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-height: 110px; /* Adjusted for 120-140px book height */
    line-height: 1.3; /* Slightly increased for better readability */
    z-index: 2;
    position: relative;
}

/* SVG book spines - pseudo-elements removed in favor of dynamic SVG backgrounds */

/* Spider Notification */
.spider-notification {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    z-index: 100;
    pointer-events: none;
}

.spider-notification.hidden {
    display: none;
}

.spider {
    font-size: 16px;
    animation: wiggle 1s ease-in-out infinite;
}

@keyframes wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}

.spider-message {
    max-width: 200px;
    line-height: 1.3;
}

/* Book Hover Tooltip */
.book-tooltip {
    position: absolute;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 999;
    font-size: 12px;
    line-height: 1.4;
    color: var(--primary-color);
    min-width: 180px;
    max-width: 250px;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-5px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    visibility: hidden;
}

.book-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
    visibility: visible;
}

.book-tooltip .tooltip-title {
    font-weight: bold;
    color: var(--accent-color);
    margin-bottom: 4px;
    font-size: 13px;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.book-tooltip .tooltip-author {
    color: var(--secondary-color);
    font-style: italic;
    margin-bottom: 4px;
}

.book-tooltip .tooltip-genre {
    color: var(--primary-color);
    font-size: 11px;
    margin-bottom: 4px;
}

.book-tooltip .tooltip-rating {
    color: var(--accent-color);
    font-size: 11px;
}

.book-tooltip .tooltip-stars {
    color: #FFD700;
    margin-left: 4px;
}

/* Modal Styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    padding: 30px;
    border-radius: 15px;
    border: 3px solid var(--border-color);
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 90%;
}

.modal-content h3 {
    text-align: center;
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 22px;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
    width: 100%;
    padding: 12px;
    margin: 10px 0;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    font-family: Georgia, serif;
    font-size: 14px;
    color: var(--primary-color);
}

.modal-content textarea {
    height: 100px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 12px 24px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--secondary-color);
    color: var(--primary-color);
    font-family: Georgia, serif;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-buttons button:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

.cancel-btn {
    background: var(--bg-tertiary) !important;
}

.delete-btn {
    background: #CD5C5C !important;
    color: white !important;
}

/* Rating Stars */
.rating-stars {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin: 20px 0;
}

.star {
    font-size: 30px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.2s ease;
}

.star:hover,
.star.active {
    color: #FFD700;
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.theme-option {
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
}

.theme-option:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.theme-option.active {
    border-color: var(--accent-color);
    background: var(--tertiary-color);
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
}

.theme-name {
    font-weight: bold;
    margin-bottom: 10px;
    font-size: 14px;
    color: var(--primary-color);
}

.theme-preview {
    height: 40px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.theme-preview[data-theme="original"] {
    background: linear-gradient(90deg, #8B4513, #D2B48C, #F4A460, #CD853F, #A0522D);
}

.theme-preview[data-theme="lavender-mist"] {
    background: linear-gradient(90deg, #C2B2B4, #6B4E71, #3A4454, #53687E, #F5DDDD);
}

.theme-preview[data-theme="forest-earth"] {
    background: linear-gradient(90deg, #1B2021, #51513D, #A6A667, #E3DC95, #E3DCC2);
}

.theme-preview[data-theme="ocean-bloom"] {
    background: linear-gradient(90deg, #00BFB2, #1A5E63, #028090, #F0F3BD, #C64191);
}

.theme-preview[data-theme="sunset-glow"] {
    background: linear-gradient(90deg, #003049, #D62828, #F77F00, #FCBF49, #EAE2B7);
}

.theme-preview[data-theme="ember-flame"] {
    background: linear-gradient(90deg, #4F000B, #720026, #CE4257, #FF7F51, #FF9B54);
}

/* Trophy Collection Modal */
.trophy-modal {
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
}

.trophy-instructions {
    text-align: center;
    color: var(--secondary-color);
    font-style: italic;
    margin-bottom: 20px;
}

.trophy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.trophy-item {
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    background: var(--bg-secondary);
    position: relative;
}

.trophy-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-color: var(--accent-color);
}

.trophy-item.dragging {
    opacity: 0.7;
    cursor: grabbing;
    transform: rotate(5deg) scale(0.9);
}

.trophy-item.unlocked {
    border-color: var(--accent-color);
    background: var(--tertiary-color);
}

.trophy-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.trophy-icon-large {
    font-size: 32px;
    margin-bottom: 8px;
}

.trophy-name {
    font-size: 12px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.trophy-requirement {
    font-size: 10px;
    color: var(--secondary-color);
}

.trophy-progress {
    font-size: 9px;
    color: var(--accent-color);
    font-weight: bold;
    margin-top: 4px;
}

.genre-badges-section {
    border-top: 2px solid var(--border-color);
    padding-top: 20px;
}

.genre-badges-section h4 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.genre-badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.genre-badge {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: center;
    background: var(--bg-tertiary);
}

.genre-badge.earned {
    border-color: var(--accent-color);
    background: var(--tertiary-color);
}

.genre-name {
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 4px;
    color: var(--primary-color);
}

.genre-progress {
    font-size: 9px;
    color: var(--secondary-color);
}

.genre-tier {
    font-size: 14px;
    margin-bottom: 4px;
}

/* Trophy decorations on shelves */
.shelf-decoration {
    position: absolute;
    top: -15px;
    z-index: 10;
    cursor: pointer;
    transition: all 0.3s ease;
}

.shelf-decoration:hover {
    transform: scale(1.1);
}

.shelf-decoration.trophy {
    font-size: 20px;
}

/* Drop zones for trophies */
.shelf-row.trophy-drop-zone {
    border: 2px dashed var(--hover-color);
    background: linear-gradient(180deg, var(--tertiary-color), var(--bg-tertiary));
}

/* Drop Zone Styling */
.shelf-row.drag-over {
    background: linear-gradient(180deg, var(--hover-color), var(--tertiary-color));
    border: 3px dashed var(--primary-color);
    transform: scale(1.02);
    box-shadow: inset 0 0 15px rgba(0,0,0,0.3);
}

.shelf-row.drag-over::before {
    background: linear-gradient(90deg, var(--primary-color), var(--hover-color), var(--primary-color));
}

/* Audio Control Modal */
.audio-modal {
    max-width: 400px;
}

.audio-controls {
    margin: 20px 0;
}

.audio-control-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.control-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-icon {
    font-size: 20px;
}

.control-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
}

/* Toggle Switch Styling */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background-color: var(--accent-color);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider:hover {
    background-color: var(--secondary-color);
}

input:checked + .slider:hover {
    background-color: var(--hover-color);
}

/* Volume Control */
.volume-control {
    margin-top: 25px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.volume-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.volume-slider {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-secondary);
    outline: none;
    appearance: none;
    margin: 0 10px;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.volume-slider::-webkit-slider-thumb:hover {
    background: var(--hover-color);
    transform: scale(1.1);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent-color);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

.volume-value {
    font-size: 12px;
    color: var(--secondary-color);
    font-weight: 500;
    margin-left: 10px;
}

/* Audio Test Section */
.audio-test-section {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    text-align: center;
}

.test-btn {
    padding: 10px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    margin-bottom: 8px;
}

.test-btn:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

.test-info {
    display: block;
    font-size: 11px;
    color: var(--secondary-color);
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: 80px;
        flex-direction: row;
        padding: 10px 20px;
        gap: 20px;
    }
    
    .sidebar-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .bookshelf-container {
        flex-direction: column;
        padding: 10px;
    }
    
    .shelf-title {
        font-size: 20px;
    }
    
    .book {
        min-width: 12px !important;
        max-width: 25px !important;
        min-height: 90px !important;
        max-height: 110px !important;
        margin: 0 0.5px !important;
    }
    
    .book-title {
        font-size: 10px;
        padding: 8px 1px;
        max-height: 85px;
        line-height: 1.2;
    }
    
    .shelf-row {
        min-height: 130px !important;
        gap: 2px !important;
        padding: 8px !important;
    }
    
    /* Mobile tooltip adjustments */
    .book-tooltip {
        font-size: 11px;
        padding: 10px;
        min-width: 150px;
        max-width: 200px;
    }
    
    .book-tooltip .tooltip-title {
        font-size: 12px;
    }
    
    /* Audio control modal adjustments */
    .audio-modal {
        max-width: 300px;
    }
    
    .audio-controls {
        margin: 15px 0;
    }
    
    .audio-control-item {
        margin-bottom: 15px;
    }
    
    .toggle-switch {
        width: 40px;
        height: 20px;
    }
    
    .slider {
        width: 38px;
        height: 18px;
    }
    
    .slider:before {
        height: 14px;
        width: 14px;
    }
    
    .volume-control {
        margin-top: 20px;
    }
    
    .volume-slider {
        width: 150px;
        margin: 0 10px;
    }
    
    /* SVG book spines automatically scale for mobile */
}

/* Hide n8n default floating button */
.n8n-chat-button,
[data-n8n-chat-button],
.n8n-chat-fab,
[data-n8n-chat-fab] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Chat Container Styles */
#chat-container {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    z-index: 10000 !important;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3) !important;
    border-radius: 12px !important;
    overflow: hidden !important;
    border: 2px solid var(--border-color) !important;
    width: 400px !important;
    height: 600px !important;
}

/* Custom Chat Window Styling */
.chat-window {
    width: 100%;
    height: 100%;
    background: linear-gradient(180deg, var(--primary-color) 0%, var(--primary-color) 80px, var(--bg-primary) 80px, var(--bg-primary) 100%);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    font-family: Georgia, serif;
    overflow: hidden;
}

.chat-header {
    background: transparent;
    color: var(--bg-primary);
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 80px;
    position: relative;
}

.welcome-title {
    margin: 0;
    font-size: 32px;
    font-weight: normal;
    font-family: Georgia, serif;
    color: var(--bg-primary);
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.chat-close-btn {
    background: none;
    border: none;
    color: var(--bg-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.chat-messages {
    flex: 1;
    padding: 25px 20px;
    overflow-y: auto;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-message {
    max-width: 85%;
    margin-bottom: 8px;
}

.chat-message.user {
    align-self: flex-end;
    text-align: right;
}

.chat-message.assistant {
    align-self: flex-start;
}

.chat-message.small-message {
    max-width: 60%;
}

.chat-message.user .message-content {
    background: #E8D5B7;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    padding: 15px 20px;
    border-radius: 25px 25px 8px 25px;
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
    font-family: Georgia, serif;
    font-size: 16px;
    position: relative;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.1);
}

.chat-message.assistant .message-content {
    background: var(--primary-color);
    color: #F5E6D3;
    border: none;
    padding: 15px 20px;
    border-radius: 25px 25px 25px 8px;
    display: inline-block;
    max-width: 100%;
    word-wrap: break-word;
    font-family: Georgia, serif;
    font-size: 16px;
    position: relative;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
}

.chat-message.small-message .message-content {
    font-size: 14px;
    padding: 10px 16px;
}

/* Chat bubble tails */
.chat-message.user .message-content::after {
    content: '';
    position: absolute;
    bottom: 8px;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: #E8D5B7;
    border-left-color: #E8D5B7;
    transform: rotate(45deg);
}

.chat-message.assistant .message-content::after {
    content: '';
    position: absolute;
    bottom: 8px;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-top-color: var(--primary-color);
    border-right-color: var(--primary-color);
    transform: rotate(-45deg);
}

.chat-message.typing .message-content {
    font-style: italic;
    opacity: 0.7;
    animation: pulse 1.5s infinite;
}

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

.message-time {
    font-size: 11px;
    color: var(--accent-color);
    opacity: 0.6;
    margin-top: 4px;
}

.chat-message.user .message-time {
    text-align: right;
}

.chat-message.assistant .message-time {
    text-align: left;
}

.chat-input-container {
    padding: 15px 20px 20px 20px;
    background: var(--bg-primary);
    display: flex;
    gap: 12px;
    align-items: center;
    position: relative;
}

.chat-input-container::before {
    content: 'Type your message...';
    position: absolute;
    bottom: 100%;
    left: 20px;
    font-family: Georgia, serif;
    font-size: 22px;
    color: var(--primary-color);
    margin-bottom: 8px;
}

#chat-input {
    flex: 1;
    background: #FFFFFF;
    border: 3px solid var(--primary-color);
    color: var(--primary-color);
    padding: 15px 20px;
    border-radius: 30px;
    font-size: 16px;
    font-family: Georgia, serif;
    outline: none;
    transition: all 0.3s ease;
}

#chat-input:focus {
    border-color: var(--hover-color);
    box-shadow: 0 2px 12px rgba(0,0,0,0.1);
}

#chat-input::placeholder {
    color: transparent;
}

#chat-send-btn {
    background: var(--primary-color);
    color: #F5E6D3;
    border: none;
    padding: 15px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 3px 8px rgba(0,0,0,0.2);
}

#chat-send-btn:hover {
    background: var(--hover-color);
    transform: translateY(-2px);
    box-shadow: 2px 5px 12px rgba(0,0,0,0.3);
}

#chat-send-btn:active {
    transform: translateY(0);
}

/* Chat button active state */
.chat-btn.active {
    background: linear-gradient(145deg, var(--hover-color), var(--primary-color)) !important;
    transform: translateY(-2px) !important;
}

.chat-btn.active .chat-icon svg {
    color: var(--bg-primary) !important;
}

/* Hide chat widget initially */
#chat-container {
    display: none;
}

/* Mobile responsiveness for chat widget */
@media (max-width: 768px) {
    #chat-container {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        width: calc(100vw - 20px) !important;
        max-width: none !important;
        height: 60vh !important;
    }
}

/* Login Modal Styling */
.login-modal {
    z-index: 10001 !important;
}

.login-modal.hidden {
    display: none;
}

.login-content {
    max-width: 450px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h2 {
    font-size: 28px;
    color: var(--primary-color);
    margin-bottom: 8px;
    font-weight: 600;
}

.login-subtitle {
    color: var(--secondary-color);
    font-size: 16px;
    font-style: italic;
}

.login-tabs {
    display: flex;
    margin-bottom: 25px;
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.login-tab {
    flex: 1;
    padding: 15px 20px;
    background: var(--bg-tertiary);
    border: none;
    cursor: pointer;
    font-family: Georgia, serif;
    font-size: 16px;
    color: var(--primary-color);
    transition: all 0.3s ease;
    border-right: 1px solid var(--border-color);
}

.login-tab:last-child {
    border-right: none;
}

.login-tab:hover {
    background: var(--secondary-color);
}

.login-tab.active {
    background: var(--primary-color);
    color: var(--bg-primary);
    font-weight: bold;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.form-group {
    margin-bottom: 20px;
}

.form-group input {
    width: 100%;
    padding: 15px 18px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-secondary);
    font-family: Georgia, serif;
    font-size: 16px;
    color: var(--primary-color);
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: var(--bg-primary);
    box-shadow: 0 0 0 3px rgba(139, 69, 19, 0.1);
}

.form-group input::placeholder {
    color: var(--secondary-color);
    opacity: 0.8;
}

.auth-btn {
    /* width: 100%;
    padding: 15px 20px;
    border: 2px solid var(--border-color);
    border-radius: 10px; */
    font-family: Georgia, serif;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    /* margin-bottom: 15px; */
    text-transform: none;
}

.auth-btn.primary {
    background: var(--primary-color);
    color: var(--bg-primary);
    border-color: var(--primary-color);
}

.auth-btn.primary:hover {
    background: var(--accent-color);
    border-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.auth-btn.secondary {
    background: var(--bg-tertiary);
    color: var(--primary-color);
    border-color: var(--secondary-color);
}

.auth-btn.secondary:hover {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.login-divider {
    text-align: center;
    margin: 25px 0;
    position: relative;
}

.login-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.login-divider span {
    background: var(--bg-primary);
    padding: 0 20px;
    color: var(--secondary-color);
    font-size: 14px;
    position: relative;
}

.login-footer {
    text-align: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    color: var(--secondary-color);
    font-size: 12px;
    font-style: italic;
}

/* Login form validation states */
.form-group input.invalid {
    border-color: #CD5C5C;
    background: #FFF5F5;
}

.form-group .error-message {
    color: #CD5C5C;
    font-size: 12px;
    margin-top: 5px;
    display: block;
}

/* Loading state for auth buttons */
.auth-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    position: relative;
}

.auth-btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Mobile login modal adjustments */
@media (max-width: 768px) {
    .login-content {
        max-width: 95%;
        padding: 20px;
    }
    
    .login-header h2 {
        font-size: 24px;
    }
    
    .login-subtitle {
        font-size: 14px;
    }
    
    .login-tab {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .form-group input {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .auth-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
}

/* Recommendations Interface */
.recommendation-divider {
    text-align: center;
    margin: 25px 0 15px 0;
    position: relative;
}

.recommendation-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-color);
}

.recommendation-divider span {
    background: var(--bg-primary);
    padding: 0 15px;
    color: var(--secondary-color);
    font-size: 13px;
    font-style: italic;
    position: relative;
}

.magic-btn {
    width: 100%;
    padding: 15px 20px;
    border: 2px solid var(--accent-color);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent-color), var(--hover-color));
    color: var(--bg-primary);
    font-family: Georgia, serif;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    position: relative;
    overflow: hidden;
}

.magic-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 19, 0.3);
    background: linear-gradient(135deg, var(--hover-color), var(--accent-color));
}

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

.magic-btn .magic-icon {
    margin-right: 8px;
    font-size: 18px;
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.1); }
}

/* Recommendations Modal */
.recommendations-content {
    max-width: 600px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.recommendations-loading {
    text-align: center;
    padding: 40px 20px;
}

.recommendations-loading.hidden {
    display: none;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-tertiary);
    border-top: 4px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.recommendations-loading p {
    color: var(--secondary-color);
    font-style: italic;
    font-size: 16px;
}

.recommendations-list {
    margin: 20px 0;
}

.recommendation-item {
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.recommendation-item:hover {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.recommendation-title {
    font-size: 18px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 8px;
}

.recommendation-author {
    font-size: 14px;
    color: var(--secondary-color);
    font-style: italic;
    margin-bottom: 8px;
}

.recommendation-genre {
    display: inline-block;
    background: var(--accent-color);
    color: var(--bg-primary);
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 11px;
    font-weight: bold;
    margin-bottom: 10px;
}

.recommendation-reason {
    font-size: 13px;
    color: var(--primary-color);
    line-height: 1.4;
    font-style: italic;
    opacity: 0.9;
}

.add-recommendation-btn {
    background: var(--accent-color);
    color: var(--bg-primary);
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
}

.add-recommendation-btn:hover {
    background: var(--hover-color);
    transform: translateY(-1px);
}

.recommendations-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--secondary-color);
    font-style: italic;
}

.recommendations-error {
    text-align: center;
    padding: 30px 20px;
    color: #CD5C5C;
    background: #FFF5F5;
    border: 1px solid #CD5C5C;
    border-radius: 8px;
    margin: 20px 0;
}

/* Mobile recommendations adjustments */
@media (max-width: 768px) {
    .recommendations-content {
        max-width: 100%;
        padding: 15px;
    }
    
    .magic-btn {
        padding: 12px 18px;
        font-size: 14px;
    }
    
    .recommendation-item {
        padding: 15px;
    }
    
    .recommendation-title {
        font-size: 16px;
    }
    
    .recommendation-author {
        font-size: 13px;
    }
    
    .recommendation-reason {
        font-size: 12px;
    }
}

/* User Preferences Modal */
.preferences-content {
    max-width: 700px;
    width: 95%;
    max-height: 80vh;
    overflow-y: auto;
}

.preferences-section {
    margin-bottom: 30px;
}

.preferences-section h4 {
    color: var(--primary-color);
    font-size: 20px;
    margin-bottom: 8px;
}

.preference-description {
    color: var(--secondary-color);
    font-size: 14px;
    font-style: italic;
    margin-bottom: 20px;
    line-height: 1.4;
}

.genre-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.genre-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-tertiary);
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.genre-option:hover {
    border-color: var(--accent-color);
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.genre-option.selected {
    border-color: var(--accent-color);
    background: var(--accent-color);
    color: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 69, 19, 0.3);
}

.genre-option.selected .genre-name {
    color: var(--bg-primary);
    font-weight: bold;
}

.genre-emoji {
    font-size: 24px;
    margin-bottom: 8px;
}

.genre-name {
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.selected-genres-display {
    padding: 15px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 10px;
}

.selected-label {
    font-weight: bold;
    color: var(--primary-color);
}

#selected-genres-text {
    color: var(--secondary-color);
    font-style: italic;
}

.primary-btn {
    background: var(--accent-color);
    color: var(--bg-primary);
    border: 2px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px 24px;
    font-family: Georgia, serif;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover {
    background: var(--hover-color);
    border-color: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Genre selection limit indicator */
.genre-selection-limit {
    color: #CD5C5C;
    font-size: 12px;
    font-style: italic;
    text-align: center;
    margin-top: 10px;
}

/* Mobile preferences adjustments */
@media (max-width: 768px) {
    .preferences-content {
        max-width: 100%;
        padding: 15px;
    }
    
    .genre-selection-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 10px;
    }
    
    .genre-option {
        padding: 12px 8px;
    }
    
    .genre-emoji {
        font-size: 20px;
        margin-bottom: 6px;
    }
    
    .genre-name {
        font-size: 11px;
    }
}