* {
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #0a0a1a, #000000);
    color: #fff;
    font-family: 'Courier New', monospace;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    display: flex;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
#sidebar {
    width: 280px;
    background: linear-gradient(180deg, #0a0a1a, #000000);
    border-right: 2px solid #00d9ff;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

#sidebar.hidden {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 15px;
    background: rgba(0, 217, 255, 0.1);
    border-bottom: 2px solid #00d9ff;
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.3em;
    color: #00d9ff;
    text-shadow: 2px 2px #0088cc;
    flex: 1;
}

#new-chat-btn {
    width: 100%;
    padding: 10px;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    color: #000;
    border: 2px solid #00d9ff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s;
}

#new-chat-btn:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.conversation-item {
    padding: 12px;
    margin: 5px 0;
    background: rgba(0, 136, 204, 0.2);
    border: 1px solid #0088cc;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.conversation-item:hover {
    background: rgba(0, 136, 204, 0.4);
    border-color: #00d9ff;
    transform: translateX(5px);
}

.conversation-item.active {
    background: rgba(0, 217, 255, 0.3);
    border-color: #00d9ff;
    border-width: 2px;
}

.conversation-title {
    font-weight: bold;
    color: #00d9ff;
    font-size: 0.95em;
    margin-bottom: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-date {
    font-size: 0.75em;
    color: #888;
}

.delete-conv-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #ff4444;
    color: #fff;
    border: none;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9em;
    display: none;
    transition: all 0.2s;
}

.conversation-item:hover .delete-conv-btn {
    display: block;
}

.delete-conv-btn:hover {
    background: #ff6666;
    transform: translateY(-50%) scale(1.1);
}

/* Ajouter après la section #toggle-sidebar-inside */

/* ===== BOUTON TOGGLE INTÉRIEUR (dans la sidebar) ===== */
#toggle-sidebar-inside {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    color: #000;
    border: 2px solid #00d9ff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 217, 255, 0.3);
    flex-shrink: 0;
}

#toggle-sidebar-inside:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.5);
}

#toggle-sidebar-inside svg {
    width: 20px;
    height: 20px;
    transition: all 0.3s;
}

/* ===== BOUTON TOGGLE EXTÉRIEUR (visible quand sidebar fermée) ===== */
#toggle-sidebar-outside {
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 200;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    color: #000;
    border: 2px solid #00d9ff;
    border-radius: 8px;
    cursor: pointer;
    display: none; /* Caché par défaut */
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 3px 10px rgba(0, 217, 255, 0.5);
}

#toggle-sidebar-outside:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.7);
}

#toggle-sidebar-outside svg {
    width: 24px;
    height: 24px;
    transition: all 0.3s;
    transform: scaleX(-1);
}

/* Afficher le bouton extérieur seulement quand sidebar est cachée */
#sidebar.hidden ~ #toggle-sidebar-outside {
    display: flex;
}

/* Bouton toggle mobile (fixe en haut à gauche) */
#toggle-sidebar-mobile {
    display: none;
    position: fixed;
    left: 10px;
    top: 10px;
    z-index: 200;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    color: #000;
    border: 2px solid #00d9ff;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 10px rgba(0, 217, 255, 0.5);
}

#toggle-sidebar-mobile:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.5);
}

#toggle-sidebar-mobile svg {
    width: 24px;
    height: 24px;
}

/* ===== MAIN CONTENT ===== */
#main-content {
    flex: 1;
    margin-left: 280px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s;
}

#sidebar.hidden ~ #main-content {
    margin-left: 0;
}

h1 {
    font-size: clamp(2em, 5vw, 3.5em);
    color: #00d9ff;
    text-shadow: 0 0 20px rgba(0, 217, 255, 0.8), 3px 3px #0088cc;
    margin: 10px 0;
    animation: pulse 2s infinite;
    text-align: center;
}

.nexus-logo {
    display: inline-block;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: bold;
    letter-spacing: 3px;
}

