/**
 * Custom Styles - Dark Theme for NightRead
 * 
 * Based on html_ui/home.html design
 */

:root {
    --bg-body: #0c0c0f;
    --bg-surface: #1c1c1e;
    --bg-surface-highlight: #2c2c2e;
    --text-primary: #f2f2f2;
    --text-secondary: #a1a1aa;
    --accent-color: #6366f1; /* Indigo nhẹ nhàng cho mắt */
    --nav-height: 60px;
    
    /* Category Colors */
    --color-life: #10b981;       /* Emerald */
    --color-humor: #f59e0b;      /* Amber */
    --color-heart: #ef4444;      /* Red */
    --color-fantasy: #8b5cf6;    /* Violet */
    --color-motivation: #3b82f6; /* Blue */
    --color-quick: #06b6d4;      /* Cyan */
}

body {
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    padding-top: 70px; /* Space for fixed header */
    padding-bottom: 80px; /* Space for fixed bottom nav */
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

main {
    flex: 1;
}

main.container {
    padding-left: 1rem;
    padding-right: 1rem;
    max-width: 100%;
}

@media (min-width: 576px) {
    main.container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* --- Custom Header --- */
.navbar-custom {
    background-color: rgba(12, 12, 15, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    height: 60px;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
    color: var(--text-primary) !important;
}

.btn-login {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
    border: none;
    border-radius: 20px;
    padding: 5px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: rgba(255, 255, 255, 0.1);
    user-select: none;
}

.btn-login:hover {
    background-color: var(--accent-color);
    color: white;
}

/* Language Dropdown */
.btn-language {
    background: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
}

.btn-language:hover {
    background-color: var(--bg-surface-highlight);
    border-color: var(--accent-color);
    color: var(--text-primary);
}

.btn-language:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.dropdown-menu-dark {
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.dropdown-menu-dark .dropdown-item {
    color: var(--text-primary);
}

.dropdown-menu-dark .dropdown-item:hover {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
}

.dropdown-menu-dark .dropdown-item.active {
    background-color: var(--bg-surface-highlight);
    color: var(--accent-color);
}

/* User Avatar */
.btn-avatar {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.btn-avatar:hover {
    transform: scale(1.1);
}

.avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid var(--accent-color);
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent-color);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Modal Dark Theme */
.modal-dark {
    background-color: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-dark .modal-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-dark .modal-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.form-control-dark {
    background-color: var(--bg-surface-highlight);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.form-control-dark:focus {
    background-color: var(--bg-surface-highlight);
    border-color: var(--accent-color);
    color: var(--text-primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.form-control-dark::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.form-label {
    color: var(--text-primary);
}

/* User Profile */
.user-profile-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 0;
}

.user-profile-header {
    padding-bottom: 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.recent-reads-section {
    margin-top: 2rem;
}

.recent-reads-list {
    display: grid;
    gap: 1rem;
}

.recent-read-item {
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1rem;
    transition: all 0.2s;
    cursor: pointer;
}

.recent-read-item:hover {
    background-color: var(--bg-surface-highlight);
    border-color: var(--accent-color);
    transform: translateY(-2px);
}

.recent-read-item a {
    text-decoration: none;
    color: var(--text-primary);
}

.recent-read-item h6 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.recent-read-item .read-date {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.btn-logout {
    background-color: #ef4444;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-logout:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .btn-avatar {
        width: 36px;
        height: 36px;
    }
    
    .profile-avatar {
        width: 100px;
        height: 100px;
    }
    
    .user-profile-content {
        padding: 1.5rem 0;
    }
}

/* --- Story Cards --- */
.story-card {
    background-color: transparent;
    border: none;
    transition: transform 0.2s;
    cursor: pointer;
}

.story-card:active {
    transform: scale(0.98);
}

.card-img-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    border-radius: 12px;
    overflow: hidden;
    background-color: var(--bg-surface);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 8px;
}

.card-img-top {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.card-title {
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 2px;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card-meta {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

/* Story Category and Tags Container */
.story-category-tags {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    overflow: hidden;
}

.story-category-tags > span {
    white-space: nowrap;
    flex-shrink: 0;
}

.story-category-tags > div {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.story-category-tags a {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@media (max-width: 576px) {
    .story-category-tags {
        flex-wrap: wrap;
    }
    
    .story-category-tags > div {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* --- Bottom Navigation --- */
.bottom-nav {
    background-color: rgba(28, 28, 30, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    height: 65px;
    z-index: 1040;
}

.nav-item-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    gap: 4px;
    transition: color 0.2s;
    background: none;
    border: none;
    width: 100%;
}

.nav-item-link i {
    font-size: 1.3rem;
}

.nav-item-link.active, .nav-item-link:hover {
    color: var(--text-primary);
}

.nav-item-link.active i {
    color: var(--accent-color);
}

/* --- Dropup Menu Customization --- */
.custom-dropup .dropdown-menu {
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    margin-bottom: 10px !important;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.5);
}

.custom-dropup .dropdown-item {
    color: var(--text-primary);
    padding: 10px 20px;
    font-size: 0.9rem;
}

.custom-dropup .dropdown-item:hover, .custom-dropup .dropdown-item:focus {
    background-color: var(--bg-surface-highlight);
    color: white;
}

.custom-dropup .dropdown-divider {
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Story content styling (for full story view) */
.story-content {
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.story-content p {
    margin-bottom: 1rem;
}

/* Badge styling */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Section titles */
.text-uppercase.text-secondary {
    color: var(--text-secondary) !important;
}

/* Alert customization for dark theme */
.alert {
    border-radius: 12px;
    padding: 1rem;
}

.alert-info {
    background-color: var(--bg-surface) !important;
    border-color: rgba(255,255,255,0.1) !important;
    color: var(--text-primary) !important;
}

.alert code {
    background-color: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--accent-color);
}

/* --- Catalog Page Styles --- */

/* Breadcrumb Customization */
.breadcrumb-custom {
    margin-bottom: 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    background-color: transparent;
    padding: 0;
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumb-item a:hover {
    color: var(--accent-color);
}

.breadcrumb-item.active {
    color: var(--text-primary);
}

.breadcrumb-item + .breadcrumb-item::before {
    color: var(--text-secondary);
    content: "/";
    padding: 0 0.5rem;
}

/* Search Bar */
.search-container {
    position: relative;
    margin-bottom: 24px;
    z-index: 1;
}

.search-input {
    background-color: var(--bg-surface);
    border: 1px solid rgba(255,255,255,0.05);
    color: var(--text-primary);
    border-radius: 12px;
    padding: 12px 12px 12px 45px;
    width: 100%;
    transition: all 0.3s;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.search-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.search-input:focus {
    background-color: var(--bg-surface-highlight);
    border-color: var(--accent-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.search-icon {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    z-index: 2;
    pointer-events: none;
}

/* Category Section */
.category-section {
    margin-bottom: 30px;
}

.category-section:last-child {
    margin-bottom: 0;
}

.category-section[style*="display: none"] {
    display: none !important;
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.category-icon {
    margin-right: 10px;
    font-size: 1.2rem;
    flex-shrink: 0;
}

/* Chips/Tags */
.chip-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

.chip {
    display: inline-block;
    background-color: var(--bg-surface);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 50px; /* Pill shape */
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid rgba(255,255,255,0.05);
    white-space: nowrap;
    cursor: pointer;
    min-height: 36px;
    box-sizing: border-box;
}

@media (max-width: 576px) {
    .chip {
        font-size: 0.8rem;
        padding: 6px 14px;
        min-height: 32px;
    }
    
    .chip-container {
        gap: 8px;
    }
}

.chip:hover, .chip:active {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
    transform: translateY(-1px);
    border-color: rgba(255,255,255,0.1);
}

.chip:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

/* Active/Selected State */
.chip.featured {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- Static Pages Content Styles --- */
.page-content {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.page-content h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.page-content h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--accent-color);
}

.page-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.page-content p {
    color: var(--text-primary);
    line-height: 1.8;
    margin-bottom: 1rem;
}

.page-content ul,
.page-content ol {
    color: var(--text-primary);
    line-height: 1.8;
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}

.page-content li {
    margin-bottom: 0.5rem;
}

.page-content .lead {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--text-primary);
    line-height: 1.8;
}

.content-section {
    margin-bottom: 2rem;
}

.content-section:last-child {
    margin-bottom: 0;
}

/* --- Story Detail Page Styles --- */
.story-detail-card {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.story-detail-image img {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.story-detail-content h1 {
    line-height: 1.3;
}

.story-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
}

.btn-read-story {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
    cursor: pointer;
}

.btn-read-story:hover {
    background-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

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

.btn-discover-more {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 16px 48px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    transition: all 0.3s;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn-discover-more:hover {
    background-color: #4f46e5;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
    color: white;
}

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

@media (max-width: 768px) {
    .btn-discover-more {
        padding: 14px 40px;
        font-size: 1rem;
    }
}

/* --- Story Reader Modal Styles --- */
.story-reader-content {
    background-color: var(--bg-body);
    color: var(--text-primary);
    border: none;
}

.story-reader-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
}

.story-reader-header .modal-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1rem;
    margin: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Compact Controls in Header */
.story-reader-controls-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-control-compact {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    font-size: 0.9rem;
    cursor: pointer;
}

.btn-control-compact:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.btn-control-compact:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.3);
}

.btn-control-compact i {
    font-size: 0.95rem;
}

/* Dropdown Menu Styling */
.story-reader-controls-compact .dropdown-menu {
    background-color: var(--bg-surface);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 0.25rem;
    min-width: 120px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.story-reader-controls-compact .dropdown-item {
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.story-reader-controls-compact .dropdown-item:hover {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
}

.story-reader-controls-compact .dropdown-item.active {
    background-color: var(--accent-color);
    color: white;
}

.story-reader-controls-compact .dropdown-item i {
    font-size: 0.9rem;
}

.story-reader-body {
    padding: 2rem;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.story-reader-body .story-content {
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.9;
    font-size: 1.1rem;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    transition: font-size 0.3s ease;
}

.story-reader-body .story-content p {
    margin-bottom: 1.5rem;
}

.story-reader-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-nav-story {
    background-color: var(--bg-surface-highlight);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-nav-story:hover {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

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

.story-progress-container {
    width: 100%;
}

.story-progress-bar {
    width: 100%;
    height: 4px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.story-progress-fill {
    height: 100%;
    background-color: var(--accent-color);
    border-radius: 2px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Story reader body - smooth scrolling */
.story-reader-body {
    position: relative;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

@media (max-width: 768px) {
    .story-reader-header {
        padding: 0.6rem 0.75rem;
    }
    
    .story-reader-header .modal-title {
        font-size: 0.9rem;
    }
    
    .btn-control-compact {
        min-width: 28px;
        height: 28px;
        padding: 3px 6px;
        font-size: 0.85rem;
    }
    
    .story-reader-controls-compact {
        gap: 0.4rem;
    }
    
    .story-reader-body {
        padding: 1.5rem 1rem;
    }
    
    .story-reader-body .story-content {
        font-size: 1rem;
        line-height: 1.8;
    }
    
    .story-reader-footer {
        padding: 0.6rem 0.75rem;
    }
    
    .story-progress-bar {
        height: 3px;
    }
}
