@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');

:root {
    --bg-main: #0b141a;
    --bg-sidebar: #111b21;
    --bg-header: #202c33;
    --bg-chat: #0b141a;
    --accent: #00a884;
    --bubble-in: #202c33;
    --bubble-out: #005c4b;
    --text-primary: #e9edef;
    --text-secondary: #8696a0;
    --text-accent: #00a884;
    --border: #222d34;
    --input-bg: #2a3942;
}

.light-theme {
    --bg-main: #f0f2f5;
    --bg-sidebar: #ffffff;
    --bg-header: #f0f2f5;
    --bg-chat: #efeae2;
    --input-bg: #ffffff;
    --border: #e9edef;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --text-accent: #00a884;
    --bubble-in: #ffffff;
    --bubble-out: #dcf8c6;
    --accent: #00a884;
}

.winter-theme {
    --bg-main: #e3f2fd;
    --bg-sidebar: #ffffff;
    --bg-header: #bbdefb;
    --bg-chat: #f0f8ff;
    --input-bg: #ffffff;
    --border: #e1f5fe;
    --text-primary: #01579b;
    --text-secondary: #0288d1;
    --text-accent: #03a9f4;
    --bubble-in: #ffffff;
    --bubble-out: #b3e5fc;
    --accent: #03a9f4;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    overflow: hidden;
}

/* Theme Visuals Container */
.theme-visuals {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 2;
}

/* ☀️ Day Mode: Pulsing Sun */
.sun-animation {
    display: none;
    position: absolute;
    top: 40px;
    right: 40px;
    width: 80px;
    height: 80px;
    background: radial-gradient(circle, #ffb100 0%, #ff8f00 100%);
    border-radius: 50%;
    box-shadow: 0 0 50px #ffb100, 0 0 100px rgba(255, 177, 0, 0.4);
    animation: sunRise 6s ease-out infinite alternate;
}

.light-theme .sun-animation {
    display: block;
}

@keyframes sunRise {
    0% { transform: translateY(20px) scale(0.9); opacity: 0.7; }
    100% { transform: translateY(0) scale(1.1); opacity: 1; box-shadow: 0 0 70px #ffb100, 0 0 130px rgba(255, 177, 0, 0.6); }
}

/* 🌙 Night Mode: Twinkling Moon & Stars */
.moon-animation {
    display: none;
    position: absolute;
    top: 40px;
    right: 60px;
    width: 60px;
    height: 60px;
    background: #aebac1;
    border-radius: 50%;
    box-shadow: 0 0 30px #aebac1, 0 0 60px rgba(174, 186, 193, 0.3);
    animation: moonFloat 8s ease-in-out infinite alternate;
}

body:not(.light-theme):not(.winter-theme) .moon-animation {
    display: block;
}

@keyframes moonFloat {
    0% { transform: translateY(10px) rotate(-5deg); opacity: 0.8; }
    100% { transform: translateY(0) rotate(5deg); opacity: 1; }
}

.stars-animation {
    display: none;
    position: absolute;
    width: 100%;
    height: 100%;
}

body:not(.light-theme):not(.winter-theme) .stars-animation {
    display: block;
}

.stars-animation::before {
    content: "";
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    box-shadow: 
        15vw 10vh 2px #aebac1, 25vw 35vh 1px #aebac1, 35vw 15vh 3px #aebac1, 
        45vw 50vh 1px #aebac1, 55vw 25vh 2px #aebac1, 65vw 65vh 1px #aebac1, 
        75vw 35vh 3px #aebac1, 85vw 55vh 1px #aebac1, 95vw 15vh 2px #aebac1,
        10vw 75vh 1px #aebac1, 40vw 90vh 3px #aebac1, 70vw 80vh 1px #aebac1, 
        90vw 95vh 2px #aebac1, 50vw 30vh 1px #aebac1, 80vw 15vh 3px #aebac1;
    animation: twinkle 4s ease-in-out infinite;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ❄️ Winter Theme: Snowfall */
.snow-container {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.winter-theme .snow-container {
    display: block;
}

.snowflake {
    position: absolute;
    top: -10px;
    color: #03a9f4;
    font-size: 1.5em;
    animation: fall linear infinite;
    text-shadow: 0 0 8px rgba(3, 169, 244, 0.6);
}

@keyframes fall {
    to { transform: translateY(105vh) translateX(30px) rotate(360deg); }
}

.app-container {
    width: 100%;
    height: 100%;
    max-width: 1600px;
    background-color: var(--bg-main);
    display: flex;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    z-index: 10;
}

/* Sidebar */
.sidebar {
    width: 30%;
    min-width: 350px;
    max-width: 450px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    height: 60px;
    padding: 10px 16px;
    background-color: var(--bg-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.profile-name {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

.profile-pic {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #6a7175;
    overflow: hidden;
}

.profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-icons {
    display: flex;
    gap: 5px;
    color: var(--text-secondary);
    font-size: 20px;
    position: relative;
    align-items: center;
}

.icon-btn {
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.light-theme .icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Theme Specific Icon Colors */
.light-theme #themeToggle svg,
.light-theme #themeToggle i {
    color: #ffb100 !important; /* Golden Sun */
}

.winter-theme #themeToggle svg,
.winter-theme #themeToggle i {
    color: #03a9f4 !important; /* Blue Snowflake */
}

/* Night Mode (No special theme class) */
body:not(.light-theme):not(.winter-theme) #themeToggle svg,
body:not(.light-theme):not(.winter-theme) #themeToggle i {
    color: #aebac1 !important; /* Silver Moon */
}

.icon-btn i,
.icon-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

#themeToggle:hover i,
#themeToggle:hover svg {
    transform: rotate(20deg) scale(1.1);
}

/* Dropdown Menu Styles */
.dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

#menuBtn {
    border-radius: 50%;
    transition: background-color 0.2s;
    cursor: pointer;
}

#menuBtn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 40px;
    background-color: var(--bg-header);
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.8);
    z-index: 2000;
    border-radius: 4px;
    padding: 8px 0;
    border: 1px solid var(--border);
}

.dropdown-content a {
    color: var(--text-primary);
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    font-size: 14px;
    transition: background 0.2s;
}

.dropdown-content a:hover {
    background-color: var(--input-bg);
}

.show-dropdown {
    display: block !important;
}

.search-container {
    padding: 10px;
    background-color: var(--bg-sidebar);
}

.search-bar {
    background-color: var(--bg-header);
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    font-size: 14px;
}

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

.chat-item {
    display: flex;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.chat-item:hover,
.chat-item.active {
    background-color: var(--bg-header);
}

.chat-item-info {
    flex: 1;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-name {
    font-weight: 500;
    font-size: 16px;
}

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

.chat-last-msg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
}

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

.main-chat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
    opacity: 0.06;
    pointer-events: none;
}

.chat-header {
    height: 60px;
    padding: 10px 16px;
    background-color: var(--bg-header);
    display: flex;
    align-items: center;
    z-index: 10;
    position: relative;
}

.chat-search-container {
    position: absolute;
    right: 50px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--input-bg);
    border-radius: 20px;
    padding: 5px 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 250px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; width: 0; }
    to { opacity: 1; width: 250px; }
}

