/* Reset e Variabili */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Colori Light Theme */
    --primary-color: #2d6df6;
    --primary-dark: #1a56d9;
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-tertiary: #ececf1;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    
    /* Stati */
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    
    /* Spaziature */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Transizioni */
    --transition: all 0.2s ease-in-out;
}

[data-theme="dark"] {
    --primary-color: #3b82f6;
    --primary-dark: #2563eb;
    --bg-primary: #1a1a1a;
    --bg-secondary: #262626;
    --bg-tertiary: #404040;
    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --border-color: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Base Styles */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    transition: var(--transition);
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.logo {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
}

.logo-container h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.new-chat-btn {
    width: 100%;
    padding: 12px 16px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.new-chat-btn:hover {
    background-color: var(--primary-dark);
}

.chat-history {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
}

.chat-history-item {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    margin-bottom: 4px;
    transition: var(--transition);
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-history-item:hover {
    background-color: var(--bg-tertiary);
}

.chat-history-item.active {
    background-color: var(--primary-color);
    color: white;
}

.chat-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: var(--transition);
}

.chat-history-item:hover .chat-actions {
    opacity: 1;
}

.chat-action-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.chat-action-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.sidebar-nav {
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.nav-item:hover, .nav-item.active {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    border-right: 3px solid var(--primary-color);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
}

.username {
    font-size: 14px;
    font-weight: 500;
}

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.settings-btn, .plans-btn, .logout-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.settings-btn:hover, .plans-btn:hover, .logout-btn:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
}

.main-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-primary);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.menu-btn {
    display: none;
    flex-direction: column;
    gap: 4px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.menu-btn span {
    width: 20px;
    height: 2px;
    background-color: var(--text-primary);
    transition: var(--transition);
}

.header-left h2 {
    font-size: 18px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.model-selector select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
}

.theme-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.moon-icon {
    display: none;
}

[data-theme="dark"] .sun-icon {
    display: none;
}

[data-theme="dark"] .moon-icon {
    display: block;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    padding: 0 24px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    scroll-behavior: smooth;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background-color: var(--primary-color);
    color: white;
}

.bot-message .message-avatar {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.bot-message .message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-sm);
    object-fit: cover;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.sender-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.message-text {
    line-height: 1.6;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.user-message .message-text {
    background-color: var(--primary-color);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-lg);
    max-width: 80%;
}

.bot-message .message-text {
    background-color: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
}

.welcome-message .message-text {
    background: none;
    padding: 0;
}

/* Input Area */
.input-container {
    padding: 24px 0;
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

#message-input {
    flex: 1;
    padding: 16px 52px 16px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    resize: none;
    max-height: 120px;
    transition: var(--transition);
}

#message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(45, 109, 246, 0.1);
}

.send-button {
    position: absolute;
    right: 12px;
    bottom: 12px;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.send-button:not(:disabled):hover {
    color: var(--primary-color);
    background-color: var(--bg-tertiary);
}

.send-button:disabled {
    cursor: not-allowed;
}

.send-button:not(:disabled) {
    color: var(--primary-color);
}

.input-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-tertiary);
}

