/* Modern & Responsive Chatroom CSS */

:root {
    --chat-bg-dark: #0f172a;
    /* Slate 900 */
    --chat-bg-darker: #020617;
    /* Slate 950 */
    --chat-glass: rgba(15, 23, 42, 0.85);
    --chat-glass-light: rgba(30, 41, 59, 0.7);
    --chat-border: rgba(255, 255, 255, 0.1);

    --chat-primary-500: #a855f7;
    --chat-primary-600: #9333ea;
    --chat-primary-700: #7c3aed;
    --chat-accent-cyan: #22d3ee;

    --chat-text-primary: #f8fafc;
    --chat-text-secondary: #94a3b8;
}

/* Floating Chat Icon - Hidden on Desktop (>=769px) */
#chat-icon {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, var(--chat-primary-600), var(--chat-primary-700));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4);
    cursor: pointer;
    z-index: 1000;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
}

@media (min-width: 769px) {
    #chat-icon {
        display: none !important;
    }
}

#chat-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(124, 58, 237, 0.6);
}

#chat-icon i {
    color: white;
    font-size: 24px;
}

/* Chat Overlay Base */
#chat-overlay {
    position: fixed;
    z-index: 2000;
    display: none;
    flex-direction: column;
    font-family: 'Outfit', 'Inter', sans-serif;
    background: var(--chat-bg-darker);
    overflow: hidden;
}

/* Desktop layout: Right side glass panel */
@media (min-width: 769px) {
    #chat-overlay {
        top: 24px;
        right: 24px;
        bottom: 24px;
        width: 400px;
        height: auto;
        border-radius: 16px;
        border: 1px solid var(--chat-border);
        box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
        /* Replace hard dark with glass */
        background: var(--chat-glass);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
    }
}

/* Mobile layout: Fullscreen */
@media (max-width: 768px) {
    #chat-overlay {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        height: 100dvh;
        border-radius: 0;
        border: none;
    }
}

#chat-header {
    background: rgba(2, 6, 23, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--chat-text-primary);
    border-bottom: 1px solid var(--chat-border);
    flex-shrink: 0;
}

#chat-header .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

#chat-header .avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--chat-primary-500), var(--chat-primary-700));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
}

#my-name {
    font-size: 15px;
}

#close-chat i,
#open-settings i {
    font-size: 20px;
    color: var(--chat-text-secondary);
    transition: color 0.2s;
}

#close-chat:hover i,
#open-settings:hover i {
    color: var(--chat-text-primary);
}

#chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Desktop specific background pattern to match main site */
@media (max-width: 768px) {
    #chat-body {
        background-image:
            linear-gradient(rgba(2, 6, 23, 0.9), rgba(15, 23, 42, 0.95)),
            url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
        background-repeat: repeat;
    }
}

/* Message Bubbles */
.message-bubble {
    max-width: 85%;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 4px;
    animation: messagePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    opacity: 0;
    transform-origin: bottom center;
}

@keyframes messagePop {
    0% {
        opacity: 0;
        transform: translateY(15px) scale(0.95);
    }

    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (max-width: 640px) {
    .message-bubble {
        max-width: 92%;
    }
}

.message-bubble.mine {
    align-self: flex-end;
    flex-direction: row;
}

.message-bubble.others {
    align-self: flex-start;
}

.bubble-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--chat-border);
}

.bubble-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.bubble-avatar.initial {
    font-size: 13px;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, #475569, #334155);
}

.bubble-content {
    padding: 10px 14px;
    color: var(--chat-text-primary);
    position: relative;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.message-bubble.mine .bubble-content {
    background: linear-gradient(135deg, var(--chat-primary-600), var(--chat-primary-700));
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 16px 16px 4px 16px;
}

.message-bubble.others .bubble-content {
    background: var(--chat-glass-light);
    border: 1px solid var(--chat-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px 16px 16px 4px;
}

/* Distinct color for Admin Caem */
.message-bubble.others.admin-bubble .bubble-content {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(217, 119, 6, 0.25));
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.message-bubble.others.admin-bubble .message-text b {
    color: #fbbf24;
}

.message-text {
    margin-bottom: 2px;
}

.message-text b {
    font-weight: 700;
    color: var(--chat-accent-cyan);
}

.message-text i {
    font-style: italic;
    opacity: 0.9;
}

.message-text small {
    font-size: 11px;
    color: var(--chat-text-secondary);
    display: block;
    margin-top: 6px;
    font-weight: 500;
}

.message-time {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    display: block;
    font-weight: 600;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
}

.ticks {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
}

.ticks.blue {
    color: var(--chat-accent-cyan);
}

/* Chat Input Area */
#chat-input-area {
    background: rgba(2, 6, 23, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-top: 1px solid var(--chat-border);
    flex-shrink: 0;
}

#chat-input {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--chat-text-primary);
    outline: none;
    font-size: 14px;
    transition: all 0.2s;
    font-family: inherit;
}

#chat-input:focus {
    border-color: var(--chat-accent-cyan);
    background: rgba(15, 23, 42, 0.9);
}

