:root {
    /* Tema Chiaro & Glossy */
    --bg-color: #f8fafc;
    /* Grigio chiarissimo, quasi bianco */
    --card-bg: rgba(255, 255, 255, 0.75);
    /* Bianco semitrasparente per l'effetto vetro */
    --glass-bg: rgba(255, 255, 255, 0.6);
    --border-color: rgba(255, 255, 255, 0.8);
    /* Bordo molto chiaro per dare brillantezza */
    --border-subtle: rgba(0, 0, 0, 0.06);
    /* Bordo scuro sottilissimo per contrasto */

    --text-primary: #1e293b;
    /* Grigio ardesia molto scuro */
    --text-secondary: #64748b;
    /* Grigio medio */

    --accent-primary: #3b82f6;
    /* Blu moderno vibrante */
    --accent-secondary: #8b5cf6;
    /* Viola accento */
    --accent-glow: rgba(59, 130, 246, 0.25);

    --success: #10b981;
    --danger: #ef4444;

    /* Ombre molto morbide ed estese per sollevare gli elementi dallo sfondo chiaro */
    --shadow-soft: 0 10px 40px -10px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 20px 40px -10px rgba(59, 130, 246, 0.15);
}

* {
    box-sizing: border-box;
}

body {
    /* Sfondo chiaro con un gradiente radiale molto delicato per dare profondità */
    background: radial-gradient(circle at top right, #ffffff, #f1f5f9);
    color: var(--text-primary);
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem;
}

/* L'effetto Glossy (Glassmorphism) */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    /* Doppio bordo finto: uno bianco interno (glossy) e uno grigio chiarissimo esterno */
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5), var(--shadow-soft);
    border-radius: 20px;
    padding: 2rem;
    margin-bottom: 2rem;
}

h1,
h2,
h3 {
    margin-top: 0;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    letter-spacing: -0.5px;
}

/* Pulsanti */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-decoration: none;
    border: none;
    font-family: inherit;
    font-size: 1rem;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #2563eb);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
    background: linear-gradient(135deg, #4f8bf9, #3b82f6);
}

.btn-secondary {
    background: white;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.btn-danger {
    background: white;
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: #fef2f2;
    border-color: var(--danger);
}

/* Form Elements */
input,
textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.8);
    border: 1px solid var(--border-subtle);
    border-radius: 14px;
    padding: 0.85rem 1.2rem;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    background: white;
    box-shadow: 0 0 0 4px var(--accent-glow);
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

/* Dashboard */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 2rem;
}

.bot-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.bot-card {
    background: white;
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    padding: 1.5rem;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-shadow: var(--shadow-soft);
}

.bot-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.user-info {
    font-size: 0.95rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Chat */
.chat-container {
    height: 60vh;
    overflow-y: auto;
    padding: 1.5rem;
    background: rgba(241, 245, 249, 0.5);
    /* Grigio freddo chiarissimo */
    border-radius: 20px;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-subtle);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.02);
}

/* Scrollbar personalizzata per la chat */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-thumb {
    background-color: #cbd5e1;
    border-radius: 10px;
}

.memory-entry {
    margin-bottom: 1.2rem;
    padding: 1rem 1.25rem;
    border-radius: 18px;
    max-width: 85%;
    position: relative;
    animation: fadeIn 0.4s ease;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.entry-chat {
    background: white;
    border: 1px solid var(--border-subtle);
    /* Allinea a sinistra per i messaggi normali */
    align-self: flex-start;
}

.entry-thought {
    background: #f0fdf4;
    /* Verde chiarissimo pastello */
    border: 1px solid #dcfce7;
    color: #166534;
    /* Verde scuro per il testo per leggibilità */
    font-style: italic;
    border-left: 4px solid var(--success);
}

.entry-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
}

/* Login */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.login-box {
    max-width: 420px;
    width: 100%;
}

.divider {
    text-align: center;
    margin: 2rem 0;
    position: relative;
}

.divider::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e2e8f0;
}

.divider span {
    background: #f8fafc;
    padding: 0 1rem;
    position: relative;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.btn-google {
    background: white;
    color: var(--text-primary);
    width: 100%;
    margin-bottom: 1rem;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.04);
}

/* Loading Overlay */
#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 1rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.error-msg {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

.default-bot {
    border-color: var(--accent-primary) !important;
    box-shadow: 0 8px 32px 0 rgba(79, 70, 229, 0.15) !important;
}

.success-msg {
    color: #15803d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    padding: 1rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    font-size: 0.95rem;
    font-weight: 500;
}

/* =========================================
   📱 MOBILE RESPONSIVENESS
   Ottimizzazione per schermi stretti
   ========================================= */
@media (max-width: 600px) {

    /* 1. Massimizza lo Spazio: Riduciamo i padding globali */
    .container {
        padding: 1rem 0.5rem;
    }

    .glass-card {
        padding: 1.25rem 1rem;
        border-radius: 16px;
        margin-bottom: 1rem;
    }

    .chat-container {
        padding: 0.75rem;
        height: 65vh;
        /* Leggermente più alto su mobile */
        border-radius: 16px;
    }

    /* 2. Rimuovi il Max-Width: I messaggi occupano tutto lo schermo */
    .memory-entry {
        max-width: 100%;
        padding: 0.85rem;
        border-radius: 14px;
        font-size: 0.95rem;
        /* Leggermente più proporzionato per la lettura mobile */
    }

    /* 3. Migliora la Leggibilità: Niente corsivo sui testi lunghi */
    .entry-thought {
        font-style: normal;
    }

    /* 4. Ridimensiona i Titoli */
    h1 {
        font-size: 1.75rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* 5. Extra: UX Mobile-friendly */
    .bot-grid {
        grid-template-columns: 1fr;
        /* Forza 1 bot per riga */
    }

    .btn {
        width: 100%;
        /* Pulsanti a larghezza piena per essere cliccati facilmente col pollice */
        margin-bottom: 0.5rem;
    }
}