.plan-info {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Settings Content */
.settings-content {
    padding: 24px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.settings-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.settings-card h3 {
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.setting-item input[type="range"] {
    width: 100%;
    margin-bottom: 4px;
}

.setting-item input[type="text"],
.setting-item input[type="email"],
.setting-item select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
}

.setting-item input[type="checkbox"] {
    margin-right: 8px;
}

.setting-description {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.account-info {
    margin-bottom: 20px;
}

.account-info p {
    margin-bottom: 8px;
}

.account-actions {
    display: flex;
    gap: 12px;
}

/* Plans Content */
.plans-content {
    padding: 24px;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
    max-height: calc(200vh - 200px);
    padding: 24px;
}

.current-plan-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 32px;
    border: 1px solid var(--border-color);
}

.current-plan-card h3 {
    margin-bottom: 16px;
    font-size: 18px;
    font-weight: 600;
}

.plan-name {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.plan-features ul {
    list-style: none;
}

.plan-features li {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
}

.plans-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.plan-card {
    background-color: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition);
}

.plan-card.featured {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.plan-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--primary-color);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.plan-header {
    text-align: center;
    margin-bottom: 24px;
}

.plan-header h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.plan-price {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary-color);
}

.plan-price span {
    font-size: 16px;
    color: var(--text-secondary);
}

.plan-features {
    flex: 1;
    margin-bottom: 24px;
}

.plan-card .btn {
    margin-top: auto;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
    font-size: 14px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

.btn-secondary {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-danger {
    background-color: var(--error);
    color: white;
}

.btn-danger:hover {
    background-color: #dc2626;
}

.btn-full {
    width: 100%;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.close-modal:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

/* Payment Modal */
.payment-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}

.payment-modal.show {
    display: flex;
}

.payment-content {
    background-color: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: hidden;
}

.payment-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.payment-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.close-payment {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.close-payment:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.payment-body {
    padding: 24px;
}

.plan-summary {
    text-align: center;
    margin-bottom: 24px;
    padding: 16px;
    background-color: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.plan-summary h4 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.payment-note {
    margin-top: 16px;
    padding: 12px;
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    color: white;
}

.loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .menu-btn {
        display: flex;
    }
    
    .chat-container {
        padding: 0 16px;
    }
    
    .main-header {
        padding: 12px 16px;
    }
    
    .user-message .message-text {
        max-width: 90%;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px;
    }
    
    .settings-content, .plans-content {
        padding: 16px;
    }
    
    .plans-grid {
        grid-template-columns: 1fr;
    }
    
    .plan-card.featured {
        transform: none;
    }
    
    .header-right {
        gap: 8px;
    }
    
    .model-selector select {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Fix per scrollabilità impostazioni */
.settings-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 8px;
}

.modal-body {
    max-height: 60vh;
    overflow-y: auto;
}

/* Scrollbar personalizzata */
.settings-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.settings-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 3px;
}

.settings-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 3px;
}

.settings-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Fix scrollabilità COMPLETA */
.settings-content {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding-right: 8px;
}

.modal-body {
    max-height: 70vh;
    overflow-y: auto;
    padding-right: 8px;
}

.chat-messages {
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

/* Scrollbar personalizzata per tutte le aree scrollabili */
.settings-content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.settings-content::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track,
.chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

.settings-content::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Fix per elementi nascosti */
.setting-item {
    margin-bottom: 20px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

.setting-item:hover {
    background: var(--bg-secondary);
}

/* Miglioramenti responsive */
@media (max-width: 768px) {
    .settings-content {
        max-height: calc(100vh - 150px);
        padding: 10px;
    }
    
    .modal-body {
        max-height: 60vh;
        padding: 15px;
    }
}

/* Assicura che tutti i pulsanti siano cliccabili */
.btn {
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

/* Migliora la visibilità dei form */
.form-group input,
.form-group select,
.form-group textarea {
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    outline: none;
}

/* Stili aggiuntivi per i piani */
.plan-card.featured {
    position: relative;
    border: 2px solid var(--primary-color);
    transform: scale(1.02);
}

.plan-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--primary-color);
    color: white;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1;
}

.payment-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.payment-modal.show {
    display: flex;
}

.payment-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.payment-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.payment-body {
    padding: 20px;
}

.plan-summary {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    text-align: center;
}

.form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.form-row .form-group {
    flex: 1;
}

.payment-note {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 20px;
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 20px 0;
    color: var(--text-tertiary);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-color);
}

.auth-divider span {
    padding: 0 15px;
    font-size: 14px;
}

.oauth-buttons {
    display: flex;
    gap: 12px;
}

.btn-google, .btn-github {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-google:hover {
    background: #4285F4;
    color: white;
    border-color: #4285F4;
}

.btn-github:hover {
    background: #333;
    color: white;
    border-color: #333;
}

.payment-methods {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.payment-method {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 15px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
}

.payment-method.selected {
    border-color: var(--primary-color);
    background: rgba(45, 109, 246, 0.05);
}

.payment-method:hover {
    border-color: var(--primary-color);
}

.payment-method svg {
    color: var(--text-secondary);
}

.payment-method.selected svg {
    color: var(--primary-color);
}

.payment-method span {
    font-size: 14px;
    font-weight: 500;
}

.payment-section {
    display: none;
}

.payment-section.active {
    display: block;
}

.billing-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 20px;
}

.billing-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.billing-tab.active {
    background: var(--primary-color);
    color: white;
}

.plan-saving {
    background: var(--success);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 8px;
}

/* Stili per streaming e typing */
.streaming-message {
    position: relative;
}

.streaming-indicator {
    margin-top: 8px;
    padding: 8px 0;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.streaming-message .streaming-indicator {
    display: block;
}

.message:not(.streaming-message) .streaming-indicator {
    display: none;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-tertiary);
    animation: typing-dot 1.4s ease-in-out infinite both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.typing-dots span:nth-child(3) { animation-delay: 0s; }

@keyframes typing-dot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Migliora l'aspetto dei messaggi in streaming */
.message.streaming-message .message-text {
    min-height: 20px;
    background-color: var(--bg-secondary);
    padding: 12px 16px;
    border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-sm);
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Pulsante stop streaming */
.stop-streaming-btn {
    position: absolute;
    right: 10px;
    bottom: 10px;
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.stop-streaming-btn:hover {
    opacity: 1;
}

/* Stili per configurazione API */
.setting-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.setting-actions .btn {
    flex: 1;
}

/* Responsive improvements */
@media (max-width: 768px) {
    .setting-actions {
        flex-direction: column;
    }
    
    .typing-dots span {
        width: 5px;
        height: 5px;
    }
}

/* style.css - AGGIUNTE PER API MULTIPLE */
.api-config-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.api-url-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    margin-bottom: 12px;
}

.api-url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(45, 109, 246, 0.1);
}

.model-api-group {
    margin-bottom: 16px;
}

.model-api-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 14px;
}

.api-status {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 8px;
}

.api-status.connected {
    background-color: var(--success);
}

.api-status.disconnected {
    background-color: var(--error);
}

.api-status.unknown {
    background-color: var(--warning);
}

.test-api-btn {
    margin-top: 8px;
    padding: 6px 12px;
    font-size: 12px;
}

/* AGGIUNGI AL style.css */
.paypal-container {
    margin: 20px 0;
}

/* Rimuovi gli stili per Stripe */
.payment-methods,
.payment-method,
.payment-section {
    display: none !important;
}

/* AGGIUNGI AL style.css */

/* Gestione Abbonamento */
.subscription-management {
    margin-top: 30px;
}

.subscription-info {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.subscription-info p {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

.subscription-info p strong {
    color: var(--text-primary);
}

.subscription-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Selettore Fatturazione */
.billing-selection {
    margin: 20px 0;
}

.billing-option {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--bg-primary);
}

.billing-option:hover {
    border-color: var(--primary-color);
}

.billing-option input[type="radio"] {
    display: none;
}

.billing-option input[type="radio"]:checked + .checkmark {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.billing-option input[type="radio"]:checked + .checkmark::after {
    content: '';
    display: block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: white;
    margin: 4px;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    margin-right: 12px;
    transition: all 0.3s ease;
}

.billing-info {
    flex: 1;
}

.billing-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.billing-price {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
}

.billing-saving {
    display: block;
    font-size: 12px;
    color: var(--success);
    font-weight: 600;
    margin-top: 2px;
}

/* AGGIUNGI AL style.css */
.subscription-details-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 30px;
    border: 1px solid var(--border-color);
    animation: fadeIn 0.5s ease;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.details-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.cancelled {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.expired {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.detail-value {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-md);
    padding: 15px;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.details-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
    100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

/* Responsive */
@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .details-actions {
        flex-direction: column;
    }
}

/* Aggiungi queste regole al tuo style.css */

/* Avatar preview */
.avatar-preview {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    overflow: hidden;
    border: 3px solid var(--primary-color);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-initials {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    font-size: 32px;
    font-weight: bold;
}

.avatar-section {
    text-align: center;
    margin-bottom: 25px;
}

/* User avatar in sidebar */
.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: white;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Chat info in sidebar */
.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-title {
    display: block;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.chat-model {
    display: block;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 2px;
}

.chat-tokens {
    display: block;
    font-size: 10px;
    color: var(--text-tertiary);
}

/* Message avatar */
.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
    color: white;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    overflow: hidden;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Stats */
.stats-container {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: var(--radius-md);
    margin-top: 15px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.stat-item:last-child {
    border-bottom: none;
}

/* Plan info in chat footer */
.plan-info {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Stili per avatar in chat.html */
.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-email {
    font-size: 11px;
    opacity: 0.7;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.usage-indicator {
    padding: 6px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    font-size: 12px;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.usage-text {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-info-display {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: var(--radius-md);
    margin: 15px 0;
}

.chat-info-display p {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
}

@media (max-width: 768px) {
    .usage-indicator {
        display: none;
    }
    
    .user-email {
        display: none;
    }
    
    .user-details {
        min-width: 0;
    }
    
    .username {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
}