/* ==========================================================
   STILI GLOBALI E DI BASE (Dark Theme)
   ========================================================== */
:root {
    --primary-color: #28a745;
    --primary-hover-color: #1a6c2c;
}

* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #1a1a1a; /* Sfondo molto scuro */
    color: #e0e0e0; /* Testo chiaro */
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

.wrapper {
    display: flex;
    flex-grow: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

/* --- CONTAINER STYLES (INDEX & CHAT ACCESS) --- */
.container {
    width: 90%;
    max-width: 450px;
    padding: 30px; /* Ridotto il padding per schermi stretti */
    background-color: #2c2c2c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    margin-top: 20px;
    text-align: center;
}

a {
    /* Colore che si stacca dallo sfondo scuro (coerente con il tema chat/alert) */
    color: var(--primary-color); 
    
    /* Rimuove la sottolineatura predefinita (che è brutta nel dark theme) */
    text-decoration: none; 
    
    /* Transizione fluida per gli stati hover e focus */
    transition: color 0.2s, text-decoration 0.2s;
}

/* Stato al passaggio del mouse (Hover) */
a:hover {
    color: #34d0e0!important; 
}

/* Stato al click (Active) */
a:active {
    color: #007bff; /* Blu primario per un feedback immediato al click */
}

/* --- Link all'interno di elementi specifici (es. nel contenitore dei form) --- */
.container a {
    font-weight: bold;
}

/* ======================================= */
/* 1. STILE BASE DELL'HEADER SOTTILE */
/* ======================================= */

.chat-header {
    width: 100%;
    background-color: #080808;
    border-bottom: 1px solid #1a1a1a;
    padding: 12px 20px;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-grid {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 5px;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 8px; 
    text-decoration: none;
}

.header-logo-img {
    height: 28px;
    width: auto;
}

.logo-text {
    color: var(--primary-color);
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* Navigazione */
.header-nav {
    display: flex;
    gap: 20px;
    align-items: center;
}

.nav-link {
    color: #888;
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    color: var(--primary-color);
}

/* Link attivo (opzionale) */
.nav-link.active {
    color: #fff;
    border-bottom: 1px solid var(--primary-color);
}

/* ======================================= */
/* 2. STILE DEI PULSANTI HOME */
/* ======================================= */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
}

.btn-main {
    padding: 10px 25px;
    border-radius: 8px;
    font-weight: 800;
    text-decoration: none;
    text-transform: uppercase;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
    min-width: 150px;
}

.btn-access {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-access:hover {
    color: #ffffff!important;
    background-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(40, 167, 69, 0.4);
}

.btn-create {
    background-color: transparent;
    border: 2px solid #007bff;
    color: #007bff;
}

.btn-create:hover {
    background-color: #007bff;
    color: #ffffff!important;
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.4);
}

/* ==========================================================
   STILI DEI FORM (Accesso e Creazione Chat)
   ========================================================== */

/* --- Campi di Input Testo/Password --- */
.container input[type="text"],
.container input[type="password"],
.container input[type="alias"] { /* Utilizza anche un input generico se necessario */
    width: 100%;
    padding: 12px;
    margin-bottom: 15px; /* Spazio tra i campi */
    border: 1px solid #444; /* Bordo sottile grigio scuro */
    border-radius: 6px;
    background-color: #383838; /* Sfondo del campo leggermente più chiaro del contenitore */
    color: #e0e0e0; /* Testo chiaro */
    font-size: 1em;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.container input:focus {
    border-color: #00bcd4; /* Bordo colorato al focus (coerente con h1/h2) */
    box-shadow: 0 0 5px rgba(0, 188, 212, 0.5);
    outline: none; /* Rimuove il bordo predefinito del browser */
}

/* --- Pulsanti di Submit Principali (Creazione/Accesso) --- */
.container button[type="submit"],
.container .action-button { /* Se usi un div o a come pulsante */
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    margin-top: 10px; /* Spazio sopra il pulsante */
    transition: background-color 0.3s;
}

/* ==========================================================
   CHAT CLIENT SPECIFIC STYLES
   ========================================================== */
.chat-container {
    width: 95%;
    max-width: 700px;
    height: 80vh;
    background-color: #2c2c2c;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
    padding: 0;
    padding-bottom: 20px;
    border-radius: 8px;
    margin-top: 10px;
    color: #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-grow: 1;
}

h1, h2, h3 {
    color: #00bcd4;
    margin: 0;
    padding: 15px 20px; /* Aggiunto padding per intestazione */
}

.chat-title{
    font-size: 20px;
}

#status-alias {
    margin-bottom: 5px;
    color: #b0b0b0;
    font-size: 0.9em;
    padding: 0 20px;
    z-index: 999;
}

/* --- CHAT WINDOW --- */
#chat-window {
    flex-grow: 1; /* Permette alla chat window di occupare lo spazio disponibile */
    border-top: 1px solid #444; /* Usiamo solo un bordo superiore per separazione */
    height: auto; /* Rimosso l'altezza fissa */
    overflow-y: auto;
    padding: 15px;
    margin-bottom: 0;
    background-color: #222;
    border-radius: 0;
}
#chat-window::-webkit-scrollbar {
    width: 8px;
}
#chat-window::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