.chat-search-container input {
    background: none;
    border: none;
    color: var(--text-primary);
    width: 100%;
    outline: none;
    font-size: 14px;
}

.chat-search-container i {
    cursor: pointer;
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

.chat-header-info {
    margin-left: 15px;
    flex: 1;
}

.current-chat-name {
    font-weight: 500;
    font-size: 16px;
}

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

.messages-container {
    flex: 1;
    padding: 20px 7%;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1;
}

.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14.5px;
    line-height: 1.4;
    position: relative;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}

.message.received {
    align-self: flex-start;
    background-color: var(--bubble-in);
    border-top-left-radius: 0;
}

.message.sent {
    align-self: flex-end;
    background-color: var(--bubble-out);
    border-top-right-radius: 0;
}

.message-time {
    display: block;
    text-align: right;
    font-size: 11px;
    color: rgba(233, 237, 239, 0.6);
    margin-top: 4px;
}

/* Welcome Screen */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    background-color: transparent;
    z-index: 5;
    border-bottom: 6px solid #009999;
}

.welcome-content {
    max-width: 560px;
    padding: 20px;
}

.welcome-logo {
    margin-bottom: 40px;
    opacity: 0.5;
}

.welcome-screen h1 {
    font-size: 32px;
    font-weight: 300;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.welcome-screen p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 40px;
}

.welcome-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 14px;
    opacity: 0.6;
}

.chat-footer {
    padding: 10px 16px;
    background-color: var(--bg-header);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 10;
}

.input-container {
    flex: 1;
    background-color: var(--input-bg);
    border-radius: 24px;
    padding: 9px 18px;
}

.input-container input {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-primary);
    outline: none;
    font-size: 15px;
}

