/* --- VARIABLES --- */
:root {
    --primary: #ff5100;
    --primary-dark: #e64a00;
    --bg-app: #ffffff;
    --bg-side: #f5f5f7;
    --text: #1d1d1f;
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background: var(--bg-app);
    color: var(--text);
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* --- SPLASH SCREEN --- */
#splash-screen {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: 0.8s;
}

.simulation-box {
    text-align: center;
    width: 260px;
}

#svg-logo {
    width: 130px;
    height: 130px;
    margin-bottom: 20px;
}

.logo-piece {
    fill: var(--primary);
    opacity: 0;
    transform: scale(0);
    transition: 0.5s;
}

.piece-circle {
    animation: piecePop 1s forwards 0.2s;
}

.piece-ear-l {
    animation: piecePop 1s forwards 0.5s;
}

.piece-ear-r {
    animation: piecePop 1s forwards 0.7s;
}

.piece-eye-l,
.piece-eye-r {
    fill: white;
    animation: piecePop 0.5s forwards 1.2s;
}

.piece-mouth {
    stroke: white;
    fill: none;
    stroke-width: 5;
    animation: piecePop 0.5s forwards 1.4s;
}

@keyframes piecePop {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.splash-text {
    font-size: 32px;
    font-weight: 800;
    opacity: 0;
    animation: fadeIn 1s forwards 1.8s;
}

.splash-text span {
    color: var(--primary);
}

.progress-container {
    width: 100%;
    height: 4px;
    background: #eee;
    border-radius: 10px;
    margin: 20px 0;
    overflow: hidden;
}

#progress-fill {
    width: 0;
    height: 100%;
    background: var(--primary);
    animation: loadBar 3s forwards;
}

@keyframes loadBar {
    to {
        width: 100%;
    }
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

/* --- AUTHENTIFICATION --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9000;
}

.auth-card {
    background: white;
    padding: 40px;
    border-radius: 30px;
    width: 90%;
    max-width: 420px;
    text-align: center;
}

.social-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 12px;
    background: white;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.social-btn:hover {
    background: #f9f9f9;
}

.social-btn img {
    width: 20px;
}

.divider {
    margin: 20px 0;
    color: #999;
    position: relative;
}

.divider::before,
.divider::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #eee;
}

.divider::before {
    left: 0;
}

.divider::after {
    right: 0;
}

.input-wrap {
    position: relative;
    margin-bottom: 12px;
}

.input-wrap i {
    position: absolute;
    left: 15px;
    top: 15px;
    color: var(--primary);
}

.input-wrap input {
    width: 100%;
    padding: 14px 15px 14px 45px;
    border: 1px solid #ddd;
    border-radius: 12px;
    font-size: 16px;
    outline: none;
}

#email-login-btn {
    width: 100%;
    padding: 15px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
}

/* --- LAYOUT --- */
#app-wrapper {
    display: flex;
    height: 100vh;
    width: 100vw;
    position: relative;
}

/* Sidebar */
#sidebar {
    width: 300px;
    background: var(--bg-side);
    border-right: 1px solid #e5e5e7;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 8500;
}

.sidebar-top {
    padding: 25px;
}

#new-chat-trigger {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid var(--primary);
    background: white;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
}

.sidebar-section-label {
    font-size: 11px;
    font-weight: 800;
    color: #999;
    padding: 15px 25px 10px;
    text-transform: uppercase;
}

#history-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 15px;
}

.history-file {
    padding: 12px;
    background: white;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}

.history-file:hover {
    border-color: var(--primary);
}

.sidebar-profile {
    padding: 20px;
    border-top: 1px solid #ddd;
    display: flex;
    align-items: center;
    gap: 12px;
}

#user-avatar {
    width: 42px;
    height: 42px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.user-details p {
    font-size: 14px;
    font-weight: 700;
}

.user-details span {
    font-size: 11px;
    color: #888;
}

#logout-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: #ccc;
    cursor: pointer;
}

#sidebar-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 8000;
    display: none;
}

/* Main Area */
#chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    background: white;
}

#chat-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid #f0f0f2;
    justify-content: space-between;
}

#menu-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #333;
}

.header-title {
    font-size: 20px;
    font-weight: 600;
}

.header-title strong {
    color: var(--primary);
}

.header-status {
    font-size: 11px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
}

.dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
}

#messages-window {
    flex: 1;
    overflow-y: auto;
    padding: 40px 15%;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    max-width: 85%;
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.6;
    font-size: 15px;
}

.user {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.ai {
    align-self: flex-start;
    background: #f2f2f7;
    color: #1d1d1f;
    border-bottom-left-radius: 2px;
}

/* Footer */
#chat-footer {
    padding: 20px 15% 40px;
}

.input-controls {
    display: flex;
    align-items: flex-end;
    gap: 15px;
    max-width: 900px;
    margin: auto;
}

#phone-mode-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: #f2f2f7;
    color: #555;
    cursor: pointer;
    transition: 0.3s;
    flex-shrink: 0;
}

#phone-mode-btn.active {
    background: #ff3b30;
    color: white;
    animation: ripple 1.5s infinite;
}

@keyframes ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.4);
    }

    100% {
        box-shadow: 0 0 0 15px rgba(255, 59, 48, 0);
    }
}

.text-box-wrap {
    flex: 1;
    background: #f2f2f7;
    border-radius: 26px;
    display: flex;
    padding: 12px 20px;
    border: 1px solid #e5e5e7;
}

#chat-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    font-size: 16px;
    padding: 5px 0;
    max-height: 160px;
}

.box-actions {
    display: flex;
    gap: 15px;
    margin-left: 10px;
}

.box-actions button {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 20px;
    cursor: pointer;
}

/* Style pour les images dans les messages */
.message img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin-top: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: block;
}

.legals {
    text-align: center;
    font-size: 11px;
    color: #aaa;
    margin-top: 15px;
}

/* MOBILE & SWIPE */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: 0;
        height: 100%;
        transform: translateX(-100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebar-mask.active {
        display: block;
    }

    #messages-window,
    #chat-footer {
        padding-left: 5%;
        padding-right: 5%;
    }
}