/* --- MESSAGES --- */
.message {
    position: relative;
    margin-bottom: 10px;
    padding: 8px 12px;
    border-radius: 18px;
    max-width: 75%; /* Ridotto leggermente per coerenza */
    line-height: 1.4;
    word-wrap: break-word;
}
.message.mine {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    text-align: left; /* Il testo deve essere a sinistra, la bolla si allinea a destra */
}
.message.other {
    background-color: #444;
    color: #e0e0e0;
    margin-right: auto;
    text-align: left;
}
.sender-alias {
    font-weight: bold;
    font-size: 0.85em;
    display: block;
    margin-bottom: 2px;
    color: #00bcd4;
}

.delete-btn {
    cursor: pointer;
    font-size: 0.5em; 
    color: #d9534f;
    opacity: 0.9;
    transition: color 0.2s;
    
    /* POSIZIONAMENTO ASSOLUTO */
    position: absolute;
    top: -5px;    /* Sposta leggermente fuori o in alto dalla bolla */
    right: -5px;  /* Sposta leggermente fuori o a destra dalla bolla */
    
    padding: 5px; 
    background-color: #2c2c2c; /* Colore del contenitore .container o #222 della chat-window per mascherare */
    border-radius: 50%;
    z-index: 10; /* Assicura che sia sopra altri elementi */
    
    /* Per un look più discreto, se vuoi la X DENTRO la bolla, usa: */
    /* top: 5px; */
    /* right: 5px; */
    /* background-color: transparent; */
}

.delete-btn:hover {
    color: #ff0000;
    opacity: 1;
}

/* --- MEDIA --- */
.media-container { 
    margin: 8px 0; 
}
.media-container img, 
.media-container video,
.media-container audio { /* Aggiunto anche l'audio */
    max-width: 100%; 
    max-height: 250px; 
    display: block; 
    border-radius: 4px;
}

/* --- INPUT AREA --- */
#input-area {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    border-top: 1px solid #444;
}
.file-label {
    padding: 10px;
    cursor: pointer;
    font-size: 1.5em;
    line-height: 1;
    color: #b0b0b0;
    transition: color 0.2s;
    flex-shrink: 0; /* Impedisce al label di restringersi */
}
.file-label:hover {
    color: #007bff;
}
#file-input {
    display: none;
}
#message-input {
    font-size: 16px;
    flex-grow: 1;
    padding: 10px;
    border: 1px solid #444;
    border-radius: 20px; /* Arrotondato input per look moderno */
    background-color: #333;
    color: #e0e0e0;
    margin-right: 8px; /* Spazio dal pulsante */
    margin-left: 8px;
}
#input-area button { /* Specificato per l'area input */
    padding: 10px 15px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 5px; /* Arrotondato il pulsante */
    flex-shrink: 0; /* Impedisce al pulsante di restringersi */
}
#input-area button:hover {
    background-color: #218838;
}

