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

:root {
    /* Couleurs X (Twitter) - mode clair */
    --primary: #1d9bf0;
    --primary-light: #8ecdf8;
    --primary-dark: #0f6baf;
    --secondary: #ef4444;
    --bg-body: #ffffff;
    --bg-topbar: rgba(255, 255, 255, 0.98);
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --bg-message: #ffffff;
    --bg-message-hover: #f5f5f5;
    --text-main: #0f1419;
    --text-muted: #536471;
    --text-topbar: #0f1419;
    --text-sidebar: #0f1419;
    --border-light: #e7e7e8;
    --border-sidebar: #eff3f4;
    --btn-primary: #1d9bf0;
    --btn-hover: #1a8cd8;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-sidebar: 0 1px 3px rgba(0, 0, 0, 0.05);
    --radius-s: 8px;
    --radius-m: 12px;
    --radius-l: 50px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
}

[data-theme="dark"] {
    /* Couleurs X (Twitter) - mode sombre */
    --primary: #1d9bf0;
    --primary-light: #2b7bb9;
    --primary-dark: #0f6baf;
    --bg-body: #000000;
    --bg-topbar: rgba(0, 0, 0, 0.95);
    --bg-card: #000000;
    --bg-sidebar: #000000;
    --bg-message: #000000;
    --bg-message-hover: #16181c;
    --text-main: #e7e9ea;
    --text-muted: #71767b;
    --text-topbar: #e7e9ea;
    --text-sidebar: #e7e9ea;
    --border-light: #2f3336;
    --border-sidebar: #2f3336;
    --btn-primary: #1d9bf0;
    --btn-hover: #1a8cd8;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.3);
    --shadow-sidebar: 0 1px 3px rgba(0, 0, 0, 0.5);
}

body {
    font-family: 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    transition: 0.2s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 200;
    transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sidebar);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-section-title,
.sidebar.collapsed .sidebar-user-info {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-nav-item {
    justify-content: center;
    padding: 0.75rem;
}

.sidebar.collapsed .sidebar-nav-item i {
    margin-right: 0;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    overflow: hidden;
}

.sidebar-logo-icon {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-logo-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
    transition: 0.3s;
}

.sidebar-toggle {
    width: 28px;
    height: 28px;
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-muted);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0.5rem;
}

.sidebar-nav-section {
    margin-bottom: 1rem;
}

.sidebar-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    transition: 0.3s;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-l);
    color: var(--text-sidebar);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    transition: 0.2s;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-item i {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: 0.2s;
}

.sidebar-nav-item:hover {
    background: rgba(29, 155, 240, 0.1);
    color: var(--primary);
}

.sidebar-nav-item:hover i {
    color: var(--primary);
}

.sidebar-nav-item.active {
    background: rgba(29, 155, 240, 0.15);
    color: var(--primary);
}

.sidebar-nav-item.active i {
    color: var(--primary);
}

/* Voir plus toggle */
.voir-plus-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: var(--radius-l);
    color: var(--text-sidebar);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    font-family: inherit;
}

.voir-plus-toggle i:first-child {
    width: 20px;
    font-size: 1.1rem;
    color: var(--text-muted);
}

.voir-plus-toggle span {
    flex: 1;
    text-align: left;
}

.voir-plus-toggle i:last-child {
    font-size: 0.8rem;
    transition: transform 0.2s;
}

.voir-plus-toggle:hover {
    background: rgba(29, 155, 240, 0.1);
    color: var(--primary);
}

.voir-plus-toggle:hover i {
    color: var(--primary);
}

.voir-plus-links {
    margin-left: 0.5rem;
    margin-top: 0.25rem;
}

.voir-plus-links .sidebar-nav-item {
    padding-left: 2.5rem;
}

/* User section */
.sidebar-user {
    padding: 1rem;
    border-top: 1px solid var(--border-sidebar);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    overflow: hidden;
    cursor: pointer;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    flex-shrink: 0;
    font-size: 0.85rem;
}

.sidebar-user-info {
    overflow: hidden;
    transition: 0.3s;
}

.sidebar-user-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
}

.sidebar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* Main content */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    transition: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.main-wrapper.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed-width);
}

.top-bar {
    background: var(--bg-topbar);
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    gap: 1rem;
    box-shadow: var(--shadow-card);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-s);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: 0.2s;
}

.mobile-menu-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.theme-toggle,
.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    padding: 0.5rem;
    border-radius: var(--radius-s);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
    cursor: pointer;
}

.theme-toggle:hover,
.icon-btn:hover {
    background: rgba(29, 155, 240, 0.1);
    color: var(--primary);
}

.auth-btn {
    background: var(--btn-primary);
    color: #fff;
    padding: 0.6rem 1.4rem;
    border-radius: var(--radius-l);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: 0.3s;
    border: none;
    white-space: nowrap;
}

.auth-btn:hover {
    background: var(--btn-hover);
    transform: translateY(-1px);
}

.main-content {
    flex: 1;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.feed-container {
    width: 100%;
    max-width: 700px;
}

.message-card {
    background: var(--bg-message);
    padding: 1rem 1.25rem;
    display: flex;
    gap: 1rem;
    transition: 0.2s;
    border-bottom: 1px solid var(--border-light);
}

.message-card:hover {
    background: var(--bg-message-hover);
}

.message-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.message-body {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
}

.message-author {
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.95rem;
    cursor: pointer;
}

.message-author:hover {
    color: var(--primary);
}

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

.message-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
    word-wrap: break-word;
    cursor: pointer;
}