@keyframes pulse {
    0% { transform: scale(1); text-shadow: 0 0 20px rgba(0, 217, 255, 0.8), 3px 3px #0088cc; }
    50% { transform: scale(1.05); text-shadow: 0 0 30px rgba(0, 217, 255, 1), 3px 3px #0088cc; }
    100% { transform: scale(1); text-shadow: 0 0 20px rgba(0, 217, 255, 0.8), 3px 3px #0088cc; }
}

#clock {
    font-size: clamp(1.2em, 3vw, 1.8em);
    color: #00d9ff;
    background: #0a0a1a;
    padding: 8px 15px;
    border: 2px solid #00d9ff;
    border-radius: 5px;
    display: inline-block;
    margin: 5px auto;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
    text-align: center;
}

.ad-banner {
    background: linear-gradient(145deg, #0088cc, #005580);
    border: 2px solid #00d9ff;
    color: #fff;
    padding: 8px;
    margin: 10px auto;
    width: 90%;
    max-width: 320px;
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.4);
    text-align: center;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
}

.ad-banner:hover {
    transform: scale(1.02);
    box-shadow: 0 0 25px rgba(0, 217, 255, 0.6);
}

.ad-banner span.star-icon {
    color: #00d9ff;
    font-size: 1.5em;
    margin-right: 8px;
    vertical-align: middle;
}

.ad-dimensions {
    display: block;
    font-size: 0.9em;
    font-weight: normal;
    margin-top: 5px;
    color: #99e6ff;
}

.warning {
    color: #00d9ff;
    font-size: clamp(1em, 2.5vw, 1.3em);
    font-weight: bold;
    margin: 10px auto;
    text-shadow: 0 0 10px rgba(0, 217, 255, 0.6);
    padding: 0 10px;
    text-align: center;
}

.api-status {
    font-size: 0.9em;
    color: #00ff88;
    margin: 5px 0;
    padding: 5px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    display: inline-block;
    text-align: center;
}

/* ===== FILE UPLOADS ===== */
#file-input {
    display: none;
}

.uploaded-files-container {
    margin: 10px auto;
    max-width: 600px;
    min-height: 40px;
}

.uploaded-file {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(0, 136, 204, 0.1));
    padding: 8px 12px;
    border-radius: 8px;
    margin: 5px;
    border: 2px solid #00d9ff;
    font-size: 0.9em;
    animation: slideIn 0.3s;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.uploaded-file .file-icon {
    margin-right: 8px;
    font-size: 1.2em;
}

.uploaded-file .file-name {
    color: #00d9ff;
    font-weight: bold;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.uploaded-file .remove-file {
    margin-left: 12px;
    color: #ff4444;
    cursor: pointer;
    font-weight: bold;
    font-size: 1.2em;
    transition: all 0.2s;
}

.uploaded-file .remove-file:hover {
    color: #ff6666;
    transform: scale(1.2);
}

/* ===== CHAT BOX ===== */
#chat-box {
    width: 95%;
    max-width: 900px;
    min-height: 400px;
    border: 3px solid #00d9ff;
    padding: 20px;
    overflow-y: auto;
    margin: 10px auto 20px auto;
    background: linear-gradient(135deg, #0a0a1a, #001a2e);
    border-radius: 15px;
    box-shadow: 0 0 30px rgba(0, 217, 255, 0.3), inset 0 0 20px rgba(0, 0, 0, 0.5);
}

#chat-box::-webkit-scrollbar,
#sidebar::-webkit-scrollbar,
.conversations-list::-webkit-scrollbar {
    width: 10px;
}

#chat-box::-webkit-scrollbar-track,
#sidebar::-webkit-scrollbar-track,
.conversations-list::-webkit-scrollbar-track {
    background: #0a0a1a;
    border-radius: 10px;
}

#chat-box::-webkit-scrollbar-thumb,
#sidebar::-webkit-scrollbar-thumb,
.conversations-list::-webkit-scrollbar-thumb {
    background: #00d9ff;
    border-radius: 10px;
}

#chat-box::-webkit-scrollbar-thumb:hover,
#sidebar::-webkit-scrollbar-thumb:hover,
.conversations-list::-webkit-scrollbar-thumb:hover {
    background: #00ffff;
}

/* ===== MESSAGES ===== */
.user-message {
    text-align: right;
    margin: 12px 0;
    padding: 12px 15px;
    background: linear-gradient(135deg, #0088cc, #005580);
    border-radius: 15px 15px 5px 15px;
    color: #fff;
    max-width: 75%;
    margin-left: auto;
    font-size: 1em;
    word-wrap: break-word;
    box-shadow: 0 3px 10px rgba(0, 136, 204, 0.5);
    animation: slideInRight 0.3s;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.bot-message {
    text-align: left;
    margin: 12px 0;
    padding: 12px 15px;
    background: linear-gradient(135deg, #001a2e, #002244);
    border-radius: 15px 15px 15px 5px;
    border-left: 3px solid #00d9ff;
    color: #fff;
    max-width: 75%;
    margin-right: auto;
    font-size: 1em;
    word-wrap: break-word;
    line-height: 1.6;
    box-shadow: 0 3px 10px rgba(0, 217, 255, 0.3);
    animation: slideInLeft 0.3s;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.bot-message.typing::after {
    content: '▋';
    animation: blink-cursor 0.7s infinite;
    color: #00d9ff;
}

@keyframes blink-cursor {
    0%, 49% { opacity: 1; }
    50%, 100% { opacity: 0; }
}

.bot-message strong {
    color: #00d9ff;
    font-weight: bold;
}

.bot-message em {
    color: #66ccff;
    font-style: italic;
}

.bot-message ul, .bot-message ol {
    text-align: left;
    margin: 10px 0;
    padding-left: 20px;
}

.bot-message li {
    margin: 5px 0;
}

.bot-message code {
    background: #0a0a1a;
    padding: 2px 6px;
    border-radius: 3px;
    color: #00ff88;
    font-family: 'Courier New', monospace;
    border: 1px solid #00d9ff;
}

.bot-message pre {
    background: #0a0a1a;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    border-left: 3px solid #00d9ff;
    margin: 10px 0;
}

.bot-message pre code {
    background: none;
    padding: 0;
    border: none;
}

.bot-message h1, .bot-message h2, .bot-message h3 {
    color: #00d9ff;
    margin: 10px 0 5px 0;
}

.bot-message blockquote {
    border-left: 3px solid #00d9ff;
    padding-left: 10px;
    margin: 10px 0;
    color: #99e6ff;
    font-style: italic;
}

.bot-message a {
    color: #00d9ff;
    text-decoration: underline;
}

.bot-message a:hover {
    color: #00ffff;
}

.bot-message p {
    margin: 8px 0;
}

.typing-indicator {
    text-align: left;
    margin: 12px 0;
    padding: 12px 15px;
    background: linear-gradient(135deg, #001a2e, #002244);
    border-radius: 15px 15px 15px 5px;
    border-left: 3px solid #00d9ff;
    color: #fff;
    max-width: 70%;
    margin-right: auto;
    font-size: 1.1em;
}

.typing-indicator span {
    animation: blink 1.4s infinite;
    opacity: 0;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes blink {
    0%, 60%, 100% { opacity: 0; }
    30% { opacity: 1; }
}

/* ===== INPUT CONTAINER ===== */
#input-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 10px auto 30px auto;
    width: 95%;
    max-width: 900px;
    gap: 10px;
    padding: 15px;
    background: linear-gradient(135deg, rgba(0, 217, 255, 0.1), rgba(0, 136, 204, 0.1));
    border-radius: 15px;
    border: 2px solid #00d9ff;
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.2);
    position: sticky;
    bottom: 10px;
    z-index: 50;
}

#home-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    border: 2px solid #00d9ff;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    text-decoration: none;
}

#home-btn:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.1);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.5);
}

#home-btn svg {
    width: 26px;
    height: 26px;
    transition: all 0.3s;
}

#home-btn svg path {
    stroke: #000;
}

#home-btn:hover svg {
    transform: scale(1.1);
}

#attach-file-btn {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #00ff88, #00cc66);
    border: 2px solid #00d9ff;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    position: relative;
}

