@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #151d30;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-card-glass: rgba(30, 41, 59, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    --accent: #8b5cf6;
    --accent-glow: rgba(139, 92, 246, 0.15);
    --accent-hover: #a78bfa;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --success: #10b981;
    --error: #ef4444;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --font-sans: 'Outfit', sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-primary);
    background-image: radial-gradient(circle at 50% 0%, #1e1b4b 0%, var(--bg-primary) 70%);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

/* Mobile container - Mobile first, max width on desktop */
.app-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: rgba(11, 15, 25, 0.8);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)); /* space for bottom nav */
}

/* Header */
.app-header {
    background: rgba(21, 29, 48, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0px));
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #a78bfa, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-dot {
    width: 8px;
    height: 8px;
    background-color: var(--accent);
    border-radius: 50%;
    box-shadow: 0 0 10px var(--accent);
}

/* Main Content */
.app-content {
    flex: 1;
    padding: 20px;
}

/* Bottom Navigation Bar - iOS Floating Pill Menu */
.bottom-nav {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 440px;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 28px;
    display: flex;
    justify-content: space-around;
    padding: 12px 10px;
    z-index: 100;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 
                inset 0 1px 1px rgba(255, 255, 255, 0.15);
    transition: var(--transition);
}

.bottom-nav-item {
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 500;
    gap: 4px;
    transition: var(--transition);
}

.bottom-nav-item:hover, .bottom-nav-item.active {
    color: var(--accent);
}

.bottom-nav-item:active {
    transform: scale(0.92);
}

.bottom-nav-item svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    transition: var(--transition);
}

.bottom-nav-item.active svg {
    filter: drop-shadow(0 0 5px var(--accent));
}

/* Cards & Layout Items */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    border-color: rgba(139, 92, 246, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Typography & Text utility */
h1 { font-size: 1.5rem; font-weight: 700; margin-bottom: 8px; }
h2 { font-size: 1.2rem; font-weight: 600; margin-bottom: 12px; }
p { font-size: 0.95rem; color: var(--text-secondary); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #7c3aed);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--error);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
}

/* Forms */
.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-control {
    width: 100%;
    padding: 12px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Badges & Feeds filter */
.feed-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.15);
    color: var(--accent-hover);
    border: 1px solid rgba(139, 92, 246, 0.3);
}

.horizontal-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 10px;
    margin-bottom: 20px;
    scrollbar-width: none; /* Firefox */
}

.horizontal-scroll::-webkit-scrollbar {
    display: none; /* Safari & Chrome */
}

.pill-btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: var(--transition);
}

.pill-btn.active, .pill-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Article List styling */
.article-card {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.article-card.read {
    opacity: 0.55;
    border-color: rgba(255, 255, 255, 0.03);
}

.article-card.read:hover {
    opacity: 0.85;
    border-color: rgba(139, 92, 246, 0.2);
}

/* Masquage de l'image et de la description pour les articles lus sur mobile */
@media (max-width: 767px) {
    .article-card.read .article-image,
    .article-card.read .article-excerpt {
        display: none;
    }
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
}

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

.article-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-decoration: none;
    line-height: 1.4;
    transition: var(--transition);
}

.article-title:hover {
    color: var(--accent-hover);
}

.article-excerpt {
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-image {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Article details */
.detail-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.detail-content {
    font-size: 1rem;
    line-height: 1.6;
    color: #e2e8f0;
    margin-bottom: 24px;
}

.detail-content p {
    margin-bottom: 12px;
    color: #e2e8f0;
}

.detail-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* Pagination */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 10px 0;
}

/* Auth Pages Centering */
.auth-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: calc(100vh - 120px);
}

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

.auth-title {
    font-size: 1.8rem;
    font-weight: 700;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 6px;
}

.auth-footer-text {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 16px;
}

.auth-footer-text a {
    color: var(--accent-hover);
    text-decoration: none;
    font-weight: 500;
}

/* User admin list item */
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
}

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

.user-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.user-actions {
    display: flex;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
    width: auto;
}

