/* ============================================
   Variables & Theme Setup
   ============================================ */
:root {
    /* Common Variables */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --spacing-2xl: 3rem;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --transition-fast: 0.15s ease;
    --transition-base: 0.25s ease;
    --transition-slow: 0.4s ease;
}

/* Dark Theme (Default) */
:root[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.9);
    --bg-modal: #1e293b;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --text-accent: #818cf8;

    --border-color: rgba(148, 163, 184, 0.1);
    --border-focus: #818cf8;

    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-bg: radial-gradient(circle at top right, #1e1b4b, #0f172a);
    --gradient-progress: linear-gradient(90deg, #6366f1, #a855f7);

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

/* Light Theme */
:root[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-card-hover: #ffffff;
    --bg-modal: #ffffff;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --text-accent: #6366f1;

    --border-color: rgba(148, 163, 184, 0.2);
    --border-focus: #6366f1;

    --gradient-primary: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --gradient-bg: radial-gradient(circle at top right, #e0e7ff, #f8fafc);
    --gradient-progress: linear-gradient(90deg, #6366f1, #a855f7);

    --shadow-sm: 0 2px 4px rgba(148, 163, 184, 0.1);
    --shadow-md: 0 4px 6px rgba(148, 163, 184, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(148, 163, 184, 0.1);
}

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

a {
    text-decoration: none;
    color: inherit;
}

.hidden {
    display: none !important;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    background-image: var(--gradient-bg);
    background-attachment: fixed;
    transition: background-color var(--transition-base), color var(--transition-base);
}

/* ============================================
   Header
   ============================================ */
.header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    padding-top: var(--spacing-md);
}

:root[data-theme="light"] .header {
    background: rgba(255, 255, 255, 0.8);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-lg) var(--spacing-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-lg);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
    animation: fadeInDown 0.6s ease-out;
}

.search-container {
    flex: 1;
    max-width: 500px;
    position: relative;
}

.search-input {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-lg);
    padding-left: 2.5rem;
    background: var(--bg-secondary);
    border: 2px solid transparent;
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.search-input:focus {
    outline: none;
    background: var(--bg-primary);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* ============================================
   Navigation Tabs
   ============================================ */
.nav-tabs-container {
    background: rgba(15, 23, 42, 0.5);
    border-bottom: 1px solid var(--border-color);
    padding: 0 var(--spacing-lg);
}

:root[data-theme="light"] .nav-tabs-container {
    background: rgba(255, 255, 255, 0.5);
}

.nav-tabs {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: var(--spacing-lg);
}

.nav-tab {
    padding: var(--spacing-md) var(--spacing-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: all var(--transition-base);
}

.nav-tab:hover {
    color: var(--text-primary);
}

.nav-tab.active {
    color: var(--text-accent);
}

.nav-tab.active::after {
    content: "";
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-primary);
    border-radius: 3px 3px 0 0;
}

/* ============================================
   Buttons
   ============================================ */
.btn {
    padding: var(--spacing-sm) var(--spacing-lg);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all var(--transition-base);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    /* Default for dark mode */
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

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

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

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

/* Light Mode Button Text Fix */
:root[data-theme="light"] .btn-primary {
    color: #1e293b !important;
    /* Dark grey for readability */
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
}

.btn-icon {
    padding: var(--spacing-sm);
    border-radius: 50%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-color);
}

.btn-icon:hover {
    transform: rotate(15deg) scale(1.1);
    background: var(--bg-tertiary);
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--text-accent);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    font-family: inherit;
    display: inline;
}

.btn-link:hover {
    color: var(--text-primary);
    text-decoration: none;
}

/* ============================================
   Notifications
   ============================================ */
.notification-wrapper {
    position: relative;
    z-index: 1000;
}

.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    border: 2px solid var(--bg-primary);
    animation: bounceIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.notification-dropdown {
    position: absolute;
    top: 120%;
    right: 0;
    width: min(300px, calc(100vw - 2rem));
    max-width: 90vw;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideDown 0.2s ease-out;
    z-index: 9999;
}

.notification-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-tertiary);
}

.notification-header h4 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.notification-list {
    max-height: 350px;
    overflow-y: auto;
}

.notification-item {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: start;
    gap: 0.75rem;
}

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

.notification-item:hover {
    background: var(--bg-tertiary);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--text-accent);
}