/* --- FILE STATUS --- */
#file-status { 
    display: block; 
    padding: 0 20px 10px; /* Spostato sotto l'area input */
    font-size: 0.8em; 
    color: #5cb85c; 
    height: 15px; 
    text-align: left;
    margin-left: 0; /* Rimosso margin-left forzato */
}

/* --- UTILITIES (Barra Progresso, Banner Chiusura, Pulsante Chiusura) --- */
.progress-container {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 5px;
    margin: 10px 0;
    display: none; /* Nascondi di default */
}
.progress-bar {
    height: 20px;
    width: 0%;
    background-color: #4CAF50;
    text-align: center;
    line-height: 20px;
    color: white;
    border-radius: 5px;
    transition: width 0.3s; /* Animazione fluida */
    font-size: 0.8em;
}
.chat-closed-banner {
    background-color: #d9534f;
    color: white;
    padding: 10px 20px;
    text-align: center;
    margin-bottom: 0;
    border-radius: 0;
    font-weight: bold;
}
.chat-container > div:first-child { /* Contenitore header per allineamento */
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}
#delete-chat-btn {
    background-color: #d9534f;
    color: white;
    padding: 5px 10px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    margin-left: 10px;
}
#delete-chat-btn:hover {
    background-color: #933633;
}

/* Stile per i Messaggi di Sistema (Notifiche di unione) */
.system-message {
    text-align: center;
    font-size: 0.8em;
    color: #888; /* Grigio chiaro per il testo del sistema */
    margin: 10px 0;
    padding: 5px 10px;
    border-radius: 5px;
    background-color: #3a3a3a; /* Sfondo leggermente più scuro o più chiaro del contenitore */
    font-style: italic;
}
/* ========================================================== */
/* FOOTER
/* ========================================================== */

.chat-footer {
    width: 100%;
    margin-top: 10px;
    padding: 20px;
    background-color: #080808;
    border-top: 1px solid #1a1a1a;
    color: #666;
    font-family: sans-serif;
}

.footer-grid {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
}

/* Colonna sinistra (Testo) */
.footer-info {
    flex: 2; /* Prende più spazio */
    font-size: 0.75rem;
    line-height: 1.5;
    text-align: left;
}

