/* ============================================
   TECH BOT — Design System & Styles
   ============================================ */

/* --- Dark Theme (default) --- */
:root,
[data-theme="dark"] {
    --bg-dark: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-input: rgba(30, 41, 59, 0.9);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #60a5fa;
    --accent-glow: rgba(59, 130, 246, 0.15);
    --purple-glow: rgba(139, 92, 246, 0.1);
    --glass-blur: blur(16px);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
    --glow-opacity: 1;
    --card-hover-bg: rgba(255, 255, 255, 0.03);
    --filter-active-bg: rgba(59, 130, 246, 0.2);
    --filter-active-border: rgba(59, 130, 246, 0.5);
    --badge-bg: rgba(59, 130, 246, 0.15);
    --badge-text: #60a5fa;
    --empty-icon-color: #334155;
    --scrollbar-track: rgba(255, 255, 255, 0.02);
    --scrollbar-thumb: rgba(255, 255, 255, 0.1);
}

/* --- Light Theme --- */
[data-theme="light"] {
    --bg-dark: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.85);
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-input: rgba(255, 255, 255, 0.95);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent-color: #2563eb;
    --accent-hover: #3b82f6;
    --accent-glow: rgba(37, 99, 235, 0.08);
    --purple-glow: rgba(139, 92, 246, 0.05);
    --glass-blur: blur(16px);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
    --glow-opacity: 0.4;
    --card-hover-bg: rgba(0, 0, 0, 0.02);
    --filter-active-bg: rgba(37, 99, 235, 0.1);
    --filter-active-border: rgba(37, 99, 235, 0.4);
    --badge-bg: rgba(37, 99, 235, 0.1);
    --badge-text: #2563eb;
    --empty-icon-color: #cbd5e1;
    --scrollbar-track: rgba(0, 0, 0, 0.02);
    --scrollbar-thumb: rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Smooth scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }

/* --- Ambient Glow Backgrounds --- */
.glow-bg {
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 70%);
    border-radius: 50%;
    z-index: -1;
    pointer-events: none;
    opacity: var(--glow-opacity);
    transition: opacity 0.4s ease;
}

.glow-bg-2 {
    top: 50%;
    left: 60%;
    background: radial-gradient(circle, var(--purple-glow) 0%, transparent 70%);
}

/* --- Layout --- */
.app-container {
    display: flex;
    max-width: 1600px;
    margin: 0 auto;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: 270px;
    background: var(--bg-panel);
    backdrop-filter: var(--glass-blur);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: background 0.4s ease, border-color 0.4s ease;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 3rem;
}

.logo-icon {
    color: var(--accent-color);
    width: 28px;
    height: 28px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.nav-menu { flex: 1; overflow-y: auto; }

.nav-menu h3 {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--text-muted);
    margin-bottom: 1rem;
    font-weight: 600;
}

#category-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#category-list li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 500;
}

#category-list li a:hover,
#category-list li a.active {
    background: var(--card-hover-bg);
    color: var(--text-primary);
}

.cat-count {
    margin-left: auto;
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--badge-bg);
    color: var(--badge-text);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}

.footer-info {
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.powered-by {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.powered-by i { width: 14px; height: 14px; color: #a855f7; }
.powered-by span { font-weight: 600; color: var(--accent-hover); }

/* --- Main Content --- */
.main-content {
    flex: 1;
    padding: 2rem 3rem;
    overflow-y: auto;
    min-width: 0;
}

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

.top-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
    letter-spacing: -0.02em;
}

.last-updated {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* --- Search Bar --- */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    pointer-events: none;
    z-index: 1;
}

.search-input {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    padding: 8px 36px 8px 36px;
    border-radius: 10px;
    width: 220px;
    outline: none;
    backdrop-filter: var(--glass-blur);
    transition: all 0.25s ease;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    width: 280px;
}

.search-clear {
    position: absolute;
    right: 8px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}
.search-clear i { width: 14px; height: 14px; }
.search-clear:hover { color: var(--text-primary); }

/* --- Icon Buttons --- */
.icon-btn {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: var(--glass-blur);
    flex-shrink: 0;
}

.icon-btn i { width: 18px; height: 18px; }

.icon-btn:hover {
    background: var(--card-hover-bg);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

/* --- Toolbar (Filters & Badge) --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}

.filter-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.filter-btn.active {
    background: var(--filter-active-bg);
    border-color: var(--filter-active-border);
    color: var(--accent-color);
}

/* --- New Badge --- */
.new-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    color: #34d399;
    background: rgba(52, 211, 153, 0.1);
    border: 1px solid rgba(52, 211, 153, 0.25);
    padding: 6px 14px;
    border-radius: 20px;
    animation: badgePulse 2s ease-in-out infinite;
    cursor: pointer;
}

.new-badge i { width: 14px; height: 14px; }

@keyframes badgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* --- Category Sections --- */
.news-category {
    margin-bottom: 3rem;
    scroll-margin-top: 2rem;
}

.news-category h3 {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.01em;
}

/* --- Grid & Cards (Glassmorphism) --- */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 1.25rem;
}

.news-card {
    background: var(--bg-card);
    backdrop-filter: var(--glass-blur);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    min-height: 140px;
}

/* Gradient top-bar on hover */
.news-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 2px;
    background: linear-gradient(90deg, var(--accent-color), #a855f7);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    background: var(--card-hover-bg);
    border-color: var(--border-hover);
}

.news-card:hover::before { opacity: 1; }

.card-badge {
    margin-bottom: 0.75rem;
}

.status-new-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.4);
}