.notification-icon {
    font-size: 1.2rem;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }

    80% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Main Container
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-2xl) var(--spacing-lg);
}

/* ============================================
   Statistics Section
   ============================================ */
.statistics-section {
    margin-bottom: var(--spacing-2xl);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
}

.stat-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    padding: var(--spacing-lg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    transition: all var(--transition-base);
    animation: slideUp 0.5s ease-out backwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.2s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.3s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.4s;
}

.stat-card:nth-child(5) {
    animation-delay: 0.5s;
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: var(--text-accent);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.stat-info h3 {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

/* ============================================
   Controls Section
   ============================================ */
.controls {
    margin-bottom: var(--spacing-xl);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.category-tabs {
    display: flex;
    gap: var(--spacing-xs);
    background: var(--bg-card);
    padding: var(--spacing-xs);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
}

.category-tab {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: transparent;
    color: var(--text-secondary);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-base);
}

.category-tab:hover {
    color: var(--text-primary);
    background: rgba(99, 102, 241, 0.1);
}

.category-tab.active {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

.filter-controls {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex-wrap: wrap;
}

.data-controls {
    display: flex;
    gap: var(--spacing-md);
}

.select-input {
    padding: var(--spacing-sm) var(--spacing-lg);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all var(--transition-base);
}

.select-input:focus {
    outline: none;
    border-color: var(--border-focus);
}

/* ============================================
   Book Grid
   ============================================ */
.books-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.book-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    animation: fadeInScale 0.5s ease-out both;
}

.book-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-focus);
}

/* List View Styles */
.books-grid.list-view {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    background: transparent;
    padding: 0;
}

.book-list-header {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1fr;
    gap: 1.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

@media (max-width: 768px) {
    .book-list-header {
        display: none;
    }
}

.book-list-item {
    display: grid;
    grid-template-columns: 60px 2fr 1fr 1fr;
    align-items: center;
    gap: 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1.5rem;
    transition: all var(--transition-base);
    cursor: pointer;
}

.book-list-item:hover {
    border-color: var(--border-focus);
    background: var(--bg-card-hover);
    transform: translateX(8px);
    box-shadow: var(--shadow-md);
}

.book-list-cover-container {
    width: 45px;
    height: 65px;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.book-list-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: var(--bg-tertiary);
}

.book-list-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.book-list-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-list-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-list-badges {
    display: flex;
    gap: 10px;
    align-items: center;
}

.book-list-progress-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

@media (max-width: 768px) {
    .book-list-item {
        grid-template-columns: 60px 1fr;
        gap: 1rem;
        padding: 1rem;
    }

    .book-list-badges,
    .book-list-progress-section {
        grid-column: 1 / span 2;
        margin-top: 5px;
    }

    .book-list-badges {
        justify-content: flex-start;
    }
}


/* Pagination Styles */
.pagination-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
    padding: 1rem;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-base);
    font-size: 0.9rem;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--border-focus);
}

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

.pagination-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.view-toggle-btn.active {
    background: var(--bg-tertiary) !important;
    color: var(--text-accent) !important;
}

.book-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--spacing-xs);
    line-height: 1.3;
}

.book-author {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.book-category-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-accent);
    margin-top: var(--spacing-sm);
    text-transform: capitalize;
}

.book-language-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: rgba(240, 147, 251, 0.1);
    border: 1px solid rgba(240, 147, 251, 0.2);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: #d946ef;
    margin-top: var(--spacing-sm);
    margin-left: var(--spacing-xs);
}

:root[data-theme="light"] .book-language-badge {
    background: rgba(217, 70, 239, 0.1);
    color: #c026d3;
    border-color: rgba(217, 70, 239, 0.2);
}

.book-progress {
    margin: var(--spacing-md) 0;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xs);
    font-size: 0.85rem;
}

.progress-bar-container {
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--gradient-progress);
    border-radius: 999px;
    transition: width var(--transition-slow);
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s infinite;
}

/* ============================================
   Vocabulary Section
   ============================================ */
.vocabulary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-2xl);
}

.word-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--spacing-lg);
    transition: all var(--transition-base);
    position: relative;
    animation: fadeInScale 0.5s ease-out both;
}

.word-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-focus);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-md);
}

.word-term {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.word-definition {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: var(--spacing-md);
    line-height: 1.5;
}

.word-context-box {
    background: var(--bg-secondary);
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--text-accent);
    margin-top: var(--spacing-md);
}

