/* public/css/anonimo.css */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

/* ========== NICKNAME SCREEN ========== */

#nickname-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.welcome-container {
    width: 100%;
    max-width: 500px;
}

.logo {
    text-align: center;
    color: white;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.logo-icon {
    width: 70px;
    height: 70px;
}

.logo-text {
    height: 40px;
    width: auto;
}

.logo p {
    font-size: 18px;
    opacity: 0.9;
}

/* Header logo (chat screen) */
.header-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo-icon {
    width: 35px;
    height: 35px;
}

.header-logo-text {
    height: 25px;
    width: auto;
}

.welcome-card {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.welcome-card h2 {
    color: #333;
    margin-bottom: 10px;
}

.welcome-card > p {
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: #999;
    font-size: 13px;
}

.privacy-info {
    background: #f0f4ff;
    border-left: 4px solid #667eea;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.privacy-info p {
    color: #667eea;
    font-weight: 600;
    margin-bottom: 10px;
}

.privacy-info ul {
    list-style: none;
    padding-left: 0;
}

.privacy-info li {
    color: #666;
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
}

.privacy-info li:before {
    content: ">";
    position: absolute;
    left: 0;
    color: #667eea;
    font-weight: bold;
}

.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* ========== PARI INFO CARD ========== */

.pari-info-card {
    background: linear-gradient(135deg, #f8f9ff 0%, #e8ecff 100%);
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 25px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pari-info-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.pari-foto {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
    box-shadow: 0 4px 10px rgba(102, 126, 234, 0.3);
}

.pari-reparto-name {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.pari-argomenti {
    background: white;
    border-radius: 8px;
    padding: 12px 15px;
}

.pari-argomenti strong {
    color: #667eea;
    font-size: 14px;
    display: block;
    margin-bottom: 5px;
}

.pari-argomenti p {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    margin: 0;
}

/* ========== CHAT SCREEN ========== */

#chat-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.chat-container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    width: 100%;
    max-width: 800px;
    height: 600px;
    display: flex;
    flex-direction: column;
}

/* Header */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 15px 15px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.header-left h2 {
    margin-bottom: 5px;
}

.status {
    font-size: 14px;
    opacity: 0.9;
}

.btn-danger {
    padding: 10px 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: 2px solid white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-danger:hover {
    background: rgba(255,255,255,0.3);
}

/* Messaggi */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #fafbfc;
}

.waiting-message {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.waiting-message .small {
    font-size: 13px;
    margin-top: 5px;
}

/* Singolo messaggio */
.message {
    margin-bottom: 15px;
    display: flex;
    gap: 10px;
}

.message.anonimo {
    justify-content: flex-end;
}

.message.pari {
    justify-content: flex-start;
}

.message.mentore {
    justify-content: flex-start;
}

.message.sistema {
    justify-content: center;
}

.message-bubble {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message.anonimo .message-bubble {
    background: #667eea;
    color: white;
}

.message.pari .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
}

.message.mentore .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
}

.message.sistema .message-bubble {
    background: #f0f4ff;
    color: #667eea;
    font-style: italic;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 5px;
}

/* Input area */
.input-area {
    background: white;
    padding: 15px 20px;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 15px 15px;
}

.typing-indicator {
    padding: 5px 10px;
    color: #667eea;
    font-size: 13px;
    font-style: italic;
}

/* UPLOAD PREVIEW */
.upload-preview {
    background: #f0f4ff;
    border: 2px dashed #667eea;
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 10px;
}

.preview-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.preview-name {
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.preview-cancel {
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
}

.preview-cancel:hover {
    background: #cc0000;
}

.upload-progress {
    margin-top: 8px;
    background: #e0e0e0;
    border-radius: 4px;
    height: 6px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    align-items: flex-end;
}

.btn-attach {
    padding: 12px;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-attach:hover {
    background: #e8e8e8;
    border-color: #667eea;
}

.btn-attach:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    /* Auto-resize: inizia con 1 riga, espande fino a ~7 righe */
    min-height: 44px;  /* ~1 riga + padding */
    max-height: 168px; /* ~7 righe (7 * 21px line-height) + padding */
    overflow-y: hidden; /* Nascosto inizialmente, JS lo cambia in 'auto' quando necessario */
    transition: height 0.1s ease;
}

#message-input:focus {
    outline: none;
    border-color: #667eea;
}

#message-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

.btn-send {
    padding: 12px 20px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 20px;
    transition: background 0.3s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: #5568d3;
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.char-counter {
    text-align: right;
    font-size: 12px;
    color: #999;
}

/* FILE MESSAGE STYLES */
.file-message {
    margin: 5px 0;
}

.file-image img {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
}

.file-video video {
    max-width: 100%;
    max-height: 250px;
    border-radius: 8px;
    display: block;
}

.file-info {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 5px;
    word-break: break-all;
}

.file-document .file-download {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
}

.file-document .file-download:hover {
    background: rgba(255,255,255,0.3);
}

.message.pari .file-download,
.message.mentore .file-download {
    background: rgba(0,0,0,0.05);
}

.message.pari .file-download:hover,
.message.mentore .file-download:hover {
    background: rgba(0,0,0,0.1);
}

.file-icon {
    font-size: 28px;
}

.file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.file-name {
    font-weight: 600;
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    opacity: 0.8;
}

/* Scrollbar */
.messages-area::-webkit-scrollbar {
    width: 8px;
}

.messages-area::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.messages-area::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.messages-area::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ==================== RESPONSIVE DESIGN ==================== */

/* Tablets (768px and below) */
@media (max-width: 768px) {
    .logo h1 {
        font-size: 36px;
    }

    .logo p {
        font-size: 16px;
    }

    .welcome-card {
        padding: 30px 25px;
    }

    .pari-foto {
        width: 60px;
        height: 60px;
    }

    .pari-reparto-name {
        font-size: 18px;
    }

    .chat-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
        padding: 15px;
    }

    .header-left h2 {
        font-size: 20px;
    }

    .input-area {
        border-radius: 0;
        padding: 12px 15px;
    }

    .message-bubble {
        max-width: 80%;
    }

    .file-image img {
        max-height: 200px;
    }

    .file-video video {
        max-height: 200px;
    }
}

/* Mobile (576px and below) */
@media (max-width: 576px) {
    #nickname-screen {
        padding: 15px;
    }

    .logo h1 {
        font-size: 32px;
    }

    .logo p {
        font-size: 14px;
    }

    .welcome-card {
        padding: 25px 20px;
        border-radius: 12px;
    }

    .welcome-card h2 {
        font-size: 22px;
    }

    .form-group input,
    .form-group select {
        padding: 10px;
        font-size: 14px;
    }

    .pari-info-card {
        padding: 15px;
    }

    .pari-info-header {
        gap: 12px;
    }

    .pari-foto {
        width: 50px;
        height: 50px;
    }

    .pari-reparto-name {
        font-size: 16px;
    }

    .pari-argomenti {
        padding: 10px 12px;
    }

    .btn-primary {
        padding: 12px;
        font-size: 15px;
    }

    #chat-screen {
        padding: 0;
    }

    .chat-header {
        padding: 12px 15px;
    }

    .header-left h2 {
        font-size: 18px;
    }

    .status {
        font-size: 12px;
    }

    .btn-danger {
        padding: 8px 12px;
        font-size: 13px;
    }

    .messages-area {
        padding: 15px;
    }

    .message-bubble {
        max-width: 85%;
        padding: 10px 12px;
    }

    .input-area {
        padding: 10px 12px;
    }

    .input-wrapper {
        gap: 8px;
    }

    .btn-attach {
        padding: 10px;
        font-size: 16px;
    }

    #message-input {
        padding: 10px;
        font-size: 14px;
        min-height: 42px;
        max-height: 150px; /* Leggermente ridotto per mobile */
    }

    .btn-send {
        padding: 10px 15px;
        font-size: 18px;
    }

    .file-document .file-download {
        padding: 10px;
    }

    .file-icon {
        font-size: 24px;
    }

    .file-name {
        font-size: 13px;
    }

    .file-size {
        font-size: 11px;
    }
}

/* Very small screens (400px and below) */
@media (max-width: 400px) {
    .logo h1 {
        font-size: 28px;
    }

    .welcome-card {
        padding: 20px 15px;
    }

    .chat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .btn-danger {
        width: 100%;
        text-align: center;
    }

    .message-bubble {
        max-width: 90%;
    }

    .input-wrapper {
        gap: 5px;
    }

    .btn-attach {
        padding: 8px;
    }

    #message-input {
        padding: 8px;
        font-size: 13px;
        min-height: 38px;
        max-height: 130px; /* Ridotto per schermi piccoli */
    }

    .btn-send {
        padding: 8px 12px;
    }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #nickname-screen {
        padding: 10px;
        align-items: flex-start;
    }

    .logo {
        margin-bottom: 15px;
    }

    .logo h1 {
        font-size: 28px;
    }

    .welcome-card {
        padding: 20px;
    }

    .chat-container {
        height: 100vh;
    }

    .chat-header {
        padding: 10px 15px;
    }

    .messages-area {
        padding: 10px;
    }

    .input-area {
        padding: 8px 12px;
    }

    .upload-preview {
        padding: 8px 12px;
    }
}

