:root {
            --animation-start-x: 0;
            --animation-start-y: 0;
        }

        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
        }

        body {
            background-color: #f6f8fc;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 90vh;
            width: 100%;
            overflow: hidden;
        }

        .gallery-container {
            width: 100%;
            height: 100%;
            position: absolute;
            background-color: #333333f5;
            display: block;
            overflow: scroll;
            text-align: center;
            visibility: hidden;
            z-index: 100000;
            animation-name: hide-gallery;
            animation-duration: 0.5s;
        }

        @keyframes hide-gallery {
            from {
                translate: 0 0;
                scale: 100% 100%;
                opacity: 100%;
                visibility: visible;
            }

            to {
                translate: var(--animation-start-x) var(--animation-start-y);
                scale: 10% 10%;
                opacity: 0%;
                visibility: hidden;
            }
        }

        .gallery-container.visible {
            transform: translateY(0);
            visibility: visible;
            animation-duration: 0.5s;
            animation-name: show-gallery;
        }

        @keyframes show-gallery {
            from {
                translate: var(--animation-start-x) var(--animation-start-y);
                scale: 10% 10%;
                opacity: 0%;
            }

            to {
                translate: 0 0;
                scale: 100% 100%;
                opacity: 100%;
                
            }
        }

        .gallery-container img {
            position: absolute;
            left: 50%;
            top: 50%;
            margin: auto;
            display: block;
            max-width: 80%;
            max-height: 80%;
            translate: -50% -50%;
            box-shadow: 3px 3px 30px #dddddd;
            border: 2px solid rgba(255, 255, 255, 0.5);
            border-radius: 5%;
        }

        .gallery-image:hover {
            cursor:pointer;
        }

        .gallery-caption {
            position: absolute;
            left: 50%;
            translate: -50% 0;
            bottom: 5%;
            margin-top: 20px;
            display: none;
        }

        .gallery-caption.visible {
            display: block;
        }

        .gallery-caption span {
            font-size: 15px;
            color: white;
            text-shadow: 1px 1px 3px #121212;
        }

        .gallery-splash {
            position: absolute;
            left: 50%;
            translate: -50% 0;
            bottom: 5%;
            margin-top: 20px;
        }

        .gallery-splash span {
            display: inline-block;
            font-size: 25px;
            color: white;
            text-shadow: 2px 2px 6px #121212;
            animation: wave 2s ease-in-out infinite;
        }

        .gallery-splash span:nth-child(1) {
            animation-delay: 0ms;
        }

        .gallery-splash span:nth-child(2) {
            animation-delay: 0.1s;
        }

        .gallery-splash span:nth-child(3) {
            animation-delay: 0.2s;
        }

        .gallery-splash span:nth-child(4) {
            animation-delay: 0.3s;
        }

        .gallery-splash span:nth-child(5) {
            animation-delay: 0.4s;
        }

        .gallery-splash span:nth-child(6) {
            animation-delay: 0.5s;
        }

        .gallery-splash span:nth-child(7) {
            animation-delay: 0.6s;
        }

        .gallery-splash span:nth-child(8) {
            animation-delay: 0.7s;
        }

        .gallery-splash span:nth-child(9) {
            animation-delay: 0.8s;
        }

        .gallery-splash span:nth-child(10) {
            animation-delay: 0.9s;
        }

        @keyframes wave {
            0%, 100% {
                transform: translateY(0);
            }    
            50% {
                transform: translateY(-10px);
            }
        }

        .chat-container {
            width: 100%;
            max-width: 700px;
            height: 90%;
            background-color: #fff;
            border-radius: 18px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.1);
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
        }

        .chat-header {
            padding: 20px;
            background: linear-gradient(135deg, #5f88d6ba, #a4c3f0b2);
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            z-index: 10;
        }

        .header-left {
            display: flex;
            align-items: center;
        }

        .avatar {
            width: 40px;
            height: 40px;
            border-radius: 50%;
            margin-right: 12px;
            object-fit: cover;
            border: 2px solid rgba(255, 255, 255, 0.5);
        }

        .user-info h2 {
            font-size: 18px;
            font-weight: 600;
        }

        .user-info p {
            font-size: 13px;
            opacity: 0.8;
        }

        .header-actions {
            display: flex;
            gap: 16px;
            opacity: 0;
        }

        .header-actions.visible {
            opacity: 1;
        }

        .header-actions i {
            font-size: 22px;
            cursor: pointer;
            transition: transform 0.2s ease;
        }

        .header-actions i:hover {
            transform: scale(1.1);
        }

        .chat-body {
            flex: 1;
            padding: 20px;
            overflow-y: auto;
            background-color: #f6f8fc;
            background-image: 
                radial-gradient(circle at 25% 25%, rgba(110, 142, 251, 0.05) 2%, transparent 5%),
                radial-gradient(circle at 75% 75%, rgba(167, 119, 227, 0.05) 2%, transparent 5%);
            background-size: 60px 60px;
        }

        .reply {
            display: block;
            margin-bottom: 6px;
            width: 100%;
            transition: all 0.3s ease;
            opacity: 1;
            transform: translateY(0);
            visibility: visible;
            z-index: 333;
        }

        .reply:hover {
            cursor: pointer;
        }

        .reply.visible {
            visibility: visible;
            opacity: 1;
            transform: translateY(0);
        }

        .reply.incoming {
            justify-content: flex-start;
        }

        .reply.outgoing {
            justify-content: flex-end;
        }

        .reply .reply-bubble {
            background-color: #abaaaa90;
        }

        .reply .reply-bubble .user-name {
            color: #252525;
            padding: none;
        }

        .reply .reply-bubble p {
            font-size: 11px;
        }

        .reply-bubble {
            padding: 2px 2px;
            border-radius: 2px;
            max-width: 100;
            position: relative;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .message {
            display: flex;
            margin-bottom: 16px;
            transition: all 0.3s ease;
            opacity: 0;
            transform: translateY(20px);
            visibility: hidden;
        }

        .message.visible {
            visibility: visible;
            opacity: 1;
            transform: translateY(0);
        }

        .message.incoming {
            justify-content: flex-start;
        }

        .message.outgoing {
            justify-content: flex-end;
        }

        .message-avatar {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-right: 12px;
        }

        .message-picture {
            width: 100%;
            border-radius: 5%;
            margin-right: 12px;
            object-fit: cover;
            border: 2px solid rgba(255, 255, 255, 0.5);
        }

        .message-picture:hover {
            cursor: pointer;
        }

        .user-name {
            padding: 4px 4px;
            border-radius: 10px;
            max-width: 100%;
            position: relative;
            color: #fa8c16;
            text-shadow: #121212 1px 0 12px;
        }

        .bubble {
            padding: 4px 10px;
            padding-bottom: 14px;
            border-radius: 20px;
            max-width: 65%;
            position: relative;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
            transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .bubble:hover {
            transform: scale(1.02);
        }

        .bubble p {
            margin: 0;
            line-height: 1.5;
            font-size: 15px;
        }

        .bubble .time {
            font-size: 11px;
            margin-top: 6px;
            opacity: 0.7;
            display: flex;
            align-items: center;
            justify-content: flex-end;
        }

        .time i {
            font-size: 14px;
            margin-left: 4px;
        }

        /* Incoming message styling */
        .message.incoming .bubble {
            background: linear-gradient(135deg, #6e8efb, #6e8efb);
            color: white;
            border-bottom-left-radius: 4px;
        }

        /* Outgoing message styling */
        .message.outgoing .bubble {
            background: linear-gradient(135deg, #c4a2eecc, #a777e3cc);
            color: white;
            border-bottom-right-radius: 4px;
        }

        .solution-box {
            display: none;
        }

        .solution-box.visible {
            display: flex;
            opacity:1;
            transform: translateY(0px);
        }

        .solution-button {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            border: none;
            width: 42px;
            height: 42px;
            border-radius: 50% 20%;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(110, 142, 251, 0.4);
            transition: all 0.2s ease;
        }

        .solution-button.visible {
            display: flex;
            opacity:1;
            transform: translateY(0px);
        }

        .solution-button:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(110, 142, 251, 0.5);
        }

        .solution-button i {
            font-size: 18px;
        }

        .solution-button.accept { 
            background: #88dd88bb;
        }

        .solution-button.reject {
            background: #dd8888bb;
        }

        /* Friend 1 styling */
        .friend-1 .bubble {
            background: linear-gradient(135deg, #13c2c2, #36cfc9);
            color: white;
            border-bottom-left-radius: 4px;
        }

        /* Friend 2 styling */
        .friend-2 .bubble {
            background: linear-gradient(135deg, #ff7a45, #fa8c16);
            color: white;
            border-bottom-left-radius: 4px;
        }

        .group-divider {
            text-align: center;
            margin: 20px 0;
            position: relative;
            opacity: 0;
            transform: translateY(20px);
            transition: all 0.3s ease;
        }

        .group-divider.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .group-divider span {
            background-color: rgba(0, 0, 0, 0.1);
            color: #555;
            padding: 5px 12px;
            border-radius: 15px;
            font-size: 12px;
            font-weight: 500;
        }

        .chat-input {
            padding: 15px 20px;
            background-color: white;
            display: flex;
            align-items: center;
            border-top: 1px solid rgba(0, 0, 0, 0.05);
            z-index: 101;
        }

        .input-actions {
            display: none;
            gap: 14px;
            color: #6e8efb;   
            opacity: 0;
            transform: translateY(10px);
        }

        .input-actions.visible {
            display: flex;
            opacity:1;
            transform: translateY(0px);
        }

        .input-actions i {
            font-size: 22px;
            cursor: pointer;
            transition: all 0.2s ease;
        }

        .input-actions i:hover {
            transform: scale(1.1);
            color: #a777e3;
        }

        .message-input {
            display: none;
            flex: 1;
            margin: 0 15px;
            padding: 12px 18px;
            border: none;
            background-color: #f6f8fc;
            border-radius: 24px;
            font-size: 15px;
            transition: all 0.2s ease;
        }

        .message-input.visible {
            display: flex;
            flex: 1;
            opacity:1;
            transform: translateY(0px);
        }

        .message-input:focus {
            outline: none;
            box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.3);
            background-color: #f0f4ff;
        }

        .send-button {
            background: linear-gradient(135deg, #6e8efb, #a777e3);
            color: white;
            border: none;
            width: 42px;
            height: 42px;
            border-radius: 50%;
            display: none;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 2px 8px rgba(110, 142, 251, 0.4);
            transition: all 0.2s ease;
        }

        .send-button.visible {
            display: flex;
            opacity:1;
            transform: translateY(0px);
        }

        .send-button:hover {
            transform: scale(1.05);
            box-shadow: 0 4px 12px rgba(110, 142, 251, 0.5);
        }

        .send-button i {
            font-size: 18px;
        }

        /* Typing indicator */
        .typing-indicator {
            display: flex;
            align-items: center;
            margin-top: 8px;
            margin-bottom: 16px;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
        }

        .typing-indicator.visible {
            opacity: 1;
            transform: translateY(0);
        }

        .typing-indicator.right {
            justify-content: flex-end;
        }

        .typing-indicator img {
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-right: 12px;
        }

        .typing-bubble {
            background-color: #e9edf5;
            padding: 12px 16px;
            border-radius: 18px;
            border-bottom-left-radius: 4px;
            position: relative;
            display: flex;
            align-items: center;
        }

        .typing-bubble.right {
            border-radius: 18px;
            border-bottom-right-radius: 4px;  
        }

        .typing-dot {
            background-color: #9da9c7;
            width: 8px;
            height: 8px;
            border-radius: 50%;
            margin: 0 2px;
            animation: typingAnimation 1.5s infinite ease-in-out;
        }

        .typing-dot:nth-child(1) {
            animation-delay: 0s;
        }

        .typing-dot:nth-child(2) {
            animation-delay: 0.3s;
        }

        .typing-dot:nth-child(3) {
            animation-delay: 0.6s;
        }

        @keyframes typingAnimation {
            0%, 100% {
                transform: translateY(0);
            }
            50% {
                transform: translateY(-5px);
            }
        }

        /* Reaction styling */
        .reaction {
            position: absolute;
            bottom: -12px;
            right: 10px;
            background: white;
            padding: 3px 8px;
            border-radius: 12px;
            font-size: 13px;
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
            display: flex;
            align-items: center;
            opacity: 0;
            transform: scale(0.8);
            transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        }

        .reaction.visible {
            opacity: 1;
            transform: scale(1);
        }

        .reaction span {
            margin-left: 4px;
            font-weight: 500;
            color: #555;
        }

        .reaction span::first-letter {
            color: red;
        }

        .reaction .animate {
            text-shadow: 0 0 11px #e00e0e;

            animation-name: flyInAnimation, reactionAnimation;
            animation-delay: 0s, 1s;
            animation-duration: 1s, 1.5s;
            animation-iteration-count: 1, 1;
            animation-timing-function: linear, linear;
            animation-direction: forwards, forwards;
        }

        @keyframes flyInAnimation {
            0% {
                transform: scale(10) rotate(-360deg);
                opacity: 0.1;
            }
            
            100% {
                transform: scale(1.) rotate(0deg);
                opacity: 1;
            }
        }

        @keyframes reactionAnimation {
            0%, 100% {
                transform: scale(1.) rotate(0deg);
            }
            25% {
                transform: scale(1.4) rotate(-35deg);
            }
            50% {
                transform: scale(1.7) rotate(0deg);
            }
            75% {
                transform: scale(1.4) rotate(35deg);
            }
        }

        /* Custom scrollbar */
        .chat-body::-webkit-scrollbar {
            width: 6px;
        }

        .chat-body::-webkit-scrollbar-track {
            background: transparent;
        }

        .chat-body::-webkit-scrollbar-thumb {
            background-color: rgba(0, 0, 0, 0.1);
            border-radius: 10px;
        }

        .chat-body::-webkit-scrollbar-thumb:hover {
            background-color: rgba(0, 0, 0, 0.2);
        }

        /* file upload preview */
        .upload-preview {
            position: absolute;
            bottom: 80px;
            left: 50%;
            background-color: #333333f5;
            border-radius: 12px;
            box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
            padding: 12px;
            width: 90%;
            display: flex;
            flex-wrap: wrap;
            visibility: hidden;
            justify-content: space-between;
            gap: 8px;
            opacity: 0;
            translate: -50% 0;
            transform: translateY(100px);
            transition: all 0.3s ease;
            pointer-events: all;
            z-index: 100;
        }

        .upload-preview.visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: all;
            visibility: visible;
        }

        .upload-preview-image-container {
            width: 100%;
            min-height: 30px;

        }

        .upload-preview-image-container img {
            position: relative;
            /*left: 50%;
            top: 50%;*/
            margin: auto;
            display: flex;
            max-width: 80%;
            /*translate: -50% -50%;*/
            box-shadow: 3px 3px 30px #dddddd;
            border: 2px solid rgba(255, 255, 255, 0.5);
            border-radius: 5%;
        }

        .close-button {
            position: absolute;
            top: 10px;
            right: 10px;
            cursor: pointer;
        }

        .reaction-popup {
            position: absolute;
            bottom: 80px;
            left: 20%;
            background: white;
            border-radius: 12px;
            box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
            padding: 12px;
            margin-right: 20px;
            width: 216px;
            display: flex;
            justify-content: space-between;
            gap: 5px;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
            pointer-events: none;
            z-index: 100;
        }

        .reaction-popup.visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: all;
        }

        .reaction-popup.with-reply {
            width: 269px;
        }

        .reaction-popup.outgoing {
            translate: -80% 0;
        }

        .reply-popup {
            width: 36px;
            height: 100%;
            margin-left: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .reply-option {
            width: 36px;
            height: 36px;
            display: flex;

            padding: 7px;
            font-size: 22px;
            cursor: pointer;
            border-radius: 20%;
            transition: all 0.2s ease;
        }

        .reply-option:hover {
            background-color: #f0f4ff;
            color: #a777e3;
            transform: scale(1.1);
        }

        .vertical-divider {
            position: absolute;
            left: 210px;
            height: 80%;
            width: 3px;
            padding: 3px;
            border-left: 3px solid #cccccccc;
            border-radius: 3px;
            display: flex;
        }

        /* Pop-up reactions selector */
        .reaction-selector {
            width: 192px;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 3px;
            /*opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;*/
            pointer-events: all;
            z-index: 105;
        }

        /*
        .reaction-selector.visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: all;
        }

        .reaction-selector.incoming {
            justify-content: flex-start;
        }

        .reaction-selector.outgoing {
            margin-left: 20px;
            translate: -80% 0;
            justify-content: flex-end;
        }*/

        .reaction-option {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s ease;
        }

        .reaction-option:hover {
            background-color: #f0f4ff;
            transform: scale(1.1);
        }

        /* Pop-up emoji selector */
        .emoji-selector {
            position: absolute;
            bottom: 80px;
            left: 20px;
            background: white;
            border-radius: 12px;
            box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
            padding: 12px;
            width: 240px;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
            gap: 8px;
            opacity: 0;
            transform: translateY(10px);
            transition: all 0.3s ease;
            pointer-events: none;
            z-index: 100;
        }

        .emoji-selector.visible {
            opacity: 1;
            transform: translateY(0);
            pointer-events: all;
        }

        .emoji-option {
            width: 36px;
            height: 36px;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 20px;
            cursor: pointer;
            border-radius: 8px;
            transition: all 0.2s ease;
        }

        .emoji-option:hover {
            background-color: #f0f4ff;
            transform: scale(1.1);
        }

        /* Animation for sending a new message */
        @keyframes sendAnimation {
            0% {
                opacity: 0;
                transform: translateY(20px) scale(0.8);
            }
            100% {
                opacity: 1;
                transform: translateY(0) scale(1);
            }
        }

        .message.sending {
            animation: sendAnimation 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
        }

        a:link, a:visited {
            color: #afcbff;
            text-shadow: 1px 1px 3px #33333380;
            background-color: #5f88d6a0;
            text-decoration: dotted;
            padding: 4px;
            line-height: 20px;
            border-radius: 10px;
            border-bottom-left-radius: 0;
        }

        a:hover {
            text-shadow: 1px 1px 3px #ffaaffb0;
        }

        a:active {
            font-weight: bold;
            filter: blur(1px);
            text-shadow: 1px 1px 3px #ffaaffb0;
        }


        @media (max-width: 900px) {
            
            .gallery-container img {
                max-width: 90%;
                max-height: 90%;
                box-shadow: none;
            }
            
            .chat-container {
                width: 100%;
                height: 100%;
                padding-bottom: 10px;
                border-radius: 0;
            }

            .bubble {
                max-width: 75%;
            }

            .header-actions i:nth-child(3),
            .header-actions i:nth-child(4) {
                display: none;
            }

            .input-actions i:nth-child(3),
            .input-actions i:nth-child(4) {
                display: none;
            }
        }

        /* Adaptive dark mode support */
        @media (prefers-color-scheme: dark) {
            body {
                background-color: #121212;
            }

            .chat-container {
                background-color: #1f1f1f;
                box-shadow: 0 12px 28px rgba(0, 0, 0, 0.25);
            }

            .chat-body {
                background-color: #121212;
                background-image: 
                    radial-gradient(circle at 25% 25%, rgba(110, 142, 251, 0.08) 2%, transparent 5%),
                    radial-gradient(circle at 75% 75%, rgba(167, 119, 227, 0.08) 2%, transparent 5%);
            }

            .message-input {
                background-color: #2d2d2d;
                color: #e0e0e0;
            }

            .message-input:focus {
                background-color: #333;
                box-shadow: 0 0 0 2px rgba(110, 142, 251, 0.4);
            }

            .typing-bubble {
                background-color: #2d2d2d;
            }

            .typing-dot {
                background-color: #aaa;
            }

            .group-divider span {
                background-color: rgba(255, 255, 255, 0.1);
                color: #bbb;
            }

            .reaction {
                background: #2d2d2d;
            }

            .reaction span {
                color: #ddd;
            }

            .reaction-popup {
                background-color: #2d2d2d;
            }

            .reaction-option:hover {
                background-color: #3d3d3d;
            }

            .reply-option:hover {
                background-color: #3d3d3d;
            }

            .emoji-selector {
                background-color: #2d2d2d;
            }

            .emoji-option:hover {
                background-color: #3d3d3d;
            }

            .chat-input {
                background-color: #1f1f1f;
                border-top: 1px solid rgba(255, 255, 255, 0.05);
            }
        }