.status-new-badge i {
    width: 10px;
    height: 10px;
}

.card-title {
    font-size: 0.95rem;
    line-height: 1.55;
    font-weight: 500;
    margin-bottom: 1.25rem;
    flex: 1;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    padding-top: 0.85rem;
    gap: 8px;
}

.card-source {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--badge-bg);
    padding: 4px 10px;
    border-radius: 6px;
    font-weight: 500;
    white-space: nowrap;
}

.card-source i { width: 12px; height: 12px; flex-shrink: 0; }

.card-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.card-stars {
    color: #fbbf24;
    letter-spacing: 2px;
    flex-shrink: 0;
}

/* --- Stagger Fade-In Animation --- */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.news-card.animate-in {
    animation: fadeSlideUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* --- Empty State --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 2rem;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    color: var(--empty-icon-color);
    margin-bottom: 1.5rem;
}

.empty-state h3 {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.empty-state p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    max-width: 400px;
    line-height: 1.6;
}

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

.no-results i {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

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

/* --- Error State --- */
.error-state {
    text-align: center;
    padding: 4rem 2rem;
}

.error-state i {
    width: 56px;
    height: 56px;
    color: #ef4444;
    margin-bottom: 1rem;
}

.error-state h3 {
    font-size: 1.1rem;
    color: #ef4444;
    margin-bottom: 0.5rem;
}

.error-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* --- Skeletons --- */
.skeleton-nav {
    height: 38px;
    background: var(--border-color);
    border-radius: 10px;
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-title {
    height: 28px; width: 150px;
    background: var(--border-color);
    border-radius: 6px;
    animation: pulse 1.5s infinite ease-in-out;
}
.skeleton-card {
    height: 160px;
    background: var(--border-color);
    animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
    0% { opacity: 0.4; }
    50% { opacity: 0.8; }
    100% { opacity: 0.4; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
.spin { animation: spin 1s linear infinite; }

/* --- Mobile Menu Button --- */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 50px;
    height: 50px;
    border-radius: 14px;
    background: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
    z-index: 200;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
}

.mobile-menu-btn i { width: 22px; height: 22px; }
.mobile-menu-btn:active { transform: scale(0.92); }

/* --- Responsiveness --- */
@media (max-width: 900px) {
    .app-container { flex-direction: column; }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 0;
        overflow: hidden;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 0 1.5rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        transition: max-height 0.35s ease, padding 0.35s ease;
    }

    .sidebar.open {
        max-height: 80vh;
        padding: 1.5rem;
        overflow-y: auto;
    }

    .logo { margin-bottom: 1.5rem; }

    #category-list {
        flex-direction: row;
        flex-wrap: wrap;
    }

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

    .main-content { padding: 1.5rem; }

    .mobile-menu-btn { display: flex; }

    .search-input { width: 160px; }
    .search-input:focus { width: 200px; }

    .top-header { flex-direction: column; align-items: flex-start; }
    .header-actions { width: 100%; }

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

@media (max-width: 480px) {
    .main-content { padding: 1rem; }
    .search-input { width: 130px; }
    .search-input:focus { width: 160px; }
    .news-card { padding: 1.2rem; }
    .filter-group { flex-wrap: wrap; }
}