.footer-icon {
    color: var(--text-secondary);
    width: 24px;
    height: 24px;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footer-icon:hover {
    color: var(--text-primary);
}

/* Emoji Picker Styling */
.emoji-picker-container {
    position: relative;
    display: flex;
    align-items: center;
}

.emoji-picker {
    position: absolute;
    bottom: 50px;
    left: 0;
    width: 280px;
    height: 320px;
    background-color: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    display: none;
    flex-direction: column;
    z-index: 1000;
    overflow: hidden;
    animation: slideUp 0.2s ease-out;
}

.emoji-picker.show {
    display: flex;
}

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

.emoji-picker-header {
    padding: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    background: rgba(255, 255, 255, 0.03);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
    padding: 10px;
    overflow-y: auto;
    flex: 1;
}

.emoji-item {
    font-size: 22px;
    padding: 5px;
    cursor: pointer;
    text-align: center;
    border-radius: 6px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.send-btn-circle {
    background-color: var(--accent);
    color: var(--bg-main);
    border: none;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
    flex-shrink: 0;
}

.send-btn-circle:hover {
    transform: scale(1.05);
    background-color: #008f6f;
}

.send-btn-circle i {
    width: 24px;
    height: 24px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: fadeIn 0.3s ease-out forwards;
}

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

::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Navigation & Responsive */
.back-btn-container {
    display: none;
    margin-right: 10px;
    padding: 10px;
    cursor: pointer;
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    border-radius: 50%;
    z-index: 100;
}

.back-btn-container:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.back-icon {
    width: 24px;
    height: 24px;
}

@media (max-width: 768px) {
    body {
        height: 100dvh;
        width: 100vw;
        position: fixed; /* Prevent scrolling/bouncing on some mobile browsers */
    }

    .app-container {
        height: 100dvh;
        width: 100vw;
        max-width: none;
        border-radius: 0;
        box-shadow: none;
    }

    .back-btn-container {
        display: flex;
    }

    .sidebar {
        width: 100%;
        min-width: 0; /* Important: Override the desktop 350px min-width */
        max-width: none;
        position: absolute;
        height: 100%;
        z-index: 20;
        transition: transform 0.3s ease;
    }

    .sidebar-header, .chat-header {
        height: 54px;
    }

    .main-chat {
        width: 100%;
        min-width: 0; /* Important: Override any desktop constraints */
        position: absolute;
        height: 100%;
        z-index: 10;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }

    .app-container.show-chat .sidebar {
        transform: translateX(-100%);
    }

    .app-container.show-chat .main-chat {
        transform: translateX(0);
        z-index: 30;
    }

    .messages-container {
        padding: 15px 4%;
    }

    .message {
        max-width: 85%;
    }

    /* Adjust modal for mobile */
    .modal-content {
        width: 95%;
        height: 90%;
        border-radius: 12px;
    }
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: var(--bg-header);
    width: 90%;
    max-width: 400px;
    border-radius: 12px;
    overflow: hidden;
    animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 15px 20px;
    background: #009999;
    color: white;
    display: flex;
    align-items: center;
    gap: 20px;
}

.close-modal-btn {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s;
}

.close-modal-btn:hover {
    opacity: 0.7;
}

.close-icon {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-profile-pic {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    margin-bottom: 20px;
    border: 4px solid var(--border);
}

.modal-profile-pic img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.modal-info {
    width: 100%;
    color: var(--text-primary);
}

.modal-info h3 {
    margin-bottom: 5px;
    font-size: 20px;
}

.modal-status {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 25px;
}

.info-item {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item i {
    color: var(--text-secondary);
    width: 20px;
}

.info-item span {
    display: block;
    font-size: 12px;
    color: var(--text-accent);
    margin-bottom: 4px;
}

.info-item p {
    font-size: 14px;
    line-height: 1.4;
}

/* Theme Dropdown */
.theme-dropdown-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.theme-dropdown-menu {
    display: none;
    position: absolute;
    top: 44px;
    right: 0;
    background-color: var(--bg-header);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 3000;
    min-width: 150px;
    padding: 6px 0;
    animation: dropdownFade 0.15s ease-out;
}

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

.theme-dropdown-menu.open {
    display: block;
}

.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: background 0.15s;
    border-radius: 4px;
}

.theme-option:hover {
    background-color: var(--input-bg);
}

.theme-option.active {
    color: var(--accent);
    font-weight: 600;
}

.theme-option i {
    width: 16px;
    height: 16px;
}
