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

:root {
    --bg-gradient: radial-gradient(circle at top right, #1a1235 0%, #0d091e 50%, #05030a 100%);
    --panel-bg: rgba(20, 16, 38, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --glass-accent: rgba(99, 102, 241, 0.15);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.4);
    
    --bubble-sent: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    --bubble-received: rgba(255, 255, 255, 0.06);
    
    --sidebar-width: 350px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    outline: none;
}

body {
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Authentication Page Styles */
.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
    perspective: 1000px;
}

.auth-card {
    background: var(--panel-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 40px 30px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
    transition: var(--transition);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header .logo {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 100%);
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 15px;
    box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    overflow: hidden;
}

.auth-header .logo svg {
    width: 32px;
    height: 32px;
    fill: #fff;
}

.auth-header .logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auth-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #ffffff 0%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 4px;
    margin-bottom: 25px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 10px 0;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.form-group {
    position: relative;
    margin-bottom: 20px;
}

.form-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px 16px 14px 44px;
    color: #fff;
    font-size: 15px;
    transition: var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
}

.form-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    transition: var(--transition);
}

.form-input:focus ~ .form-icon {
    color: var(--primary);
}

.btn {
    width: 100%;
    background: var(--bubble-sent);
    border: none;
    border-radius: 12px;
    padding: 14px;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.5);
}

.btn:active {
    transform: translateY(0);
}

/* Chat Main Layout */
.chat-app {
    width: 100vw;
    height: 100vh;
    display: flex;
    background: var(--bg-gradient);
    overflow: hidden;
}

/* Left Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: rgba(13, 9, 30, 0.7);
    border-right: 1px solid var(--panel-border);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--panel-border);
}

.user-profile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--panel-border);
}

.user-info h4 {
    font-weight: 600;
    font-size: 16px;
}

.user-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-logout {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.search-box {
    position: relative;
}

.search-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 10px 12px 10px 38px;
    color: #fff;
    font-size: 14px;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    width: 16px;
    height: 16px;
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.user-list::-webkit-scrollbar {
    width: 4px;
}

.user-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 16px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 5px;
    border: 1px solid transparent;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.user-item.active {
    background: var(--glass-accent);
    border-color: rgba(99, 102, 241, 0.2);
}

.avatar-wrapper {
    position: relative;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    position: absolute;
    bottom: 0;
    right: 0;
    border: 2px solid #0d091e;
    background: var(--text-muted);
}

.status-indicator.online {
    background: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.user-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
}

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

.user-item.active .user-last-msg {
    color: var(--text-primary);
}

.badge {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.5);
    animation: pulse 2s infinite;
}

/* Chat Main View */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: rgba(5, 3, 10, 0.4);
    position: relative;
}

.chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px;
}

.chat-welcome .welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--glass-accent);
    border-radius: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.chat-welcome h3 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.chat-welcome p {
    color: var(--text-secondary);
    font-size: 14px;
    max-width: 320px;
}

.chat-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--panel-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(13, 9, 30, 0.4);
    backdrop-filter: blur(10px);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

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

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.message-row {
    display: flex;
    width: 100%;
}

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

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

.message-bubble {
    max-width: 65%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    line-height: 1.5;
    font-size: 15px;
    word-break: break-word;
}

.message-row.sent .message-bubble {
    background: var(--bubble-sent);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.message-row.received .message-bubble {
    background: var(--bubble-received);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-top-left-radius: 4px;
}

.message-info {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 10px;
}

.message-row.sent .message-info {
    color: rgba(255, 255, 255, 0.6);
}

.message-row.received .message-info {
    color: var(--text-muted);
}

.read-receipt {
    display: flex;
}

.read-receipt svg {
    width: 14px;
    height: 14px;
}

.read-receipt.read svg {
    color: #38bdf8;
}

/* Chat Footer / Input */
.chat-footer {
    padding: 16px 24px;
    background: rgba(13, 9, 30, 0.5);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--panel-border);
}

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

.chat-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.chat-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 12px 48px 12px 20px;
    color: #fff;
    font-size: 15px;
    transition: var(--transition);
}

.chat-input:focus {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.btn-emoji {
    position: absolute;
    right: 16px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
}

.btn-emoji:hover {
    color: #fff;
}

.btn-send {
    background: var(--primary);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-send:hover {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.btn-send svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    margin-left: 2px;
}

/* Notification Permission Banner */
.notification-banner {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.2) 0%, rgba(79, 70, 229, 0.2) 100%);
    border-bottom: 1px solid rgba(99, 102, 241, 0.3);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideDown 0.5s ease-out;
}

.notification-banner-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.notification-banner-content svg {
    color: var(--primary);
    animation: swing 2s infinite ease-in-out;
}

.btn-enable-notif {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 6px 16px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-enable-notif:hover {
    background: var(--primary-hover);
}

.btn-close-banner {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

/* Back button for mobile view */
.btn-back {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px;
}

/* Keyframe Animations */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); box-shadow: 0 0 14px rgba(99, 102, 241, 0.7); }
    100% { transform: scale(1); }
}

@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes swing {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(10deg); }
    30% { transform: rotate(-10deg); }
    45% { transform: rotate(5deg); }
    55% { transform: rotate(-5deg); }
    60% { transform: rotate(0deg); }
}

/* Responsive Media Queries */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        transition: var(--transition);
    }
    
    .chat-main {
        position: absolute;
        width: 100%;
        height: 100%;
        left: 100%;
        transition: var(--transition);
        z-index: 20;
    }
    
    .chat-app.show-chat .sidebar {
        transform: translateX(-100%);
    }
    
    .chat-app.show-chat .chat-main {
        left: 0;
    }
    
    .btn-back {
        display: block;
    }
    
    .message-bubble {
        max-width: 80%;
    }
}

/* Attachment & Image Bubble styling */
.btn-attachment {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    border-radius: 50%;
}
.btn-attachment:hover {
    color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
}

.bubble-image {
    padding: 4px !important;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    max-width: 280px !important;
}
.chat-image {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 12px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    display: block;
}
.chat-image:hover {
    opacity: 0.9;
}

/* Image Zoom Modal */
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity 0.3s ease;
}
.image-modal.show {
    display: block;
    opacity: 1;
}
.image-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}
.image-modal.show .image-modal-content {
    transform: scale(1);
}
.image-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10000;
}
.image-modal-close:hover,
.image-modal-close:focus {
    color: var(--primary);
    text-decoration: none;
}

/* Typing Indicator Animation */
.typing-indicator-text {
    color: var(--primary) !important;
    font-weight: 500;
    animation: pulseText 1.5s infinite ease-in-out;
}
@keyframes pulseText {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Image Caption Styling */
.chat-image-caption {
    padding: 8px 8px 4px 8px;
    font-size: 14.5px;
    color: var(--text-primary);
    line-height: 1.4;
    word-break: break-word;
    text-align: left;
}