#attach-file-btn:hover {
    background: linear-gradient(135deg, #00ffaa, #00ff88);
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 5px 20px rgba(0, 255, 136, 0.5);
}

#attach-file-btn svg {
    width: 24px;
    height: 24px;
    transition: all 0.3s;
}

#attach-file-btn:hover svg {
    transform: rotate(-90deg);
}

#user-input {
    padding: 12px 15px;
    font-size: 1.1em;
    border: 2px solid #00d9ff;
    background: #0a0a1a;
    color: #fff;
    border-radius: 10px;
    flex: 1;
    min-width: 150px;
    transition: all 0.3s;
}

#user-input:focus {
    outline: none;
    border-color: #00ffff;
    box-shadow: 0 0 15px rgba(0, 217, 255, 0.5);
}

#user-input::placeholder {
    color: #666;
}

#send-button {
    padding: 12px 25px;
    font-size: 1.1em;
    background: linear-gradient(135deg, #00d9ff, #0088cc);
    color: #000;
    border: 2px solid #00d9ff;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
    font-weight: bold;
}

#send-button:hover {
    background: linear-gradient(135deg, #00ffff, #00d9ff);
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(0, 217, 255, 0.5);
}

#send-button:disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
    transform: scale(1);
    box-shadow: none;
    border-color: #444;
}

