@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #f5f7fa, #c3cfe2);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Menu principale */
.menu-container {
    width: 100%;
    max-width: 420px;
    height: 90vh;
    background-color: white;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    animation: containerAppear 0.5s ease-out forwards;
}

.menu-header {
    padding: 30px 20px;
    background: linear-gradient(135deg, #6e45e1, #4d79ff);
    color: white;
    text-align: center;
}

.menu-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

.menu-header p {
    font-size: 16px;
    opacity: 0.9;
}

.menu-buttons {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    gap: 20px;
    overflow-y: auto;
}

.menu-btn {
    background-color: #f0f2f5;
    border: none;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    text-align: left;
}

.menu-btn:hover {
    background-color: #e8eaed;
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.1);
}

.menu-btn i {
    font-size: 24px;
    margin-right: 15px;
    color: #6e45e1;
}

.menu-btn span {
    font-size: 16px;
    font-weight: 500;
    color: #333;
}

/* Chat container */
.chat-container {
    width: 100%;
    max-width: 420px;
    height: 90vh;
    background-color: white;
    border-radius: 18px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
    animation: containerAppear 0.5s ease-out forwards;
}

.chat-header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: linear-gradient(135deg, #6e45e1, #4d79ff);
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.profile-pic {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(45deg, #ff9a9e, #fad0c4);
    margin-right: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.profile-pic i {
    font-size: 22px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.profile-pic::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.profile-pic:hover::after {
    transform: scale(1);
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin: 0 0 2px 0;
}

.status {
    font-size: 13px;
    opacity: 0.9;
    position: relative;
    padding-left: 12px;
}

.status::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 8px;
    height: 8px;
    background-color: #4ade80;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-actions i {
    font-size: 18px;
    cursor: pointer;
    opacity: 0.9;
    transition: all 0.2s ease;
}

.header-actions i:hover {
    opacity: 1;
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #f0f2f5;
    background-image: url("data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm56-76c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM12 86c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm28-65c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm23-11c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-6 60c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm29 22c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zM32 63c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm57-13c2.76 0 5-2.24 5-5s-2.24-5-5-5-5 2.24-5 5 2.24 5 5 5zm-9-21c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM60 91c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM35 41c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2zM12 60c1.105 0 2-.895 2-2s-.895-2-2-2-2 .895-2 2 .895 2 2 2z' fill='%239C92AC' fill-opacity='0.05' fill-rule='evenodd'/%3E%3C/svg%3E");
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
}

.message {
    margin-bottom: 15px;
    max-width: 80%;
    position: relative;
}

.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    word-wrap: break-word;
    transition: all 0.3s ease;
}

.message-time {
    font-size: 11px;
    margin-top: 5px;
    opacity: 0.7;
}

.received {
    align-self: flex-start;
    animation: receiveMessage 0.4s ease-out forwards;
    transform-origin: top left;
}

.received .message-content {
    background-color: white;
    border-top-left-radius: 4px;
}

.received .message-content:hover {
    background-color: #f8f8f8;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.sent {
    align-self: flex-end;
    margin-left: auto;
    animation: sendMessage 0.4s ease-out forwards;
    transform-origin: bottom right;
}

.sent .message-content {
    background-color: #dcf8c6;
    border-top-right-radius: 4px;
}

.sent .message-content:hover {
    background-color: #d4f0c0;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
}

.sent .message-time {
    text-align: right;
}

.system {
    align-self: center;
    max-width: 90%;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.system .message-content {
    background-color: #f1f1f1;
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 12px;
}

.typing-indicator {
    display: none;
    padding: 12px 16px;
    background-color: white;
    border-radius: 18px;
    margin-bottom: 15px;
    width: fit-content;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    animation: typingAppear 0.3s ease-out forwards;
}

.typing-indicator span {
    height: 8px;
    width: 8px;
    float: left;
    margin: 0 1px;
    background-color: #9e9ea1;
    display: block;
    border-radius: 50%;
    opacity: 0.4;
}

.typing-indicator span:nth-of-type(1) {
    animation: typing 1s infinite;
}

.typing-indicator span:nth-of-type(2) {
    animation: typing 1s 0.33s infinite;
}

.typing-indicator span:nth-of-type(3) {
    animation: typing 1s 0.66s infinite;
}

.choice-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px 20px;
    background-color: white;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    position: relative;
    z-index: 5;
}

.choice-btn {
    padding: 12px 20px;
    background-color: #f0f2f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    animation: choiceAppear 0.4s ease-out forwards;
    transform: translateY(20px);
    opacity: 0;
}

.choice-btn:nth-child(2) {
    animation-delay: 0.1s;
}

.choice-btn:hover {
    background-color: #e8eaed;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.hidden {
    display: none;
}

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

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    50% {
        transform: translateY(-5px);
        opacity: 1;
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

@keyframes receiveMessage {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes sendMessage {
    0% {
        opacity: 0;
        transform: translateX(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes typingAppear {
    0% {
        opacity: 0;
        transform: translateX(-15px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes choiceAppear {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes containerAppear {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6);
    }
    70% {
        box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
    }
}

@keyframes receiveMessage {
    0% {
        opacity: 0;
        transform: translateX(-20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes sendMessage {
    0% {
        opacity: 0;
        transform: translateX(20px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes typingAppear {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.9);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes choiceAppear {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes containerAppear {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Responsive design */
@media (max-width: 480px) {
    .chat-container {
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .message {
        max-width: 80%;
    }
    
    .choice-btn {
        padding: 16px 24px;
        font-size: 16px;
    }
}

/* Indicatore di scrittura in basso */
.writing-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 15px;
    background-color: transparent;
    position: absolute;
    bottom: 70px; /* Posizionato sopra il contenitore delle scelte */
    left: 0;
    right: 0;
    z-index: 10;
    animation: fadeIn 0.3s ease-out forwards;
}

.writing-balloon {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: white;
    border-radius: 18px;
    padding: 12px 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    gap: 4px;
}

.writing-balloon .dot {
    height: 8px;
    width: 8px;
    background-color: #9e9ea1;
    border-radius: 50%;
    opacity: 0.4;
}

.writing-balloon .dot:nth-of-type(1) {
    animation: typing 1s infinite;
}

.writing-balloon .dot:nth-of-type(2) {
    animation: typing 1s 0.33s infinite;
}

.writing-balloon .dot:nth-of-type(3) {
    animation: typing 1s 0.66s infinite;
}