/* ============================================
   MARIUS TOOL - STYLES
   Grafica coerente con Trading Signals App
   ============================================ */

/* Reset e Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #121212;
    color: #FFFFFF;
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   CHAT CONTAINER
   ============================================ */

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

/* Header */
.chat-header {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 100%;
    gap: 0.5rem;
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Sync Button */
.btn-sync {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
    font-weight: 500;
}

.btn-sync:hover {
    background-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.btn-sync.syncing .sync-icon {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Status Indicator */
.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1rem;
    border-radius: 6px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #2ED573;
    animation: pulse 2s ease-in-out infinite;
}

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

.status-text {
    font-size: 0.9rem;
    color: white;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.chat-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Bottone Toggle Sidebar (mobile) - Integrato nell'header */
.sidebar-toggle {
    display: none; /* Nascosto su desktop */
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    width: 40px;
    height: 40px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 1rem;
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.sidebar-toggle .toggle-icon {
    font-size: 1.5rem;
    line-height: 1;
}

/* ============================================
   SIDEBAR - Lista Utenti
   ============================================ */

.chat-sidebar {
    width: 320px;
    background-color: #1E1E1E;
    border-right: 1px solid #2C2C2C;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 1rem;
    background-color: #252525;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #2C2C2C;
}

/* Bottone chiudi sidebar (mobile) */
.sidebar-close {
    display: none; /* Nascosto su desktop */
    background: transparent;
    border: none;
    color: #FFFFFF;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    line-height: 1;
    transition: color 0.2s ease;
}

.sidebar-close:hover {
    color: #FF6B6B;
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.user-count {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Search */
.sidebar-search {
    padding: 1rem;
    border-bottom: 1px solid #2C2C2C;
}

.sidebar-search input {
    width: 100%;
    background-color: #2C2C2C;
    color: #FFFFFF;
    border: 1px solid #3D3D3D;
    border-radius: 6px;
    padding: 0.75rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.sidebar-search input:focus {
    outline: none;
    border-color: #4A6FEA;
    box-shadow: 0 0 0 2px rgba(74, 111, 234, 0.2);
}

/* Filters */
.sidebar-filters {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    border-bottom: 1px solid #2C2C2C;
    background-color: #252525;
}

.filter-btn {
    width: 100%;
    background-color: #2C2C2C;
    color: #A0A0A0;
    border: 1px solid #3D3D3D;
    border-radius: 6px;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-btn:hover {
    background-color: #36393F;
    color: #FFFFFF;
    transform: translateY(-1px);
}

.filter-btn.active {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    color: white;
    border-color: #4A6FEA;
    font-weight: 600;
}

/* User List */
.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.user-item:hover {
    background-color: #2C2C2C;
}

.user-item.active {
    background-color: #36393F;
    border-left: 3px solid #4A6FEA;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

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

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    font-size: 0.8rem;
    color: #A0A0A0;
}

/* User Badges Container */
.user-badges {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

/* Status Badge */
.status-badge {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-badge.never_contacted {
    background-color: #FFFFFF;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

.status-badge.pending {
    background-color: #FF9F43;
    box-shadow: 0 0 8px rgba(255, 159, 67, 0.5);
}

.status-badge.active {
    background-color: #2ED573;
    box-shadow: 0 0 8px rgba(46, 213, 115, 0.5);
}

.unread-badge {
    background: linear-gradient(135deg, #FF4757 0%, #FF6B81 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.15rem 0.45rem;
    border-radius: 10px;
    flex-shrink: 0;
    min-width: 20px;
    text-align: center;
}

/* Tag Badge */
.tag-badge {
    font-size: 1rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Tag Context Menu */
.tag-context-menu {
    position: fixed;
    background-color: #2C2C2C;
    border: 1px solid #3D3D3D;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    z-index: 10000;
    min-width: 150px;
    animation: menuFadeIn 0.2s ease;
}

@keyframes menuFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.tag-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #E0E0E0;
    font-size: 0.9rem;
}

.tag-menu-item:hover {
    background-color: #36393F;
    color: #FFFFFF;
}

.tag-menu-item span {
    font-size: 1.1rem;
}

/* Loading */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #A0A0A0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border-top-color: #7289DA;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

/* ============================================
   CHAT AREA
   ============================================ */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #1A1A1A;
}

/* Tabs */
.chat-tabs {
    background-color: #1E1E1E;
    border-bottom: 1px solid #2C2C2C;
    display: flex;
    align-items: center;
    position: relative;
    min-height: 50px;
}

.tabs-container {
    display: flex;
    overflow-x: auto;
    scroll-behavior: smooth;
    scrollbar-width: none;
    flex: 1;
    padding: 0 2.5rem;
}

.tabs-container::-webkit-scrollbar {
    display: none;
}

.chat-tab {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: transparent;
    border: none;
    color: #A0A0A0;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    border-bottom: 2px solid transparent;
    position: relative;
}

.chat-tab:hover {
    color: #FFFFFF;
    background-color: rgba(255, 255, 255, 0.05);
}

.chat-tab.active {
    color: #FFFFFF;
    border-bottom-color: #4A6FEA;
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.1);
    font-size: 0.7rem;
    transition: all 0.2s ease;
}

.tab-close:hover {
    background-color: #FF4757;
}

.tab-scroll {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 100%;
    background: linear-gradient(to right, #1E1E1E, transparent);
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 10;
}

.tab-scroll-left {
    left: 0;
}

.tab-scroll-right {
    right: 0;
    background: linear-gradient(to left, #1E1E1E, transparent);
}

/* Chat Content */
.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #A0A0A0;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-empty h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    color: #FFFFFF;
}

.chat-empty p {
    font-size: 1rem;
}

/* Conversations Container */
.conversations-container {
    display: none;
    flex-direction: column;
    height: 100%;
}

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

.conversation-view {
    display: none;
    flex-direction: column;
    height: 100%;
}

.conversation-view.active {
    display: flex;
}

/* Conversation Header */
.conversation-header {
    padding: 1rem 1.5rem;
    background-color: #252525;
    border-bottom: 1px solid #2C2C2C;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.conversation-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.conversation-info {
    flex: 1;
}

.conversation-name {
    font-weight: 600;
    font-size: 1.1rem;
}

.conversation-status {
    font-size: 0.85rem;
    color: #A0A0A0;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Date Separator */
.date-separator {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1rem 0;
    width: 100%;
}

.date-separator-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, #3D3D3D, transparent);
}

.date-separator-text {
    color: #A0A0A0;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: capitalize;
    padding: 0.25rem 0.75rem;
    background-color: #252525;
    border-radius: 12px;
    white-space: nowrap;
}

.message {
    display: flex;
    gap: 0.75rem;
    max-width: 70%;
    animation: fadeIn 0.3s ease;
}

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

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

.message.user {
    align-self: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.message-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-bubble {
    background-color: #2C2C2C;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.smm .message-bubble {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
}

.message-time {
    font-size: 0.75rem;
    color: #A0A0A0;
    padding: 0 0.5rem;
}

/* Message Input */
.message-input-container {
    padding: 1rem 1.5rem;
    background-color: #1E1E1E;
    border-top: 1px solid #2C2C2C;
}

.message-input-wrapper {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    background-color: #2C2C2C;
    color: #FFFFFF;
    border: 1px solid #3D3D3D;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    resize: none;
    max-height: 120px;
    font-family: 'Poppins', sans-serif;
    transition: all 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: #4A6FEA;
    box-shadow: 0 0 0 2px rgba(74, 111, 234, 0.2);
}

.btn-send {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.btn-send:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(74, 111, 234, 0.3);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: #2C2C2C;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    animation: modalFadeIn 0.3s ease-out;
}

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

.modal-header {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    color: white;
    padding: 1rem;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body {
    padding: 1.5rem;
    color: #E0E0E0;
}

.modal-footer {
    padding: 1rem;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-button {
    background: linear-gradient(135deg, #4A6FEA 0%, #7C3AED 100%);
    color: white;
    border: none;
    padding: 0.5rem 2rem;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Poppins', sans-serif;
}

.modal-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(74, 111, 234, 0.3);
}

/* ============================================
   LOADING OVERLAY (per sincronizzazione)
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: linear-gradient(135deg, #1E1E1E 0%, #2C2C2C 100%);
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(74, 111, 234, 0.2);
    border-radius: 50%;
    border-top-color: #4A6FEA;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}

.loading-text {
    color: #FFFFFF;
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.loading-subtext {
    color: #A0A0A0;
    font-size: 0.9rem;
}

/* Progress bar */
.loading-progress {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    margin-top: 1rem;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4A6FEA 0%, #7C3AED 100%);
    width: 0%;
    animation: progressIndeterminate 1.5s ease-in-out infinite;
}

@keyframes progressIndeterminate {
    0% {
        width: 0%;
        margin-left: 0%;
    }
    50% {
        width: 70%;
        margin-left: 15%;
    }
    100% {
        width: 0%;
        margin-left: 100%;
    }
}

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

@media (max-width: 1024px) {
    .chat-sidebar {
        width: 280px;
    }

    .message {
        max-width: 80%;
    }
}

@media (max-width: 768px) {
    .chat-header {
        padding: 0.8rem 1rem;
    }

    .chat-header h1 {
        font-size: 1.2rem;
    }

    .header-actions {
        gap: 0.5rem;
    }

    .btn-sync .sync-text {
        display: none;
    }

    /* Filtri più compatti su mobile */
    .sidebar-filters {
        padding: 0.5rem;
        gap: 0.4rem;
    }

    .filter-btn {
        min-width: 60px;
        padding: 0.4rem 0.5rem;
        font-size: 0.7rem;
    }

    /* Sidebar diventa un overlay su mobile */
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%); /* Nascosta di default */
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);
    }

    /* Sidebar visibile quando ha la classe 'active' */
    .chat-sidebar.active {
        transform: translateX(0);
    }

    /* Mostra bottone toggle su mobile */
    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Mostra bottone chiudi sidebar su mobile */
    .sidebar-close {
        display: block;
    }

    /* Chat area occupa tutto lo spazio su mobile */
    .chat-area {
        width: 100%;
    }

    .message {
        max-width: 90%;
    }

    /* Tabs più compatti su mobile */
    .chat-tab {
        padding: 0.5rem 0.8rem;
        font-size: 0.85rem;
    }

    .chat-tab .close-tab {
        font-size: 1rem;
        margin-left: 0.3rem;
    }

    /* Input messaggio più compatto */
    .message-input-container {
        padding: 0.8rem;
    }

    .message-input {
        font-size: 0.9rem;
    }

    .send-button {
        width: 45px;
        height: 45px;
    }
}

/* Overlay scuro quando sidebar è aperta su mobile */
@media (max-width: 768px) {
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

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

::-webkit-scrollbar-track {
    background: #1E1E1E;
}

::-webkit-scrollbar-thumb {
    background: #3D3D3D;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4A6FEA;
}