/* ===== FOOTER ===== */
.footer {
    text-align: center;
    width: 100%;
    color: #666;
    font-size: 0.8em;
    text-shadow: 1px 1px #000;
    padding: 20px 0;
}

.footer .nexus-brand {
    color: #00d9ff;
    font-weight: bold;
}

.center-content {
    text-align: center;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    #sidebar {
        width: 85%;
        z-index: 1000;
    }

    #main-content {
        margin-left: 0;
        padding: 70px 10px 10px 10px;
    }

    /* Afficher le bouton toggle mobile */
    #toggle-sidebar-mobile {
        display: flex;
    }

    /* Cacher le bouton toggle desktop dans la sidebar sur mobile */
    #toggle-sidebar {
        display: none;
    }
    
    h1 {
        font-size: 1.8em;
        margin: 5px 0;
    }
    
    #chat-box {
        padding: 10px;
        min-height: 300px;
        width: 100%;
    }
    
    .user-message, .bot-message {
        font-size: 0.95em;
        padding: 10px;
        max-width: 85%;
    }
    
    #input-container {
        gap: 5px;
        padding: 10px;
        width: 100%;
        flex-wrap: wrap;
    }
    
    #user-input {
        font-size: 1em;
        padding: 10px;
        min-width: 0;
        flex: 1 1 100%;
        order: 1;
    }
    
    #send-button {
        padding: 10px 20px;
        font-size: 1em;
        order: 2;
        flex: 1;
    }

    #attach-file-btn, #home-btn {
        width: 40px;
        height: 40px;
        order: 0;
    }

    #attach-file-btn svg {
        width: 20px;
        height: 20px;
    }

    #home-btn svg {
        width: 22px;
        height: 22px;
    }

    .uploaded-files-container {
        width: 100%;
        padding: 0 5px;
    }

    .ad-banner {
        width: 95%;
    }
}

@media (max-width: 480px) {
    #sidebar {
        width: 90%;
    }

    .ad-banner {
        font-size: 0.85em;
        padding: 6px;
    }
    
    .warning {
        font-size: 0.9em;
    }

    .conversation-title {
        font-size: 0.85em;
    }

    .uploaded-file .file-name {
        max-width: 100px;
    }

    h1 {
        font-size: 1.5em;
    }

    #clock {
        font-size: 1em;
        padding: 6px 10px;
    }
}

@media (min-width: 769px) {
    #sidebar.hidden ~ #main-content {
        margin-left: 0;
    }
}