/* Safe area for notched devices */
@supports(padding: max(0px)) {
    .chat-header {
        padding-top: max(15px, env(safe-area-inset-top));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }

    .input-area {
        padding-bottom: max(15px, env(safe-area-inset-bottom));
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
}

/* ========== BANNED SCREEN ========== */

.banned-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.banned-container {
    background: white;
    border-radius: 15px;
    padding: 50px 40px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    max-width: 500px;
    width: 100%;
    text-align: center;
}

.banned-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.banned-title {
    color: #c33;
    font-size: 32px;
    margin-bottom: 15px;
}

.banned-message {
    color: #333;
    font-size: 18px;
    margin-bottom: 10px;
}

.banned-explanation {
    color: #666;
    font-size: 16px;
    margin-bottom: 30px;
}

.banned-contacts {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    text-align: left;
}

.banned-contacts h3 {
    color: #333;
    font-size: 18px;
    margin-bottom: 15px;
    text-align: center;
}

.mentor-contacts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mentor-contact {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: white;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.mentor-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.mentor-email {
    color: #667eea;
    text-decoration: none;
    font-size: 14px;
}

.mentor-email:hover {
    text-decoration: underline;
}

/* Banned screen responsive */
@media (max-width: 576px) {
    .banned-container {
        padding: 30px 20px;
    }

    .banned-icon {
        font-size: 60px;
    }

    .banned-title {
        font-size: 24px;
    }

    .banned-message {
        font-size: 16px;
    }

    .banned-explanation {
        font-size: 14px;
    }

    .banned-contacts {
        padding: 15px;
    }

    .banned-contacts h3 {
        font-size: 16px;
    }
}

/* ========== NOTIFICATION SYSTEM ========== */

.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.notification {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    pointer-events: auto;
    animation: notificationSlideIn 0.3s ease-out;
    border-left: 4px solid #667eea;
}

.notification.hiding {
    animation: notificationSlideOut 0.3s ease-in forwards;
}

.notification.error {
    border-left-color: #e74c3c;
}

.notification.success {
    border-left-color: #27ae60;
}

.notification.warning {
    border-left-color: #f39c12;
}

.notification.info {
    border-left-color: #667eea;
}

@keyframes notificationSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes notificationSlideOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.notification-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
    font-size: 14px;
}

.notification-message {
    color: #666;
    font-size: 13px;
    line-height: 1.4;
}

.notification-close {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.2s;
}

.notification-close:hover {
    color: #333;
}

/* ========== CONFIRMATION MODAL ========== */

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-content {
    position: relative;
    background: white;
    border-radius: 16px;
    padding: 30px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: confirmSlideIn 0.3s ease-out;
}

@keyframes confirmSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.confirm-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.confirm-title {
    color: #333;
    font-size: 20px;
    margin-bottom: 10px;
}

.confirm-message {
    color: #666;
    font-size: 15px;
    line-height: 1.5;
    margin-bottom: 25px;
}

.confirm-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn {
    padding: 12px 28px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.confirm-btn-cancel {
    background: #f0f0f0;
    color: #666;
}

.confirm-btn-cancel:hover {
    background: #e0e0e0;
}

.confirm-btn-ok {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.confirm-btn-ok:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.confirm-btn-ok.danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
}

.confirm-btn-ok.danger:hover {
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

/* Notification responsive */
@media (max-width: 576px) {
    .notification-container {
        top: 10px;
        right: 10px;
        left: 10px;
    }

    .notification {
        min-width: unset;
        max-width: unset;
        width: 100%;
    }

    .confirm-content {
        padding: 25px 20px;
    }

    .confirm-actions {
        flex-direction: column;
    }

    .confirm-btn {
        width: 100%;
    }
}
