/**
 * Professional Blogging Platform Styling
 * Modern, typography-first design similar to Medium/Dev.to
 */

:root {
    --light-bg: #ffffff;
    --light-bg-alt: #f7f7f7;
    --light-border: #e8e8e8;
    --light-text: #0f0f0f;
    --light-text-secondary: #666;
    
    --hero-height: 500px;
    --card-shadow: 0 2px 12px rgba(0,0,0,0.08);
    --card-hover-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

/* Override Bootstrap defaults for professional look */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
}

.container-lg {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ==================== HEADER & NAVIGATION ==================== */
.navbar-sticky {
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    backdrop-filter: blur(10px);
    background: rgba(var(--bg-rgb-primary), 0.95) !important;
}

.navbar {
    padding: 1rem 0;
}

.navbar-brand {
    font-size: 1.3rem;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    border-radius: 8px;
    color: white;
    font-weight: 800;
    font-size: 1.2rem;
}

.navbar-nav .nav-link {
    font-size: 0.95rem;
    margin: 0 0.75rem;
    transition: color 200ms ease;
    position: relative;
}

.navbar-nav .nav-link:hover {
    color: var(--primary) !important;
}

.btn-search {
    padding: 0.5rem 1rem !important;
}

#theme-toggle {
    font-size: 1.3rem;
    cursor: pointer;
}

/* ==================== SEARCH BAR IN NAVBAR ==================== */
.search-nav-item {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-search {
    padding: 0.5rem !important;
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

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

.search-bar-inline {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    min-width: 300px;
    display: none;
    gap: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    animation: slideDown 0.2s ease;
}

.search-bar-inline.active {
    display: flex;
    align-items: center;
}

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

.search-bar-inline .search-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 200ms ease;
}

.search-bar-inline .search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-search-submit {
    padding: 10px 16px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.btn-search-submit:hover {
    background-color: var(--primary-dark);
}

.btn-search-close {
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-search-close:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary);
    color: var(--primary);
}

/* Old search overlay styles - remove */
.search-overlay {
    display: none !important;
}

/* ==================== SEARCH RESULTS PAGE ==================== */
.search-results-form {
    display: flex;
    gap: 1rem;
}

.search-results-input {
    padding: 12px 16px !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 8px !important;
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
    font-size: 1rem;
    transition: all 200ms ease;
}

.search-results-input:focus {
    outline: none !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

/* ==================== HERO / FEATURED SECTION ==================== */
.hero-section {
    padding: 4rem 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.featured-article {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: center;
}

.featured-image {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    aspect-ratio: 16/10;
    box-shadow: 0 12px 32px rgba(0,0,0,0.15);
}

.featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 500ms ease;
}

.featured-image:hover img {
    transform: scale(1.05);
}

.featured-badge {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.featured-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.category-badge {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.read-time {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.featured-title {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
}

.featured-excerpt {
    font-size: 1.1rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

.featured-author {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.featured-author img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.featured-author strong {
    display: block;
    color: var(--text-primary);
}

/* ==================== SECTION HEADERS ==================== */
.section-header {
    text-align: center;
    margin-bottom: 3rem;
}

.section-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

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

/* ==================== TRENDING ARTICLES SECTION ==================== */
#trending {
    background: var(--bg-light-alt, #f7f7f7);
}

.trending-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.trend-card {
    background: var(--bg-primary);
    border-radius: 12px;
    overflow: hidden;
    transition: all 300ms ease;
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    cursor: pointer;
}

.trend-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--card-hover-shadow);
}

.trend-card-image {
    position: relative;
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--bg-tertiary);
}

.trend-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms ease;
}

.trend-card:hover .trend-card-image img {
    transform: scale(1.08);
}

.trend-rank {
    position: absolute;
    top: 1rem;
    left: 1rem;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
}

.trend-card-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.trend-card-body h3 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

.trend-card-body h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 200ms ease;
}

.trend-card-body h3 a:hover {
    color: var(--primary);
}

.trend-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== RECENT ARTICLES FEED ==================== */
.articles-feed {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    margin-bottom: 2rem;
}

.article-item {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 300ms ease;
    cursor: pointer;
}

.article-item:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
    box-shadow: var(--card-shadow);
}

.article-item-image {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    aspect-ratio: 4/3;
    background: var(--bg-tertiary);
}

.article-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 400ms ease;
}

