:root {
    --page-bg: #f0f2f5;
    --kanban-bg: #e9ecef;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

html, body {
    min-height: 100%;
}

body {
    background:
        radial-gradient(circle at top left, rgba(13, 110, 253, 0.08), transparent 40%),
        radial-gradient(circle at bottom right, rgba(25, 135, 84, 0.08), transparent 35%),
        var(--page-bg);
    display: flex;
    flex-direction: column;
}

main.container {
    flex: 1;
}

.auth-card,
.list-card {
    background: rgba(255, 255, 255, 0.95);
}

.column-badge {
    color: #fff;
}

.kanban-board {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 300px;
    background: var(--kanban-bg);
    border-radius: 0.75rem;
    min-height: 420px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    padding: 0.9rem 1rem 0.6rem;
    border-top: 4px solid #6c757d;
    border-radius: 0.75rem 0.75rem 0 0;
    background: #fff;
}

.kanban-column-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-dot {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    display: inline-block;
}

.kanban-column-count {
    font-size: 0.8rem;
    margin-top: 0.15rem;
}

.kanban-cards {
    padding: 0.75rem;
    flex: 1;
    min-height: 200px;
}

.kanban-card {
    background: #fff;
    border-radius: 0.6rem;
    padding: 0.85rem;
    margin-bottom: 0.65rem;
    box-shadow: var(--card-shadow);
    cursor: grab;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.sortable-ghost {
    opacity: 0.4;
}

.kanban-card-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.kanban-card-desc {
    font-size: 0.85rem;
    color: #6c757d;
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.color-presets {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.color-preset {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
    padding: 0;
    cursor: pointer;
}

.empty-state {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 1rem;
}

.column-drag-handle {
    cursor: grab;
    color: #adb5bd;
    margin-right: 0.15rem;
}

.column-drag-handle:active {
    cursor: grabbing;
}

.kanban-card.no-drag {
    cursor: default;
}

.messaging-layout {
    min-height: 520px;
    background: #fff;
}

.messaging-sidebar {
    max-height: 70vh;
    overflow-y: auto;
}

.messaging-main {
    min-height: 520px;
    max-height: 70vh;
}

.messaging-messages {
    overflow-y: auto;
    background:
        linear-gradient(180deg, rgba(248, 249, 250, 0.9), rgba(255, 255, 255, 0.9));
}

.chat-bubble {
    max-width: 75%;
    margin-bottom: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.85rem;
    background: #f1f3f5;
}

.chat-bubble.mine {
    margin-left: auto;
    background: #dbeafe;
}

.chat-bubble.theirs {
    margin-right: auto;
}

.chat-meta {
    font-size: 0.72rem;
    color: #6c757d;
    margin-bottom: 0.2rem;
}

.chat-body {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble.deleted {
    opacity: 0.75;
}

.chat-reply-preview {
    background: rgba(0, 0, 0, 0.06);
    border-left: 3px solid #0d6efd;
    padding: 0.35rem 0.5rem;
    margin-bottom: 0.4rem;
    border-radius: 0.35rem;
    font-size: 0.8rem;
}

.chat-actions {
    display: flex;
    gap: 0.45rem;
    margin-top: 0.35rem;
    opacity: 0.35;
}

.chat-bubble:hover .chat-actions {
    opacity: 1;
}

.chat-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.35rem;
}

.reaction-chip {
    border: 1px solid #dee2e6;
    background: #fff;
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    font-size: 0.8rem;
    line-height: 1.4;
}

.reaction-chip.mine-reaction {
    border-color: #0d6efd;
    background: #e7f1ff;
}

.reply-bar {
    position: relative;
    background: #f8f9fa;
}

.reply-bar .btn-close {
    position: absolute;
    top: 0.55rem;
    right: 0.75rem;
    transform: scale(0.75);
}

.emoji-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}

.emoji-btn {
    border: none;
    background: #f1f3f5;
    border-radius: 0.5rem;
    font-size: 1.4rem;
    width: 2.4rem;
    height: 2.4rem;
    line-height: 1;
}

.emoji-btn:hover {
    background: #e9ecef;
}

.status-dot {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    display: inline-block;
    margin-right: 0.35rem;
    vertical-align: middle;
    background: #adb5bd;
}

.status-dot.status-online { background: #198754; }
.status-dot.status-busy { background: #fd7e14; }
.status-dot.status-offline { background: #adb5bd; }

.chat-image {
    max-width: 220px;
    max-height: 180px;
    border-radius: 0.5rem;
    display: block;
}

.chat-read-status {
    font-size: 0.72rem;
    color: #6c757d;
    text-align: right;
    margin-top: 0.2rem;
}

.chat-bubble.mine .chat-read-status {
    color: #0d6efd;
}

.search-results {
    max-height: 220px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 0.5rem;
}

.search-result-item {
    display: block;
    padding: 0.45rem 0.35rem;
    text-decoration: none;
    color: inherit;
    border-radius: 0.35rem;
}

.search-result-item:hover {
    background: #f1f3f5;
}

.highlight-msg {
    outline: 2px solid #0d6efd;
    outline-offset: 2px;
}

#messageInput {
    resize: vertical;
    min-height: 2.5rem;
}

/* Rail style Teams */
.has-rail {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app-rail {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 4.5rem;
    background: #252833;
    color: #c8cbd3;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 1040;
    padding: 0.75rem 0;
}

.rail-brand {
    color: #fff;
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
    text-decoration: none;
}

.rail-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    width: 100%;
}

.rail-item {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.55rem 0.25rem;
    color: #c8cbd3;
    text-decoration: none;
    font-size: 0.65rem;
    border: none;
    background: transparent;
}

.rail-item i {
    font-size: 1.25rem;
}

.rail-item:hover,
.rail-item.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.rail-item.active {
    box-shadow: inset 3px 0 0 #6264a7;
}

.rail-label {
    line-height: 1.1;
    text-align: center;
}

.rail-badge {
    position: absolute;
    top: 0.2rem;
    right: 0.55rem;
    min-width: 1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: #c4314b;
    color: #fff;
    font-size: 0.65rem;
    line-height: 1rem;
    text-align: center;
}

.rail-status {
    cursor: default;
}

.rail-status-select {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.rail-status-dot {
    width: 0.7rem;
    height: 0.7rem;
    margin: 0;
}

.rail-bottom {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.has-rail .app-main {
    margin-left: 4.5rem;
    width: calc(100% - 4.5rem);
    max-width: none;
}

.app-main-topbar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: -1.5rem -0.5rem 1rem;
    padding: 0.65rem 1rem;
    background: linear-gradient(90deg, #5b5fc7 0%, #4f52b2 55%, #464775 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 1020;
}

.app-topbar-brand .topbar-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
}

.app-topbar-search {
    flex: 1;
    max-width: 520px;
    position: relative;
    margin: 0 auto;
}

.app-topbar-search i {
    position: absolute;
    left: 0.65rem;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.7;
    pointer-events: none;
}

.app-topbar-search input {
    padding-left: 2rem;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
}

.app-topbar-search input::placeholder {
    color: rgba(255, 255, 255, 0.75);
}

.app-topbar-search input:focus {
    background: rgba(255, 255, 255, 0.28);
    color: #fff;
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.45);
}

.app-topbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.app-topbar-actions .topbar-user {
    color: #fff;
    font-size: 0.85rem;
}

.topbar-msg-badge {
    position: absolute;
    top: -0.35rem;
    right: -0.35rem;
    font-size: 0.65rem;
}

.chat-system-time {
    opacity: 0.85;
}

.teams-search-results {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.45rem;
    max-height: 280px;
    overflow: auto;
}

.teams-search-item {
    display: flex;
    gap: 0.65rem;
    align-items: flex-start;
    padding: 0.55rem 0.75rem;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f1f3f5;
}

.teams-search-item:hover {
    background: #f8f9fa;
}

.teams-search-item i {
    font-size: 1.2rem;
    margin-top: 0.15rem;
}

.voice-call-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(20, 20, 30, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
}

.voice-call-card {
    background: #252833;
    color: #fff;
    border-radius: 1rem;
    padding: 2rem 2.5rem;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
}

.voice-call-avatar {
    width: 4.5rem;
    height: 4.5rem;
    margin: 0 auto 1rem;
    border-radius: 50%;
    background: #6264a7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.voice-call-status {
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.voice-call-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.voice-call-actions .btn.active {
    background: #6c757d;
}

.has-rail .app-footer {
    margin-left: 4.5rem;
}

.chat-system {
    text-align: center;
    color: #6c757d;
    font-size: 0.82rem;
    margin: 0.65rem auto;
    max-width: 85%;
}

.pending-files {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.pending-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 0.4rem;
    padding: 0.2rem 0.45rem;
    font-size: 0.8rem;
    max-width: 100%;
}

.pending-file-chip .btn-remove-file {
    border: none;
    background: transparent;
    color: #dc3545;
    font-size: 1rem;
    line-height: 1;
    padding: 0 0.15rem;
}

.chat-attachments {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Équipes */
.teams-layout {
    display: grid;
    grid-template-columns: minmax(220px, 280px) 1fr;
    gap: 1rem;
    min-height: 70vh;
}

.teams-sidebar,
.teams-main {
    overflow: hidden;
}

.teams-breadcrumb a {
    text-decoration: none;
}

.teams-grid {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.teams-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e9ecef;
    border-radius: 0.45rem;
    background: #fff;
}

.teams-item-icon {
    width: 2.4rem;
    text-align: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.teams-item-body {
    flex: 1;
    min-width: 0;
}

.teams-thumb {
    width: 2.4rem;
    height: 2.4rem;
    object-fit: cover;
    border-radius: 0.3rem;
}

.teams-item[draggable="true"] {
    cursor: grab;
}

.teams-item.dragging {
    opacity: 0.45;
}

.drop-target.drop-hover,
.teams-item.drop-hover {
    outline: 2px dashed #6264a7;
    outline-offset: 2px;
    background: #f4f4fb;
}

.teams-badge {
    display: inline-block;
    margin-left: 0.25rem;
    color: #6c757d;
    font-size: 0.85em;
}

.teams-ctx-menu {
    position: fixed;
    z-index: 1090;
    min-width: 200px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.45rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.35rem 0;
}

.teams-ctx-menu button {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.45rem 0.9rem;
    text-align: left;
    font-size: 0.9rem;
}

.teams-ctx-menu button:hover {
    background: #f1f3f5;
}

.teams-ctx-menu hr {
    margin: 0.3rem 0;
}

.folder-color-choices {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.folder-color-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 0.4rem;
    border: 2px solid transparent;
    cursor: pointer;
}

.folder-color-swatch.selected,
.folder-color-swatch:hover {
    border-color: #212529;
}

.teams-main.os-drop-active {
    outline: 3px dashed #6264a7;
    outline-offset: -6px;
    background: #f4f4fb;
}

.teams-main.os-drop-active::after {
    content: 'Déposez vos fichiers ici';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(244, 244, 251, 0.85);
    font-weight: 600;
    color: #6264a7;
    pointer-events: none;
    z-index: 5;
}

.chat-ctx-menu {
    position: fixed;
    z-index: 1090;
    min-width: 180px;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.45rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    padding: 0.35rem 0;
}

.chat-ctx-menu button {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    border: none;
    background: transparent;
    padding: 0.45rem 0.9rem;
    text-align: left;
    font-size: 0.9rem;
}

.chat-ctx-menu button:hover {
    background: #f1f3f5;
}

.chat-audio {
    max-width: min(100%, 320px);
    height: 2.4rem;
    vertical-align: middle;
}

#pdfViewerModal .modal-content {
    background: #2b2b2b;
}

#pdfViewerModal .modal-header {
    background: #1e1e1e;
    color: #fff;
    border-bottom-color: #444;
}

#pdfViewerModal .btn-close {
    filter: invert(1);
}

.voice-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

#voiceRecordBtn.recording {
    animation: pulse-mic 1s infinite;
}

@keyframes pulse-mic {
    50% { opacity: 0.65; }
}

@media (max-width: 768px) {
    .kanban-column {
        flex-basis: 85vw;
    }

    .messaging-main {
        min-height: 420px;
    }

    .teams-layout {
        grid-template-columns: 1fr;
    }

    .app-rail {
        width: 3.5rem;
    }

    .rail-label {
        display: none;
    }

    .has-rail .app-main,
    .has-rail .app-footer {
        margin-left: 3.5rem;
        width: calc(100% - 3.5rem);
    }
}