#chat-input::placeholder {
    color: var(--chat-text-secondary);
}

#send-btn {
    background: linear-gradient(135deg, var(--chat-primary-500), var(--chat-primary-700));
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.3);
    flex-shrink: 0;
}

#send-btn i {
    font-size: 16px;
    margin-left: -2px;
    /* Visual center adjustment */
}

#send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5);
}

#send-btn:active {
    transform: translateY(0);
}

/* Attach Menu */
#attach-menu-container {
    position: relative;
    display: flex;
    align-items: center;
}

#attach-btn {
    background: none;
    border: none;
    color: var(--chat-text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: color 0.2s;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#attach-btn:hover {
    color: var(--chat-text-primary);
}

#attach-options {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 0;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--chat-border);
    border-radius: 16px;
    padding: 8px;
    display: none;
    flex-direction: column;
    gap: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    z-index: 2100;
}

.attach-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
    color: var(--chat-text-primary);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.attach-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.attach-item i {
    width: 20px;
    text-align: center;
    color: var(--chat-primary-400);
}

/* Scrollbar */
#chat-body::-webkit-scrollbar {
    width: 6px;
}

#chat-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

#chat-body::-webkit-scrollbar-track {
    background: transparent;
}

/* Profile Modal (Match main site) */
#profile-modal {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: calc(100% - 32px);
    max-width: 400px;
    z-index: 2500;
    display: none;
    flex-direction: column;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border: 1px solid rgba(168, 85, 247, 0.3);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-radius: 24px;
    overflow: hidden;
}

#profile-modal.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.modal-header {
    background: rgba(2, 6, 23, 0.5);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--chat-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 800;
    background: linear-gradient(90deg, var(--chat-primary-300), var(--chat-accent-cyan));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#close-settings {
    cursor: pointer;
    font-size: 20px;
    color: var(--chat-text-secondary);
    transition: color 0.2s;
}

#close-settings:hover {
    color: #ef4444;
}

.modal-body {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 24px;
}

.setting-group label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 8px;
    color: var(--chat-text-secondary);
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn input {
    flex: 1;
    background: rgba(2, 6, 23, 0.6);
    border: 1px solid var(--chat-border);
    padding: 12px 16px;
    border-radius: 12px;
    color: var(--chat-text-primary);
    outline: none;
    font-size: 14px;
    font-weight: 500;
    transition: border-color 0.2s;
}

.input-with-btn input:focus {
    border-color: var(--chat-primary-500);
}

.input-with-btn button {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    color: var(--chat-text-primary);
    width: 46px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-with-btn button:hover {
    background: rgba(255, 255, 255, 0.1);
}

#avatar-preview-big {
    width: 140px;
    height: 140px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.1), rgba(34, 211, 238, 0.05));
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    box-shadow: 0 8px 32px rgba(124, 58, 237, 0.2);
}

#avatar-preview-big svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.avatar-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.control-item {
    background: rgba(2, 6, 23, 0.4);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid var(--chat-border);
}

.control-item span {
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-text-secondary);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stepper i {
    cursor: pointer;
    font-size: 12px;
    color: var(--chat-text-secondary);
    transition: color 0.2s;
}

.stepper i:hover {
    color: var(--chat-text-primary);
}

.stepper span {
    color: var(--chat-text-primary);
    font-weight: 700;
    min-width: 16px;
    text-align: center;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--chat-primary-600), var(--chat-primary-700));
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    margin-top: 24px;
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.4);
}

.btn-secondary {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--chat-border);
    border-radius: 12px;
    color: var(--chat-text-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 24px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

@media (max-width: 480px) {
    .avatar-controls {
        grid-template-columns: 1fr;
    }
}

/* Mobile specific paddings to maximize space and prevent cutoffs */
@media (max-width: 768px) {
    #chat-header {
        padding: 12px 16px;
    }

    #chat-body {
        padding: 12px;
        gap: 8px;
    }

    #chat-input-area {
        padding: 12px;
        gap: 8px;
    }

    .bubble-content {
        padding: 8px 12px;
    }

    #chat-input {
        padding: 10px 14px;
    }

    .message-bubble {
        max-width: 95%;
    }
}