/* ========================================
   1. ÉLÉMENTS GLOBAUX & HEADER
   ======================================== */

/* Masquer le bouton plug (non utilisé) */
button:has(svg.lucide-plug) {
    display: none;
}

/* Header principal */
#header {
    background: hsl(var(--header-bg));
    height: 47px;
}

#header > div.flex.items-center {
    position: relative;
}

/* Logo dans le header */
#header > div:last-child::before {
    content: "";
    display: block;
    width: 158px;
    height: 21px;
    background-image: url('/public/logo_dark.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    margin-right: 6px;
}

/* Sidebar header */
[data-sidebar="header"] {
    background: hsl(var(--header-bg));
    height: 47px;
    padding-top: 6px !important;
    padding-bottom: 0 !important;
}

/* Boutons du header */
#theme-toggle, #search-chats-button, #sidebar-trigger-button {
    color: hsl(var(--header-muted));
}
/* Bouton fermeture sidebar masqué sur desktop */
#sidebar-trigger-button {
    display: none;
}

/* Hover et focus des éléments du header */
#theme-toggle:hover, #search-chats-button:hover, #sidebar-trigger-button:hover, #chat-profiles:hover, #user-nav-button:hover {
    background-color: hsl(var(--header-hover-bg));
}

#theme-toggle:focus-visible, #new-chat-button:focus-visible, #search-chats-button:focus-visible, #sidebar-trigger-button:focus-visible, #chat-profiles:focus-visible, #user-nav-button:focus-visible {
    --tw-ring-offset-shadow: 1px 0px 15px 5px #00000029;
}

#theme-toggle::focus, #new-chat-button::focus, #search-chats-button::focus, #sidebar-trigger-button::focus, #chat-profiles::focus, #user-nav-button::focus {
    --tw-ring-offset-shadow: 1px 0px 15px 5px #00000029;
}

/* ========================================
   2. SÉLECTION DE PROFIL
   ======================================== */

/* Masquer le sélecteur natif (remplacé par les cartes custom) */
#chat-profiles {
    opacity: 0;
    pointer-events: none;
}

/* Masquer le sous-menu déroulant */
[data-radix-popper-content-wrapper]:has([role="option"]) {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Conteneur des cartes de profil */
#profile-cards-container {
    position: relative;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
    align-items: center;
    width: 100%;
    margin-top: 5px;
}

/* Cartes de sélection de profil */
.profile-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 240px;
    height: 96px;
    border-radius: 20px;
    border: 2px solid hsl(var(--border));
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    cursor: pointer;
    gap: 14px;
    padding: 20px;
    font-family: inherit;
}

.profile-card:hover {
    border: 2px solid hsl(var(--primary));
}

.profile-card img {
    width: 36px !important;
    height: 36px !important;
    margin-bottom: 0 !important;
    border-radius: 20% !important;
    object-fit: cover;
}

.profile-card span {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
}

/* ========================================
   3. WELCOME SCREEN & MESSAGES DE BIENVENUE
   ======================================== */

/* Message de bienvenue principal pour mmulti-profils (avec cartes) */
#welcome-screen .prose {
    font-size: 15px;
    color: hsl(var(--welcome-msg));
    position: relative;
}

#welcome-screen .prose::before {
    content: "Comment puis-je vous aider aujourd'hui ?";
    display: block;
    text-align: center;
    position: absolute;
    top: -41px;
    left: 50%;
    transform: translateX(-50%);
    color: hsl(var(--card-foreground));
    font-family: 'Roboto', sans-serif;
    font-size: 26px;
    font-weight: 500;
    width: max-content;
}

/* Messages de bienvenue pour profil unique (body sans classe) */
body:not([class]) #welcome-screen #message-composer {
    position: relative;
}

body:not([class]) #welcome-screen #message-composer::before {
    content: "Comment puis-je vous aider aujourd'hui ?";
    display: block;
    text-align: center;
    position: absolute;
    top: -134px;
    left: 0;
    font-family: 'Roboto', sans-serif;
    font-size: 26px;
    font-weight: 500;
    width: 100%;
}

body:not([class]) #welcome-screen #message-composer::after {
    content: "Bienvenue sur l'assistant IA interne de Cospirit";
    display: block;
    text-align: center;
    position: absolute;
    top: -87px;
    left: 0;
    font-family: 'Roboto', sans-serif;
    font-size: 16px;
    color: hsl(var(--welcome-msg));
    font-weight: 400;
    width: 100%;
}

/* Avatar du welcome screen */
.welcome-screen img {
    margin-bottom: 50px;
    border-radius: 20% !important;
    width: 50px;
    height: 50px;
}

body:not([class]) .welcome-screen img {
    margin-bottom: 127px;
}

/* Masquer l'envoi de message quand les cartes sont présentes */
#welcome-screen:has(#profile-cards-container) #message-composer {
    display: none;
}

/* ========================================
   4. BOUTON NOUVELLE CONVERSATION
   ======================================== */

#new-chat-button {
    position: absolute;
    left: 22px;
    top: 70px;
    width: auto !important;
    padding: 0 28px;
    z-index: 1000;
    background: hsl(var(--primary));
    color: white;
}

#new-chat-button:hover {
    background-color: #3333ffb0;
}

#new-chat-button svg {
    display: none;
}