.word-context {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.word-actions {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.word-card:hover .word-actions {
    opacity: 1;
}

.btn-delete-word {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-delete-word:hover {
    background: #ef4444;
    color: white;
}

/* ============================================
   Modals
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    padding: var(--spacing-lg);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: 99999 !important;
}

.modal-content {
    background: var(--bg-modal);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--spacing-2xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-xl);
}

.modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
    transform: rotate(90deg);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

.form-label {
    display: block;
    margin-bottom: var(--spacing-xs);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.form-input,
.form-textarea {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-base);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.form-row {
    display: flex;
    gap: var(--spacing-md);
}

.form-row .form-group {
    flex: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
    margin-top: var(--spacing-xl);
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-40px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   Empty State
   ============================================ */
.empty-state {
    text-align: center;
    padding: var(--spacing-2xl);
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-lg);
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.hidden {
    display: none !important;
}

/* Star Rating */
.star-rating {
    display: flex;
    gap: 0.25rem;
}

.star {
    font-size: 1.25rem;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.star.filled {
    color: #fbbf24;
}

.star:hover {
    transform: scale(1.2);
}

/* Quotes Section Styles */
.quotes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1rem 0;
}

.quote-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quote-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.quote-content {
    font-size: 1.1rem;
    font-style: italic;
    color: var(--text-primary);
    line-height: 1.6;
}

.quote-text {
    margin: 0;
}

.quote-text::before {
    /* content: "❝";  Removed as per user request */
    content: none;
    color: var(--primary-color);
    font-size: 1.5rem;
    line-height: 1;
    margin-right: 0.2rem;
}

.quote-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.quote-author {
    font-weight: 600;
    margin: 0;
}

.quote-meta {
    display: flex;
    gap: 0.8rem;
    font-size: 0.85rem;
}

.quote-tags {
    font-size: 0.85rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    align-self: flex-start;
}

/* Quotes Split Fields Styles */
.quote-source-info {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.quote-book {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
    margin: 0;
}

.quote-author-name {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin: 0;
    font-style: normal;
}

.quote-meta-row {
    display: flex;
    align-items: center;
}

/* Social System */
.social-container {
    padding: 1rem;
}

.social-grid {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 2rem;
}

@media (max-width: 768px) {
    .social-grid {
        grid-template-columns: 1fr;
    }
}

.user-list,
.feed-list {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.user-card,
.feed-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 1rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.feed-card {
    flex-direction: column;
    align-items: flex-start;
}

.search-results {
    position: absolute;
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    display: none;
}

.search-result-item {
    padding: 0.8rem;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8em;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-success {
    background: var(--success);
    color: white;
}

/* User Avatar Fixed Size */
.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient-primary);
    color: white;
    font-weight: bold;
    font-size: 0.9rem;
    overflow: hidden;
    /* Critical for consistency */
}

.user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* User Avatar Small */
.user-avatar-small {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* ============================================
   Forum Section - Premium Redesign
   ============================================ */

/* Main Container Limit */
#forumView {
    max-width: 900px;
    margin: 0 auto;
    padding-bottom: 4rem;
}

/* --- TOPIC LIST CARD --- */
.forum-topic-card {
    display: grid;
    grid-template-columns: 1fr auto;
    /* Content | Sidebar */
    gap: 1.5rem;
    background: var(--bg-card);
    /* Fallback */
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.7) 0%, rgba(15, 23, 42, 0.8) 100%);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.2s ease-in-out;
    cursor: pointer;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.forum-topic-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.95) 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.forum-topic-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0%;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s ease;
}

.forum-topic-card:hover::after {
    width: 100%;
}

/* Content Area */
.forum-card-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.forum-topic-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.4;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Meta Data Row */
.forum-topic-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.meta-separator {
    color: var(--border-color);
    font-size: 0.7rem;
}

.meta-item.author {
    color: var(--text-primary);
    font-weight: 500;
}

/* Badge Styles */
.forum-badge {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 0;
    color: var(--text-accent);
}

.forum-badge.general {
    color: #94a3b8;
}

.forum-badge.books {
    color: #818cf8;
}

.forum-badge.authors {
    color: #f472b6;
}

.forum-badge.recommendations {
    color: #34d399;
}

.spoiler-tag {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

/* Action Buttons */
.action-btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.action-btn-icon:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.action-btn-icon.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
    color: #ef4444;
}


/* --- THREAD DETAILS VIEW --- */

/* Main Post Styling */
.forum-post.main-post {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.forum-post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.forum-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.forum-username {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
}

.forum-date {
    font-size: 0.8rem;
    color: var(--text-tertiary);
}

.forum-content {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-primary);
}

/* Comments Section */
.replies-header {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.replies-header::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

/* Reply Cards */
.forum-reply-wrapper {
    margin-bottom: 1rem;
}

.forum-post.reply-post {
    background: rgb(30, 41, 59);
    /* Flat slate bg */
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    position: relative;
}

.forum-post.nested-reply {
    background: rgba(30, 41, 59, 0.5);
    /* Slightly lighter/transparent */
    border-left: 3px solid var(--border-color);
}

.forum-post.reply-post .forum-post-header {
    border-bottom: none;
    /* No separator for compact replies */
    padding-bottom: 0;
    margin-bottom: 0.75rem;
}

.forum-post.reply-post .forum-user-info {
    gap: 0.75rem;
}

.forum-post.reply-post .forum-avatar-sm {
    width: 28px;
    height: 28px;
}

.forum-post.reply-post .forum-content {
    font-size: 0.95rem;
    color: var(--text-secondary);
    /* Softer reading for comments */
}

/* Actions & Buttons in Forum */
.btn-icon-sm {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    padding: 6px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-sm:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.btn-icon-sm.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.2);
}

/* Spoiler Modernized */
.spoiler-wrapper {
    position: relative;
    margin: 1rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.spoiler-content {
    filter: blur(12px) grayscale(0.5);
    user-select: none;
    cursor: pointer;
    transition: all 0.4s ease;
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
}

.spoiler-warning-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    background: rgba(0, 0, 0, 0.6);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    pointer-events: none;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    z-index: 10;
}

.spoiler-content.revealed {
    filter: none;
    user-select: text;
    background: transparent;
    cursor: auto;
    padding: 0;
}

/* Delete Button Wrapper */
.delete-btn-wrapper {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin-left: 1rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.delete-btn-wrapper:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    transform: scale(1.1);
}

/* UI Reset for usernames to prevent inherited lines */
.forum-username,
.user-name,
.author,
.meta-item.author,
strong {
    text-decoration: none !important;
    border-bottom: none !important;
    box-shadow: none !important;
}

/* Interactive Censorship: Blur until clicked */
.censored-word {
    filter: blur(5px);
    -webkit-filter: blur(5px);
    background: rgba(0, 0, 0, 0.5);
    /* Slightly darker for better hiding */
    color: transparent !important;
    cursor: pointer;
    user-select: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 2px 6px;
    margin: 0 2px;
    border-radius: 4px;
    display: inline-block;
    vertical-align: middle;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-decoration: none !important;
}

.censored-word:hover {
    background: rgba(0, 0, 0, 0.7);
    filter: blur(3px);
}

.censored-word.revealed {
    filter: none;
    -webkit-filter: none;
    background: rgba(239, 68, 68, 0.15);
    color: inherit !important;
    user-select: text;
    padding: 0 2px;
    border-color: rgba(239, 68, 68, 0.3);
}

.censored-word::after {
    content: '👁️ Click';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.65rem;
    font-weight: bold;
    color: white;
    opacity: 0.6;
    transition: opacity 0.3s;
    white-space: nowrap;
    pointer-events: none;
}

.censored-word:hover::after {
    opacity: 1;
}

.censored-word.revealed::after {
    display: none;
}

/* Base styles for strikethrough (non-censored) */
.tachado,
.strikethrough,
.completed-text,
.abandoned-text {
    text-decoration: line-through !important;
    text-decoration-color: currentColor;
    text-decoration-thickness: 1px;
}

/* ============================================
   Skeleton & Loading States
   ============================================ */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-comment {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    margin-bottom: 15px;
}

/* Pending Comment State */
.comment-card.pending {
    border: 1px dashed var(--text-accent);
    opacity: 0.8;
}

.comment-card.pending::before {
    content: "🕒 Pendiente de aprobación";
    position: absolute;
    top: -10px;
    right: 15px;
    background: var(--text-accent);
    color: white;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: bold;
}

/* ============================================
   Animations
   ============================================ */
@keyframes commentEntrance {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.comment-card {
    animation: commentEntrance 0.3s ease-out backwards;
    transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

.comment-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--text-accent);
}