/* Colonna destra (Links & Copyright) */
.footer-actions {
    flex: 1;
    text-align: right;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-link {
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    transition: color 0.3s;
}

.footer-copyright {
    font-size: 0.7rem;
    opacity: 0.4;
    margin-top: 10px;
}

/***************/
/* PRIVACY     */
/***************/
/* --- PRIVACY PAGE STYLING --- */
.privacy-container {
    max-width: 800px;
    margin: 20px auto;
    padding: 20px;
    color: #ccc;
    line-height: 1.7;
    font-family: sans-serif;
}

.privacy-container h1 {
    color: var(--primary-color);
    border-bottom: 1px solid #222;
    padding-bottom: 10px;
    margin-bottom: 30px;
}

.privacy-container h2 {
    color: #eee;
    font-size: 1.2rem;
    margin-top: 30px;
}

.privacy-section {
    margin-bottom: 25px;
    background: #111;
    padding: 20px;
    border-radius: 8px;
    border-left: 3px solid var(--primary-color);
}

.privacy-container p {
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.highlight-box {
    background-color: rgba(40, 167, 69, 0.1);
    border: 1px solid rgba(40, 167, 69, 0.2);
    padding: 15px;
    border-radius: 5px;
    color: #fff;
    font-weight: bold;
}

/* --- DONATE PAGE STYLING --- */
.donate-card {
    background: #111;
    border: 1px solid #222;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    transition: transform 0.2s;
}

.donate-card:hover {
    border-color: var(--primary-color);
}

.crypto-name {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.address-box {
    background: #000;
    padding: 12px;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--primary-color);
    word-break: break-all;
    cursor: pointer;
    position: relative;
    border: 1px solid #333;
}

.address-box:hover {
    background: #050505;
}

/* Tooltip per il "Copiato!" */
.copy-tooltip {
    position: absolute;
    top: -30px;
    right: 10px;
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    display: none;
}

/* --- DISCRETE FLOATING SUPPORT --- */
.floating-support {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

/* Il cerchietto verde */
.support-trigger {
    background: var(--primary-color);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
    border: none;
    font-size: 1.2rem;
    transition: transform 0.2s;
}

/* La label discreta accanto */
.support-label {
    background: rgba(20, 20, 20, 0.8);
    backdrop-filter: blur(5px);
    color: #aaa;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    border: 1px solid #333;
    pointer-events: none; /* Non intralcia i click */
    white-space: nowrap;
    opacity: 0.8;
}

.floating-support:hover .support-trigger {
    transform: scale(1.1);
    background: #34ce57;
}

.floating-support:hover .support-label {
    color: #fff;
    border-color: var(--primary-color);
    opacity: 1;
}

/* Menu a comparsa sopra */
.support-menu {
    position: absolute;
    bottom: 60px;
    left: 0;
    display: none; /* Usiamo JS per lo switch o lasciamo hover */
    flex-direction: column;
    gap: 8px;
}

.floating-support:hover .support-menu {
    display: flex;
}

.support-item {
    background: #111;
    color: #eee;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.8rem;
    text-decoration: none;
    border: 1px solid #333;
    white-space: nowrap;
}

.support-item:hover {
    background: var(--primary-color);
    color: #fff;
}

.support-btn-small {
    display: block;
    padding: 8px 12px;
    background: #111;
    border: 1px solid #333;
    color: #888;
    text-decoration: none;
    font-size: 0.75rem;
    border-radius: 4px;
    text-align: center;
    transition: all 0.2s ease;
}

.support-btn-small:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #161616;
}

/* Support Bar chat_client.php */
.support-bar {
    background: #0a0a0a;
    padding: 8px 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 15px;
    font-size: 0.7rem;
}

.support-bar span {
    color: #555;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 0.7rem;
}

.support-bar a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
    transition: 0.2s;
}

.support-bar a:hover {
    color: #34ce57;
    text-decoration: underline;
}

#chat-container {
    position: relative;
    min-height: 400px; 
}

/* Loader CHAT */
.loader-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5); display: flex; flex-direction: column;
    align-items: center; justify-content: center; z-index: 100;
}

.loader-overlay p {
    color: var(--primary-color);
    font-weight: bold;;
}

.spinner {
    border: 4px solid #ffffff; border-top: 4px solid var(--primary-color);
    border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* ABOUT */
.about-container {
    max-width: 850px;
    margin: 20px auto;
    padding: 30px;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
}

.about-header {
    text-align: center;
    margin-bottom: 30px;
}

.about-header h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.about-header .tagline {
    font-size: 1.1rem;
    color: #8b949e;
    font-weight: 400;
    margin:0;
}

.about-container h2 {
    color: #f0f6fc;
    border-left: 4px solid var(--primary-color);
    padding-left: 15px;
    margin-top: 40px;
}

.feature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 30px 0;
}

.feature-card {
    padding: 20px;
    background: #0d1117;
    border-radius: 8px;
    border: 1px solid #30363d;
    transition: transform 0.2s;
}

.feature-card:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.feature-card h3 {
    margin-top: 0;
    color: var(--primary-color);
    font-size: 1.1rem;
}

.tech-stack {
    background: #0d1117;
    border: 1px solid #30363d;
    padding: 25px;
    border-radius: 8px;
    margin: 30px 0;
}

