/* Devsviluppo Teams - Stili principali */
/* by Devsviluppo */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #6264A7;
    --secondary-color: #464775;
    --success-color: #92C353;
    --danger-color: #C4314B;
    --warning-color: #F3B700;
    --bg-color: #F3F2F1;
    --chat-bg: #FFFFFF;
    --sidebar-bg: #F3F2F1;
    --header-bg: #FFFFFF;
    --text-primary: #242424;
    --text-secondary: #616161;
    --border-color: #E1DFDD;
    --online-color: #92C353;
    --busy-color: #C4314B;
    --away-color: #F3B700;
    --offline-color: #8A8886;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
}

/* Auth Screen */
#auth-screen {
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

.auth-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    min-width: 400px;
}

.logo h1 {
    color: var(--primary-color);
    margin-bottom: 10px;
    text-align: center;
}

.logo p {
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 30px;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

.auth-form input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
}

.auth-form button {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.auth-form button:hover {
    background: var(--secondary-color);
}

.switch-auth {
    text-align: center;
    margin-top: 20px;
    color: var(--text-secondary);
}

.switch-auth a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
}

.credits {
    text-align: center;
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Main Screen Layout */
#main-screen {
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.user-profile {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--header-bg);
}

.user-profile img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
}

.user-info {
    flex: 1;
}

#user-displayname {
    font-weight: 600;
    margin-bottom: 4px;
}

.status-selector select {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 12px;
    background: white;
    cursor: pointer;
}

.search-bar {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
}

.search-bar input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
}

.search-results {
    position: absolute;
    top: 60px;
    left: 15px;
    right: 15px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
}

.search-result-item:hover {
    background: var(--bg-color);
}

