/* ============================================
   COMPLETE CHAT APP CSS - .NET CORE
   FULLY RESPONSIVE
   ============================================ */

/* ---------- RESET & BASE ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

html, body {
    height: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    background: #0b141a;
}

/* ---------- APP CONTAINER ---------- */
.app-container {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: linear-gradient(145deg, #0b141a 0%, #1a2639 100%);
}

.main-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-wrapper {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 2.5rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 420px;
    padding: 2.8rem 2.2rem;
    margin: auto;
}

.login-card {
    display: flex;
    flex-direction: column;
    gap: 1.8rem;
}

.login-header {
    text-align: center;
}

    .login-header h1 {
        font-size: 2.4rem;
        font-weight: 700;
        color: #1a2639;
        letter-spacing: -0.5px;
    }

        .login-header h1 i {
            margin-right: 0.3rem;
        }

    .login-header p {
        color: #4a5b6e;
        font-weight: 500;
        margin-top: 0.3rem;
        font-size: 1rem;
    }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.input-group {
    display: flex;
    align-items: center;
    background: #f0f2f5;
    border-radius: 60px;
    padding: 0.2rem 1.2rem;
    border: 2px solid transparent;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

    .input-group:focus-within {
        border-color: #1f2a40;
        background: #ffffff;
        box-shadow: 0 4px 20px rgba(26, 38, 57, 0.08);
    }

    .input-group i {
        color: #6b7e9c;
        font-size: 1.1rem;
        margin-right: 0.8rem;
        width: 1.4rem;
        text-align: center;
        flex-shrink: 0;
    }

    .input-group input {
        border: none;
        background: transparent;
        padding: 1rem 0;
        font-size: 1rem;
        width: 100%;
        outline: none;
        color: #1a2639;
        font-weight: 500;
    }

        .input-group input::placeholder {
            color: #a5b7cd;
            font-weight: 400;
        }

.btn-primary {
    background: #1f2a40;
    border: none;
    padding: 1rem;
    border-radius: 60px;
    font-size: 1.1rem;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 6px 20px rgba(26, 38, 57, 0.25);
}

    .btn-primary:hover {
        background: #2c3f5e;
        transform: translateY(-1px);
        box-shadow: 0 8px 25px rgba(26, 38, 57, 0.35);
    }

    .btn-primary:active {
        transform: translateY(0);
    }

.login-footer {
    text-align: center;
    font-size: 0.85rem;
    color: #4b5f77;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

/* ============================================
   CHAT APP - WHATSAPP/TELEGRAM STYLE
   ============================================ */
.chat-app-wrapper {
    background: #efeae2;
    width: 100%;
    max-width: 1200px;
    height: 100%;
    max-height: 800px;
    border-radius: 1.5rem;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.chat-container {
    display: flex;
    height: 100%;
    width: 100%;
    background: #fff;
}

/* ========== LEFT PANEL: CONTACTS ========== */
.contacts-panel {
    width: 380px;
    min-width: 280px;
    height: 100%;
    background: #fff;
    border-right: 1px solid #e9edef;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.contacts-header {
    background: #f0f2f5;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid #e9edef;
    flex-shrink: 0;
}

.contacts-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.8rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.profile-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #e9edef;
}

.profile-name {
    font-weight: 600;
    font-size: 1rem;
    color: #111b21;
}

.contacts-actions {
    display: flex;
    gap: 0.3rem;
}

.icon-btn-sm {
    background: transparent;
    border: none;
    color: #54656f;
    font-size: 1.1rem;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: 50%;
    transition: 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

    .icon-btn-sm:hover {
        background: rgba(0, 0, 0, 0.05);
    }

.search-bar {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 8px;
    padding: 0.2rem 0.8rem;
    border: 1px solid #e9edef;
}

    .search-bar i {
        color: #667781;
        margin-right: 0.6rem;
        font-size: 0.9rem;
    }

    .search-bar input {
        border: none;
        background: transparent;
        padding: 0.6rem 0;
        width: 100%;
        outline: none;
        font-size: 0.9rem;
        color: #111b21;
    }

        .search-bar input::placeholder {
            color: #8696a0;
        }

/* ---------- CONTACTS LIST ---------- */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.2rem 0;
    background: #fff;
}

    .contacts-list::-webkit-scrollbar {
        width: 6px;
    }

    .contacts-list::-webkit-scrollbar-thumb {
        background: #b7b7b7;
        border-radius: 10px;
    }

.contact-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1rem;
    cursor: pointer;
    transition: 0.15s;
    border-bottom: 1px solid #f0f2f5;
    gap: 0.8rem;
}

    .contact-item:hover {
        background: #f0f2f5;
    }

    .contact-item.active {
        background: #e9edef;
    }

.contact-avatar {
    position: relative;
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

    .contact-avatar img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        object-fit: cover;
    }

    .contact-avatar .status-dot-sm {
        position: absolute;
        bottom: 0;
        right: 0;
        width: 12px;
        height: 12px;
        border-radius: 50%;
        border: 2px solid #fff;
    }

.status-dot-sm.online {
    background: #31a24c;
}

.status-dot-sm.offline {
    background: #b1b1b1;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 500;
    color: #111b21;
    font-size: 0.95rem;
}

.contact-last-msg {
    font-size: 0.8rem;
    color: #667781;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 0.1rem;
}

.contact-time {
    font-size: 0.7rem;
    color: #667781;
    flex-shrink: 0;
    margin-left: auto;
}

/* ========== RIGHT PANEL: CHAT ========== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #efeae2;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4c9b8' fill-opacity='0.2'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    min-width: 0;
}

/* Chat Panel Header */
.chat-panel-header {
    background: #f0f2f5;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e9edef;
    flex-shrink: 0;
}

.chat-panel-user {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex: 1;
    min-width: 0;
}

.back-to-contacts {
    display: none;
    background: transparent;
    border: none;
    color: #54656f;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
}

.chat-avatar-container {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.chat-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.chat-avatar-container .status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #f0f2f5;
}

.status-dot.online {
    background: #31a24c;
}

.status-dot.offline {
    background: #b1b1b1;
}

.chat-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-contact-name {
    font-weight: 600;
    color: #111b21;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-contact-status {
    font-size: 0.7rem;
    color: #667781;
}

.chat-actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
}

/* Chat Messages Panel */
.chat-messages-panel {
    flex: 1;
    padding: 0.8rem 1.2rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    scroll-behavior: smooth;
    min-height: 0;
}

    .chat-messages-panel::-webkit-scrollbar {
        width: 6px;
    }

    .chat-messages-panel::-webkit-scrollbar-thumb {
        background: #b7b7b7;
        border-radius: 10px;
    }

.no-chat-selected {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #667781;
    text-align: center;
    gap: 0.8rem;
}

    .no-chat-selected i {
        font-size: 4rem;
        color: #ccc;
    }

    .no-chat-selected h3 {
        font-weight: 500;
        font-size: 1.2rem;
        color: #41525d;
    }

    .no-chat-selected p {
        font-size: 0.9rem;
    }

/* Message Bubbles */
.message-row {
    display: flex;
    margin: 0.1rem 0;
    animation: fadeIn 0.2s ease;
}

    .message-row.received {
        justify-content: flex-start;
    }

    .message-row.sent {
        justify-content: flex-end;
    }

.message-bubble {
    max-width: 70%;
    padding: 0.6rem 0.9rem;
    border-radius: 8px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message-row.received .message-bubble {
    background: white;
    border-top-left-radius: 0;
    color: #111b21;
}

.message-row.sent .message-bubble {
    background: #d9fdd3;
    border-top-right-radius: 0;
    color: #111b21;
}

.message-bubble p {
    margin: 0;
}

.message-bubble .msg-time {
    display: inline-block;
    font-size: 0.6rem;
    color: #667781;
    margin-top: 0.2rem;
    float: right;
    margin-left: 0.5rem;
}

.message-row.sent .msg-time {
    color: #667781;
}

    .message-row.sent .msg-time i {
        margin-left: 0.2rem;
    }

/* Typing Indicator */
.typing-indicator .message-bubble {
    background: white;
    border-top-left-radius: 0;
    padding: 0.6rem 1rem;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

    .typing-dots span {
        width: 8px;
        height: 8px;
        background: #667781;
        border-radius: 50%;
        display: inline-block;
        animation: typingBounce 1.4s infinite;
    }

        .typing-dots span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-dots span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Input */
.chat-input-panel {
    background: #f0f2f5;
    padding: 0.3rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    border-top: 1px solid #e9edef;
    flex-shrink: 0;
}

    .chat-input-panel input {
        flex: 1;
        border: none;
        padding: 0.7rem 0.8rem;
        font-size: 0.95rem;
        outline: none;
        background: #fff;
        border-radius: 20px;
        color: #111b21;
    }

        .chat-input-panel input::placeholder {
            color: #999;
        }

    .chat-input-panel button {
        background: transparent;
        border: none;
        color: #54656f;
        font-size: 1.2rem;
        padding: 0.4rem 0.6rem;
        cursor: pointer;
        border-radius: 50%;
        transition: 0.2s;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

        .chat-input-panel button:hover {
            background: rgba(0, 0, 0, 0.05);
        }

.send-btn-wa {
    background: #1f2a40 !important;
    color: white !important;
    border-radius: 50% !important;
    transition: 0.2s;
}

    .send-btn-wa:hover {
        background: #2c3f5e !important;
        transform: scale(1.05);
    }

    .send-btn-wa i {
        font-size: 1rem;
    }

/* ========== RESPONSIVE ========== */
@media (max-width: 992px) {
    .contacts-panel {
        width: 320px;
        min-width: 240px;
    }
}

@media (max-width: 768px) {
    .app-container {
        padding: 0;
    }

    .chat-app-wrapper {
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .contacts-panel {
        width: 100%;
        min-width: 0;
    }

    .chat-panel {
        display: none;
        width: 100%;
    }

        .chat-panel.active {
            display: flex;
        }

    .back-to-contacts {
        display: block !important;
    }

    .contacts-panel.hidden {
        display: none;
    }

    .login-wrapper {
        border-radius: 1.5rem;
        padding: 2.2rem 1.8rem;
        max-width: 400px;
    }
}

@media (min-width: 769px) {
    .back-to-contacts {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .app-container {
        padding: 0;
    }

    .login-wrapper {
        border-radius: 0;
        padding: 2rem 1.2rem;
        min-height: 100vh;
        max-width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
    }

    .login-header h1 {
        font-size: 2rem;
    }

    .contact-item {
        padding: 0.6rem 0.8rem;
    }

    .contact-avatar {
        width: 40px;
        height: 40px;
    }

    .chat-panel-header {
        padding: 0.4rem 0.6rem;
    }

    .chat-messages-panel {
        padding: 0.6rem;
    }

    .message-bubble {
        max-width: 85%;
        font-size: 0.85rem;
        padding: 0.5rem 0.7rem;
    }

    .chat-input-panel {
        padding: 0.2rem 0.4rem;
    }

        .chat-input-panel input {
            padding: 0.6rem 0.7rem;
            font-size: 0.9rem;
        }

    .send-btn-wa {
        width: 36px;
        height: 36px;
    }

    .no-chat-selected i {
        font-size: 3rem;
    }

    .no-chat-selected h3 {
        font-size: 1rem;
    }
}

@media (max-width: 360px) {
    .login-wrapper {
        padding: 1.5rem 1rem;
    }

    .login-header h1 {
        font-size: 1.7rem;
    }

    .input-group {
        padding: 0.1rem 1rem;
    }

        .input-group input {
            padding: 0.8rem 0;
            font-size: 0.9rem;
        }

    .btn-primary {
        padding: 0.8rem;
        font-size: 1rem;
    }

    .contacts-header {
        padding: 0.5rem 0.6rem;
    }

    .profile-img {
        width: 32px;
        height: 32px;
    }

    .profile-name {
        font-size: 0.85rem;
    }

    .icon-btn-sm {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
}