.article-item:hover .article-item-image img {
    transform: scale(1.08);
}

.article-item-content {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    justify-content: center;
}

.article-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.5rem;
}

.article-item-content h3 {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

.article-item-content h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 200ms ease;
}

.article-item-content h3 a:hover {
    color: var(--primary);
}

.article-item-content p {
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.article-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.author-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* ==================== CATEGORIES SECTION ==================== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
}

.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    background: var(--bg-primary);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 300ms ease;
    text-decoration: none;
    color: var(--text-primary);
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
    box-shadow: 0 12px 24px rgba(102, 126, 234, 0.15);
    background: var(--bg-secondary);
}

.category-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.category-card h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: color 200ms ease;
}

.category-card:hover h3 {
    color: var(--primary);
}

.category-card p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0 0 1rem 0;
}

.category-count {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* ==================== NEWSLETTER SECTION ==================== */
.newsletter-section {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    padding: 4rem 0;
    margin: 3rem 0;
}

.newsletter-content {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
}

.newsletter-content h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.newsletter-content p {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.newsletter-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 1rem;
    margin-bottom: 1rem;
}

.newsletter-form input {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1rem;
}

.newsletter-form input::placeholder {
    color: var(--text-secondary);
}

.newsletter-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.newsletter-privacy {
    margin: 0;
}

/* ==================== FOOTER ==================== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.footer-section p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.6;
}

.social-links {
    display: flex;
    gap: 1rem;
}

.social-links a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1.2rem;
    transition: all 200ms ease;
}

.social-links a:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 200ms ease;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-divider {
    height: 1px;
    background: var(--border-color);
    margin: 2rem 0;
}

.footer-bottom {
    text-align: center;
}

.footer-bottom p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* ==================== BUTTONS ==================== */
.btn {
    font-weight: 500;
    transition: all 200ms ease;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    border: none;
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.3);
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8a 100%);
}

.btn-outline-primary {
    color: var(--primary);
    border: 2px solid var(--primary);
    background: transparent;
}

.btn-outline-primary:hover {
    background: linear-gradient(135deg, var(--primary) 0%, #764ba2 100%);
    color: white;
    border-color: transparent;
}

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

.btn-secondary:hover {
    background: var(--border-light);
}

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 768px) {
    .featured-article {
        grid-template-columns: 1fr;
        gap: 2rem;
    }

    .featured-title {
        font-size: 1.8rem;
    }

    .section-header h2 {
        font-size: 1.5rem;
    }

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

    .article-item {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .article-item-image {
        aspect-ratio: 16/10;
    }

    .article-item-content h3 {
        font-size: 1.1rem;
    }

    .newsletter-form {
        grid-template-columns: 1fr;
    }

    .search-container {
        flex-direction: column;
        width: 95%;
    }

    .search-container button {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container-lg {
        padding: 0 1rem;
    }

    .featured-image {
        aspect-ratio: 16/9;
    }

    .featured-content {
        gap: 1rem;
    }

    .featured-title {
        font-size: 1.4rem;
    }

    .featured-excerpt {
        font-size: 1rem;
    }

    .navbar-brand {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    .navbar-nav .nav-link {
        font-size: 0.85rem;
        margin: 0 0.5rem;
    }

    .category-card {
        padding: 1.5rem;
    }

    .trending-grid,
    .categories-grid {
        gap: 1rem;
    }

    .trend-stats {
        gap: 1rem;
    }
}

/* ==================== LIGHT MODE OVERRIDES ==================== */
@media (prefers-color-scheme: light) {
    .trend-card,
    .article-item,
    .category-card,
    .featured-content {
        background: white;
    }

    .hero-section {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    }

    #trending {
        background: #f7f7f7;
    }

    .newsletter-section {
        background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    }
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.trend-card,
.article-item,
.category-card {
    animation: fadeIn 600ms ease forwards;
}

.trend-card:nth-child(1) { animation-delay: 100ms; }
.trend-card:nth-child(2) { animation-delay: 150ms; }
.trend-card:nth-child(3) { animation-delay: 200ms; }
.trend-card:nth-child(4) { animation-delay: 250ms; }
.trend-card:nth-child(5) { animation-delay: 300ms; }
.trend-card:nth-child(6) { animation-delay: 350ms; }
