/* Chat Screen */
.chat-screen {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Chat Section */
.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-top: 125px;
    margin-bottom: 80px;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #d4af37;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 8px;
}

.chat-messages {
    flex: 1;
    padding: 15px 10px 20px 10px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.message-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
    width: 100%;
}

.message-wrapper.sent {
    justify-content: flex-end;
}

.message-wrapper.received {
    justify-content: flex-start;
}

.message {
    max-width: 75%;
    min-width: 150px;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-sizing: border-box;
    width: fit-content;
}

.message > div {
    min-width: 100px;
}

.message.usuario {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    align-self: flex-start;
    margin-right: auto;
}

.message.agente {
    background: linear-gradient(135deg, #d4af37 0%, #00cc6a 100%);
    color: #000;
    align-self: flex-end;
    margin-left: auto;
}

.message img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message img:hover {
    transform: scale(1.05);
}

/* Links clickeables en el chat */
.chat-link {
    color: #4fc3f7;
    text-decoration: underline;
    word-break: break-all;
}

.chat-link:hover {
    color: #81d4fa;
    text-decoration: none;
}

.message.agente .chat-link {
    color: #b3e5fc;
}

.message.agente .chat-link:hover {
    color: #e1f5fe;
}

/* Lightbox para imágenes */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 10000;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.lightbox.active {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 10px;
    cursor: default;
}

.lightbox-close {
    position: absolute;
    top: max(20px, env(safe-area-inset-top, 20px));
    right: 30px;
    font-size: 40px;
    color: #fff;
    cursor: pointer;
    background: none;
    border: none;
    z-index: 10001;
}

.lightbox-close:hover {
    color: #ff4444;
}

.message-time {
    font-size: 0.75em;
    opacity: 0.7;
    margin-top: 5px;
    display: block;
}

.copy-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.message-wrapper:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: #d4af37;
    transform: scale(1.1);
}

/* Chat Input */
.chat-input-container {
    padding: 8px 15px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    border-top: 1px solid #d4af37;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #0f0f0f 0%, #1a1a1a 100%);
    z-index: 999;
}

.chat-input {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    width: 45px;
    height: 45px;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.deposit-btn {
    background: linear-gradient(135deg, #00ff88 0%, #00cc6a 100%);
    color: #000;
}

.deposit-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.withdraw-btn {
    background: linear-gradient(135deg, #ff4444 0%, #cc0000 100%);
    color: #fff;
}

.withdraw-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 68, 68, 0.5);
}

.attach-btn {
    background: linear-gradient(135deg, #d4af37 0%, #ffd700 100%);
    color: #000;
}

.attach-btn:hover {
    transform: scale(1.1);
}

.cbu-chat-btn {
    background: linear-gradient(135deg, #9d4edd 0%, #6603a8 100%);
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    width: auto;
    padding: 0 12px;
    border-radius: 20px;
}

.cbu-chat-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(157, 78, 221, 0.5);
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #d4af37;
    border-radius: 25px;
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    font-size: 14px;
    resize: none;
    min-height: 45px;
    max-height: 100px;
    font-family: inherit;
}

#messageInput:focus {
    outline: none;
    border-color: #ffd700;
}

.send-btn {
    background: linear-gradient(135deg, #d4af37 0%, #5d8d76 100%);
    color: #000;
    border: none;
    padding: 12px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 255, 136, 0.4);
}

.chat-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
    margin: 8px 0;
}

.chat-date-separator span {
    background: rgba(212, 175, 55, 0.15);
    color: #d4af37;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: 20px;
    text-transform: capitalize;
    letter-spacing: 0.5px;
    border: 1px solid rgba(212, 175, 55, 0.25);
}