#new-chat-button::after {
    content: "Nouvelle conversation";
    font-size: 14px;
    font-weight: 500;
    color: white;
    margin-left: 8px;
}

#new-chat-button::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 4v16m8-8H4' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

/* ========================================
   5. LAYOUT & POSITIONNEMENT
   ======================================== */

#thread-history {
    margin-top: 58px;
}

/* User nav button */
#user-nav-button {
    .bg-primary {
        background: #ecebeb5c;
    }
}

/* Avatar messages IA */
.ai-message .relative.flex {
    width: 25px !important;
    height: 25px !important;
}

/* ========================================
   10. RESPONSIVE - MOBILE & TABLETTE
   ======================================== */

@media (max-width: 1024px) {
    #new-chat-button {
        position: static;
        left: auto;
        top: auto;
        width: 36px !important;
        padding: 0;
    }
    
    #new-chat-button svg {
        display: block;
    }
    
    #new-chat-button::after {
        content: none;
    }
    
    #new-chat-button::before {
        display: none;
    }
    
    #sidebar-trigger-button {
        display: block;
    }
    body:not([class]) #welcome-screen #message-composer::after {
        display: none;
    }
    #welcome-screen .prose::before {
        width: 90vw;
        flex-wrap: wrap;
        top: -78px;
        font-size: 23px;
    }
    #welcome-screen .prose {
        margin-top: 35px;
    }

    #header > div:last-child::before {
        display: none;
    }
    
    #profile-cards-container::after {
        display: none;
    }
}

@media (max-width: 768px) {
    .profile-badge .badge-content {
        font-size: 0 !important;
        padding: 5px !important;
        padding-right: 0 !important;
    }

    .profile-badge .badge-icon {
        font-size: 12px;
    }
}

/* ========================================
   7. STYLES SPÉCIFIQUES PAR PROFIL
   ======================================== */

/* Profil META - boutons et avatar */
.profile-meta #chat-submit, .profile-meta #stop-button{
    background-color: #9900FF !important;
}

/* Avatar personnalisé pour le profil META */
.profile-meta .ai-message img[alt*="Avatar"] {
    content: url('/public/avatars/meta.png') !important;
    src: '/public/avatars/meta.png' !important;
}

/* ========================================
   8. LOADING & INDICATEURS
   ======================================== */

/* Animation de chargement */
@keyframes shimmer {
    0%   { background-position:  200% center; }
    100% { background-position: -200% center; }
}

/* Indicateur de chargement au-dessus du message-composer */
body:has(#message-composer .stop-icon) *:has(> [data-step-type="user_message"])::after {
    content: "Chargement...";
    display: block;
    margin-top: 12px;
    padding-left: 16px;
    font-size: 1em;
    white-space: nowrap;
    background: linear-gradient(
        90deg,
        hsl(var(--muted-foreground, 0 0% 25%)) 25%,
        hsl(var(--foreground, 0 0% 95%)) 50%,
        hsl(var(--muted-foreground, 0 0% 25%)) 75%
    );
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: shimmer 1.6s linear infinite;
}

/* Cacher le curseur de chargement par défaut */
.loading-cursor {
    display: none !important;
}

/* ========================================
   6. TOKENS & PROMPT VIEWER (badges discrets)
   ======================================== */

/* Liens vers les panneaux latéraux (token usage, prompt viewer) */
.element-link {
    opacity: 0.6;
    font-size: 0.6rem !important;
    letter-spacing: 0.05em;
    transition: opacity 0.15s ease, background-color 0.15s ease;
}

.element-link:hover {
    opacity: 1;
}

/* ========================================
   9. ÉLÉMENTS MASQUÉS
   ======================================== */

/* Masquer le bouton readme */
#readme-button {
    display: none;
}

/* Masquer le watermark */
.watermark {
    height: 17px;
}

.watermark .prose {
    display: none;
}

/* Masquer les étapes tool et llm */
[data-step-type="tool"],
[data-step-type="llm"] {
    display: none;
}

/* ========================================
   9. PASTILLE DE PROFIL (MESSAGE COMPOSER)
   ======================================== */

/* Pastille de profil dans le message composer */
.profile-badge {
    margin-right: 8px;
    white-space: nowrap;
}

.profile-badge .badge-content {
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 9999px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
    border-width: 1px;
    border-style: solid;
}

.profile-badge .badge-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.profile-badge .badge-icon svg {
    width: 12px;
    height: 12px;
}

/* Style pour profil META (violet) */
.profile-meta .profile-badge .badge-content {
    background: rgba(153, 0, 255, 0.125);
    color: #9900FF;
    border-color: rgba(153, 0, 255, 0.25);
}

.profile-meta .profile-badge .badge-icon {
    background-color: #9900FF;
}

.profile-meta .profile-badge .badge-icon svg {
    color: white;
}

/* Style pour profil DEFAULT (bleu) */
.profile-default .profile-badge .badge-content {
    background: rgba(59, 130, 246, 0.125);
    color: #3B82F6;
    border-color: rgba(59, 130, 246, 0.25);
}

.profile-default .profile-badge .badge-icon {
    background-color: #3333ffb0;
}

.profile-default .profile-badge .badge-icon svg {
    color: white;
}

#side-view-content .prose {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px;
    background-color: #f4f4f4;
    border-top-width: 10px;
    font-size: 14px;
}

#side-view-content blockquote {
    font-style: normal !important;
}