.search-result-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.search-result-item button {
    margin-left: auto;
    padding: 6px 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.tab {
    flex: 1;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.badge {
    background: var(--danger-color);
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    margin-left: 5px;
}

.list-container {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.list-container.active {
    display: flex;
}

.list-header {
    padding: 15px;
    font-weight: 600;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.list-content {
    flex: 1;
    overflow-y: auto;
}

.friend-item, .chat-item, .request-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.2s;
}

.friend-item:hover, .chat-item:hover {
    background: #EDEBE9;
}

.friend-item.selected, .chat-item.selected {
    background: #E1DFDD;
}

.friend-item img, .chat-item img, .request-item img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    position: relative;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    right: 0;
    border: 2px solid white;
}

.status-indicator.online { background: var(--online-color); }
.status-indicator.busy { background: var(--busy-color); }
.status-indicator.away { background: var(--away-color); }
.status-indicator.offline { background: var(--offline-color); }

.friend-info, .chat-info, .request-info {
    flex: 1;
    overflow: hidden;
}

.friend-name, .chat-name, .request-name {
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.friend-status, .chat-last-message {
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.unread-badge {
    background: var(--primary-color);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.request-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-icon:hover {
    background: var(--border-color);
    border-radius: 4px;
}

.btn-accept, .btn-reject {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

.btn-accept {
    background: var(--success-color);
    color: white;
}

.btn-reject {
    background: var(--danger-color);
    color: white;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    position: relative;
}

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.empty-state h2 {
    margin-bottom: 10px;
}

.chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--header-bg);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-header-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

#chat-name {
    font-weight: 600;
    font-size: 16px;
}

.chat-status {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-header-actions {
    display: flex;
    gap: 10px;
}

.btn-call {
    padding: 10px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

.btn-call:hover {
    background: var(--secondary-color);
}

.messages-container {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    gap: 10px;
    max-width: 70%;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
}

.message-content {
    background: var(--bg-color);
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 100%;
}

.message.own .message-content {
    background: var(--primary-color);
    color: white;
}

.message-sender {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.message.own .message-sender {
    display: none;
}

.message-text {
    word-wrap: break-word;
}

.message-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(0,0,0,0.05);
    border-radius: 6px;
    margin-top: 5px;
}

.message-file a {
    color: var(--primary-color);
    text-decoration: none;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.message.own .message-time {
    color: rgba(255,255,255,0.7);
}

.chat-input-container {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--header-bg);
}

.btn-attach {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
}

#message-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
}

.btn-send {
    padding: 10px 20px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
}

.btn-send:hover {
    background: var(--secondary-color);
}

/* Call Area */
.call-area {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1A1A1D;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.call-header {
    padding: 20px;
    background: rgba(0,0,0,0.5);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.call-info h3 {
    margin-bottom: 5px;
}

#call-duration {
    font-size: 14px;
    opacity: 0.8;
}

.call-actions {
    display: flex;
    gap: 10px;
}

.btn-call-action {
    padding: 12px 20px;
    background: rgba(255,255,255,0.2);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.btn-call-action:hover {
    background: rgba(255,255,255,0.3);
}

.btn-call-action.active {
    background: var(--primary-color);
}

.btn-call-action.danger {
    background: var(--danger-color);
}

.btn-call-action.danger:hover {
    background: #9D1F3A;
}

.call-videos {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 10px;
    padding: 20px;
    overflow-y: auto;
}

.video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 16/9;
}

.video-container video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-label {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 12px;
}

.video-container.screen-share {
    grid-column: 1 / -1;
}

.incoming-call {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.incoming-call-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    min-width: 300px;
}

.incoming-call-content h3 {
    margin-bottom: 10px;
    font-size: 24px;
}

.incoming-call-content p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.incoming-call-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.incoming-call-actions button {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    align-items: center;
    justify-content: center;
    z-index: 1500;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    min-width: 400px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-bottom: 20px;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 15px;
}

.group-members-select {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    margin-bottom: 15px;
}

.member-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    cursor: pointer;
}

.member-checkbox:hover {
    background: var(--bg-color);
}

.member-checkbox input {
    cursor: pointer;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.modal-actions button:first-child {
    background: var(--primary-color);
    color: white;
}

.modal-actions button:last-child {
    background: var(--border-color);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #C8C6C4;
}

/* Typing indicator */
.typing-indicator {
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
}
.incoming-call { position: fixed !important; top: 50% !important; left: 50% !important; transform: translate(-50%, -50%) !important; z-index: 10000 !important; }

/* ==================== RESPONSIVE MOBILE ==================== */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 300px;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100% !important;
        height: 50vh;
        border-right: none;
        border-bottom: 1px solid #e1e8ed;
    }
    
    .main-content {
        width: 100% !important;
        height: 50vh;
    }
    
    .chat-header {
        padding: 10px;
        font-size: 14px;
    }
    
    .chat-header h2 {
        font-size: 16px;
    }
    
    .message-input-container {
        padding: 10px;
    }
    
    #message-input {
        font-size: 14px;
    }
    
    /* Chiamate fullscreen su mobile */
    #call-container {
        width: 100vw !important;
        height: 100vh !important;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0 !important;
    }
    
    .call-controls {
        padding: 15px 10px;
    }
    
    .btn-call-action {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    /* Video layout mobile */
    #local-video {
        width: 120px !important;
        height: 160px !important;
        bottom: 80px;
        right: 10px;
    }
    
    .remote-videos {
        flex-direction: column;
    }
    
    .remote-video {
        width: 100% !important;
        height: 100% !important;
    }
    
    /* Popup chiamata mobile */
    .incoming-call {
        width: 90% !important;
        max-width: 350px;
    }
    
    .incoming-call-content {
        padding: 20px;
    }
    
    .incoming-call-actions button {
        padding: 12px 20px;
        font-size: 14px;
    }
}

/* Mobile piccolo */
@media (max-width: 480px) {
    .chat-header h2 {
        font-size: 14px;
    }
    
    .message {
        max-width: 85%;
        font-size: 14px;
    }
    
    .btn-call-action {
        width: 45px;
        height: 45px;
        font-size: 18px;
        margin: 0 3px;
    }
    
    #local-video {
        width: 100px !important;
        height: 140px !important;
    }
    
    .tab-btn {
        font-size: 12px;
        padding: 8px 12px;
    }
}

/* ==================== UI/UX IMPROVEMENTS ==================== */

/* Animazioni smooth */
* {
    transition: all 0.2s ease;
}

/* Bottoni più belli */
button {
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(0);
}

/* Lista amici hover */
.friend-item:hover,
.conversation-item:hover {
    background: #f5f8fa;
    transform: translateX(5px);
}

.friend-item.active,
.conversation-item.active {
    background: #e8f4f8;
    border-left: 3px solid #1da1f2;
}

/* Messaggi con animazione */
.message {
    animation: slideIn 0.3s ease;
}

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

/* Status indicator animato */
.friend-status.online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #17bf63;
    border-radius: 50%;
    margin-right: 5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Badge notifiche */
.unread-badge {
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* Call controls hover effects */
.btn-call-action:hover {
    transform: scale(1.1);
}

.btn-call-action.danger:hover {
    background: #dc3545;
    transform: scale(1.15);
}

/* Incoming call pulse */
.incoming-call {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* Loading spinner */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1da1f2;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ==================== PROFILO UTENTE ==================== */

.user-profile {
    transition: background 0.2s;
}

.user-profile:hover {
    background: rgba(255,255,255,0.05);
}

#user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #1da1f2;
}

/* Modal profilo */
#profile-modal .modal-content {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Responsive profilo */
@media (max-width: 768px) {
    #profile-modal .modal-content {
        width: 95% !important;
        max-width: 95% !important;
        margin: 20px auto;
    }
    
    #profile-modal .modal-body {
        padding: 20px !important;
    }
}

/* Bottone elimina chat */
.btn-delete-chat {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    opacity: 0.6;
}

.btn-delete-chat:hover {
    background: #ff4444;
    opacity: 1;
    transform: scale(1.1);
}