.form-helper {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Sidebar Feeds List (Hidden on Mobile) */
.sidebar-feeds-list {
    display: none;
}


@media (min-width: 992px) {
    .app-container {
        max-width: 100%;
        width: 100%;
        display: grid;
        grid-template-columns: auto 1fr;
        grid-template-rows: auto 1fr;
        padding-bottom: 0;
        border-left: none;
        border-right: none;
    }

    .app-header {
        grid-column: 1 / -1;
        grid-row: 1;
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 20px 30px;
    }

    .bottom-nav {
        grid-column: 1;
        grid-row: 2;
        position: sticky;
        top: 93px; /* height of header (73px) + 20px margin */
        height: calc(100vh - 113px); /* 100vh - 73px header - 20px top - 20px bottom */
        width: 240px;
        margin: 20px;
        flex-direction: column;
        justify-content: flex-start;
        padding: 24px 16px;
        gap: 16px;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-lg);
        background: rgba(21, 29, 48, 0.5);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transform: none;
        left: auto;
        bottom: auto;
    }

    .bottom-nav-item {
        flex-direction: row;
        width: 100%;
        padding: 12px 20px;
        border-radius: var(--radius-md);
        font-size: 0.95rem;
        gap: 14px;
        align-items: center;
        justify-content: flex-start;
    }

    .bottom-nav-item svg {
        width: 20px;
        height: 20px;
    }

    .bottom-nav-item.active {
        background: var(--accent-glow);
        border: 1px solid rgba(139, 92, 246, 0.2);
    }

    .app-content {
        grid-column: 2;
        grid-row: 2;
        padding: 30px 40px;
    }

    .articles-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
        gap: 24px;
    }

    .card {
        margin-bottom: 0; /* grid handles gaps */
    }

    /* Auth views layout centering on desktop */
    .auth-wrapper {
        min-height: calc(100vh - 180px);
        max-width: 420px;
        margin: 0 auto;
    }

    .mobile-only {
        display: none !important;
    }

    .settings-nav-item {
        margin-top: auto !important;
    }

    .sidebar-feeds-list {
        display: flex;
        flex-direction: column;
        padding-left: 34px;
        gap: 10px;
        margin-top: 8px;
        margin-bottom: 16px;
    }

    .sidebar-feed-item {
        display: flex;
        align-items: center;
        gap: 10px;
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 0.85rem;
        font-weight: 500;
        transition: var(--transition);
        padding: 4px 0;
    }

    .sidebar-feed-item:hover, .sidebar-feed-item.active {
        color: var(--accent-hover);
    }

    .sidebar-feed-dot {
        width: 6px;
        height: 6px;
        background-color: var(--text-muted);
        border-radius: 50%;
        transition: var(--transition);
    }

    .sidebar-feed-item.active .sidebar-feed-dot {
        background-color: var(--accent);
        box-shadow: 0 0 8px var(--accent);
    }

    .nav-group {
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .detail-article-card {
        max-width: 800px;
        margin: 0 auto !important;
    }
}

/* Light Theme Variables & Overrides */
[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-glass: rgba(255, 255, 255, 0.75);
    --border-color: rgba(15, 23, 42, 0.08);
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.1);
    --accent-hover: #6d28d9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
}

[data-theme="light"] body {
    background-image: radial-gradient(circle at 50% 0%, #f5f3ff 0%, var(--bg-primary) 70%);
}

[data-theme="light"] .app-container {
    background: rgba(255, 255, 255, 0.45);
}

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

[data-theme="light"] .bottom-nav {
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.06), 
                inset 0 1px 1px rgba(255, 255, 255, 0.8);
}

[data-theme="light"] .card:hover {
    box-shadow: 0 8px 20px rgba(124, 58, 237, 0.06);
}

[data-theme="light"] .btn-secondary {
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-primary);
}

[data-theme="light"] .btn-secondary:hover {
    background: rgba(15, 23, 42, 0.08);
}

[data-theme="light"] .form-control {
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="light"] .pill-btn {
    background: rgba(15, 23, 42, 0.04);
}

[data-theme="light"] .pill-btn.active, [data-theme="light"] .pill-btn:hover {
    background: var(--accent);
    color: white;
}

[data-theme="light"] .feed-badge {
    background: rgba(124, 58, 237, 0.08);
    color: var(--accent);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

@media (min-width: 992px) {
    [data-theme="light"] .bottom-nav {
        background: rgba(255, 255, 255, 0.7);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04) !important;
    }
}

/* Utilities & Animations */
.hidden {
    display: none !important;
}

.theme-toggle-btn {
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    color: var(--accent) !important;
    transform: rotate(15deg);
}

.theme-toggle-btn:active {
    transform: scale(0.9);
}