.tech-stack ul {
    list-style: none;
    padding-left: 0;
}

.tech-stack li strong {
    color: var(--primary-color);
}

.warning-box {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    padding: 20px;
    border-radius: 8px;
    color: #ffa198;
    font-style: italic;
    margin-top: 30px;
}

/* Donate Section */
.donate-section {
    text-align: center;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #30363d;
}

.donate-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: var(--primary-color);
    color: #ffffff;
    text-decoration: none;
    font-weight: bold;
    border-radius: 6px;
    transition: background 0.2s;
    margin-top: 15px;
}

.donate-btn:hover {
    color:#ffffff!important;
    background-color: #186226;
}

/* ==========================================================
   MEDIA QUERIES (Per Mobile/Schermi stretti)
   ========================================================== */

@media (max-width: 650px) {
    /* Rende il layout a schermo intero su mobile */
    body {
        min-height: 100vh;
        align-items: stretch;
    }
    
    .chat-container {
        width: 100%;
        height: 80vh;
        border-radius: 0;
        margin-top: 0;
        box-shadow: none;
    }

    /* Riduce il padding e le dimensioni del testo per schermi piccoli */
    h2, .chat-container > div:first-child {
        padding: 12px 15px;
        font-size: 1.3em;
    }
    
    #status-alias {
        padding: 0 15px 5px;
    }

    /* Allineamento e spaziatura dell'input */
    #input-area {
        padding: 8px 10px;
    }
    
    .file-label {
        font-size: 1.4em;
        padding: 8px;
    }

    /* Messaggi più larghi per usare lo spazio mobile */
    .message {
        max-width: 90%;
        font-size: 0.95em;
    }

    /* Nasconde temporaneamente lo status o lo comprime in spazi stretti */
    #file-status {
        padding: 5px 15px;
    }
    
    /* Riduce le dimensioni del media */
    .media-container img, .media-container video { 
        max-height: 200px;
    }
    
    #delete-chat-btn {
        padding: 5px 10px;
        font-size: 0.7em;
    }

    .footer-grid {
        flex-direction: column;
        text-align: center;
        align-items: center;
    }
    
    .footer-info {
        text-align: center;
        margin-bottom: 20px;
    }
    
    .footer-actions {
        text-align: center;
        align-items: center;
    }

    .header-nav {
        gap: 12px;
    }
    .nav-link {
        font-size: 0.7rem;
    }
    .logo-text {
        display: none;
    }

    .header-logo-img {
        height: 20px;
    }

    .header-grid {
        justify-content: space-around;
    }

    .chat-title{
        font-size: 18px;
    }

    .feature-grid { grid-template-columns: 1fr; }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .btn-main {
        width: 100%;
        max-width: 300px;
        font-size:0.9rem;
    }

    .about-container {
        padding: 15px;
        border-radius: 8px; /* Arrotondamento meno aggressivo */
    }

    .about-header h1 {
        font-size: 1.4rem; /* Titolo ancora più piccolo per non andare a capo male */
    }

    .about-header .tagline {
        font-size: 0.95rem;
    }

    .about-container h2 {
        font-size: 1.2rem;
        margin-top: 25px;
        padding-left: 10px;
    }

    .feature-card {
        padding: 15px;
    }

    .feature-card h3 {
        font-size: 1rem;
    }

    .tech-stack {
        padding: 15px;
        font-size: 0.9rem;
    }

    .warning-box {
        padding: 15px;
        font-size: 0.85rem;
    }

    .donate-btn {
        width: 100%; /* Il pulsante occupa tutta la larghezza */
        box-sizing: border-box;
    }
}

@keyframes pulse-green {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7); }
    100% { transform: scale(1); box-shadow: 0 0 0 200px rgba(40, 167, 69, 0); }
}

.pulse-animation {
    animation: pulse-green 0.6s ease-out;
    display: inline-block; /* Necessario per permettere il transform scale */
}