.message-media {
    margin-top: 0.75rem;
    border-radius: var(--radius-m);
    overflow: hidden;
    max-width: 100%;
}

.message-media img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain;
    display: block;
}

.message-media iframe,
.message-media video {
    max-width: 100%;
    border-radius: var(--radius-m);
}

.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    border-radius: var(--radius-m);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.message-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.6rem;
}

.reaction-btn {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.6rem;
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: 0.2s;
    color: var(--text-main);
}

.reaction-btn:hover {
    background: rgba(29, 155, 240, 0.1);
    transform: scale(1.05);
}

.reaction-btn.active {
    background: rgba(29, 155, 240, 0.15);
}

.reaction-btn .emoji {
    font-size: 1rem;
}

.reaction-btn .count {
    font-weight: 600;
    font-size: 0.8rem;
}

.add-reaction-btn {
    width: 32px;
    height: 32px;
    min-width: 32px;
    background: transparent;
    border: 1px dashed var(--border-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1rem;
    transition: 0.2s;
}

.add-reaction-btn:hover {
    background: rgba(29, 155, 240, 0.1);
    color: var(--primary);
}

.emoji-picker {
    position: absolute;
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-m);
    padding: 0.75rem;
    box-shadow: var(--shadow-hover);
    z-index: 1000;
    display: none;
}

.emoji-picker.active {
    display: block;
}

.emoji-picker-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 0.25rem;
}

.emoji-option {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    cursor: pointer;
    border-radius: var(--radius-s);
    transition: 0.2s;
}

.emoji-option:hover {
    background: rgba(29, 155, 240, 0.1);
    transform: scale(1.15);
}

.fab {
    position: fixed;
    bottom: max(24px, env(safe-area-inset-bottom));
    right: max(24px, env(safe-area-inset-right));
    width: 56px;
    height: 56px;
    background: var(--btn-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    transition: 0.3s;
    z-index: 50;
    cursor: pointer;
    border: none;
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
}

.loader-card {
    background: var(--bg-card);
    border-radius: var(--radius-m);
    padding: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.8rem;
    color: var(--text-muted);
    box-shadow: var(--shadow-card);
    border: 1px solid var(--border-light);
}

.loader-card i {
    color: var(--primary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
    opacity: 0;
    transition: 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    backdrop-filter: blur(8px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border-radius: var(--radius-m);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-light);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.modal-close {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    border-radius: var(--radius-s);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.5rem;
    transition: 0.2s;
}

.modal-close:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.modal-body {
    padding: 1.5rem;
}

.modal-form-group {
    margin-bottom: 1.25rem;
}

.modal-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.modal-textarea,
.modal-input {
    width: 100%;
    padding: 0.75rem 0.9rem;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-m);
    font-size: 0.95rem;
    background: var(--bg-body);
    color: var(--text-main);
    transition: 0.3s;
    font-family: inherit;
}

.modal-textarea {
    min-height: 120px;
    resize: vertical;
}

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

.modal-help {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

.modal-media-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-cancel {
    padding: 0.7rem 1.5rem;
    background: transparent;
    border: 2px solid var(--border-light);
    border-radius: var(--radius-m);
    color: var(--text-main);
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
}

.btn-cancel:hover {
    background: var(--bg-body);
}

.btn-send {
    padding: 0.7rem 1.5rem;
    background: var(--btn-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-m);
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.btn-send:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Notification banner */
.notification-banner {
    position: fixed;
    bottom: 90px;
    right: max(24px, env(safe-area-inset-right));
    background: var(--bg-card);
    color: var(--text-main);
    padding: 12px 16px;
    border-radius: var(--radius-m);
    box-shadow: var(--shadow-hover);
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    z-index: 100;
    max-width: 350px;
    border: 1px solid var(--border-light);
    transition: transform 0.2s, box-shadow 0.2s;
    backdrop-filter: blur(4px);
}

.notification-banner:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.notification-badge {
    background: linear-gradient(135deg, #ff4d4d, #ff1a1a);
    color: white;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 4px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    box-shadow: 0 2px 5px rgba(255, 0, 0, 0.3);
}

.notification-text {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-main);
    flex: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        left: -100%;
        box-shadow: none;
    }
    .sidebar.mobile-open {
        left: 0;
        box-shadow: var(--shadow-sidebar);
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    .mobile-menu-btn {
        display: flex;
    }
    .sidebar-toggle {
        display: none;
    }
    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .top-bar {
        padding: 0.5rem 1rem;
    }
    .page-title {
        font-size: 1.1rem;
    }
    .top-bar-actions .icon-btn:not(:last-child) {
        display: none;
    }
    .auth-btn {
        padding: 0.4rem 1rem;
        font-size: 0.8rem;
    }
    .message-card {
        padding: 0.75rem 1rem;
    }
    .message-avatar {
        width: 36px;
        height: 36px;
        min-width: 36px;
        font-size: 0.9rem;
    }
    .message-content {
        font-size: 0.9rem;
    }
    .fab {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
        bottom: 16px;
        right: 16px;
    }
    .modal-content {
        max-width: 95%;
    }
    .modal-media-grid {
        grid-template-columns: 1fr;
    }
}