:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: rgba(79, 70, 229, 0.1);
    --bg-main: #ffffff;
    --bg-card: #ffffff;
    --bg-sidebar: #ffffff;
    --text-main: #000000;
    --text-muted: #666666;
    --border-color: #eeeeee;
    --chat-received: #f2f2f2;
    --chat-sent: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);
    --sidebar-width: 350px;
}

[data-theme="dark"] {
    --bg-main: #000000;
    --bg-card: #0a0a0a;
    --bg-sidebar: #000000;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --border-color: #1a1a1a;
    --chat-received: #1a1a1a;
    --chat-sent: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.8);
}

* {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow-x: hidden;
}

[data-theme="dark"] body {
    background-color: #000000 !important;
    color: #ffffff !important;
}

h1,
h2,
h3,
h4,
h5,
h6,
.navbar-brand,
.outfit {
    font-family: 'Outfit', sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #E5E7EB;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #D1D5DB;
}

/* Glassmorphism Navbar & Header */
.glass-nav,
.chat-header {
    background: var(--bg-card) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color) !important;
}

.hover-scale {
    transition: transform 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.05);
}

.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
}

.text-primary {
    color: var(--primary) !important;
}

/* Auth Cards */
.auth-card {
    border-radius: 1.5rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    background: white;
    overflow: hidden;
}

.auth-form-control {
    border-radius: 0.75rem;
    padding: 0.75rem 1.25rem;
    border: 1px solid #E5E7EB;
    background-color: #F9FAFB;
    transition: all 0.2s;
}

.auth-form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
    background-color: white;
}

/* Animations */
.drop-in {
    animation: dropIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

.slide-up {
    animation: slideUp 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) 0.2s both;
}

.fade-in {
    animation: fadeIn 0.8s ease 0.4s both;
}

@keyframes dropIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes msgAppear {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(5px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.chat-bubble {
    animation: msgAppear 0.2s ease-out backwards;
}

/* Chat Layout */
.chat-container {
    height: 100vh;
    display: flex;
    overflow: hidden;
    background-color: var(--bg-color);
}

.sidebar-left,
.sidebar-right {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.sidebar-right {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.modern-sidebar {
    background-color: var(--bg-sidebar);
}

.bg-primary-light {
    background-color: rgba(79, 70, 229, 0.1);
}

.rounded-end-4 {
    border-top-right-radius: 1rem !important;
    border-bottom-right-radius: 1rem !important;
}

.rounded-start-4 {
    border-top-left-radius: 1rem !important;
    border-bottom-left-radius: 1rem !important;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    position: relative;
}

.chat-header {
    padding: 1.1rem 1.5rem;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color) !important;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 1000;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    background-color: #e5ddd5;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    /* Classic WhatsApp pattern */
    background-repeat: repeat;
    background-attachment: local;
}

[data-theme="dark"] .chat-messages {
    background-color: #0b141a;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    filter: invert(1) opacity(0.05);
    /* Invert pattern for dark mode */
}


.chat-input-area {
    padding: 1.25rem 2rem;
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border-color);
    z-index: 1000;
}

.chat-bubble {
    max-width: 75%;
    padding: 0.9rem 1.3rem;
    border-radius: 1.25rem;
    margin-bottom: 1.5rem;
    margin-top: 0.5rem;
    position: relative;
    clear: both;
    font-size: 0.95rem;
    line-height: 1.5;
    word-break: break-word;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.chat-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}

.chat-bubble.sent {
    background: var(--chat-sent);
    color: white;
    float: right;
    border-bottom-right-radius: 4px;
}

.chat-bubble.received {
    background-color: var(--chat-received);
    color: var(--text-main);
    float: left;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.chat-bubble .timestamp {
    display: block;
    font-size: 0.75rem;
    margin-top: 6px;
    opacity: 0.8;
    text-align: right;
}

.chat-bubble.sent .timestamp {
    color: rgba(255, 255, 255, 0.8);
}

.search-box {
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.75rem 1.25rem;
    color: var(--text-main);
}

.search-box:focus {
    background-color: var(--bg-card);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.friend-item {
    padding: 1rem 1.25rem;
    transition: all 0.2s ease;
    cursor: pointer;
    border-radius: 1rem;
    margin: 0.25rem 0.75rem;
    display: flex;
    align-items: center;
    border: 1px solid transparent;
}

.friend-item:hover {
    background-color: var(--bg-main);
    border-color: var(--border-color);
}

.friend-item.active {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

.sidebar-left h6,
.sidebar-right h6 {
    font-family: 'Outfit', sans-serif;
    letter-spacing: 0.5px;
    font-weight: 700 !important;
}

.avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.avatar-lg {
    width: 96px;
    height: 96px;
    border-radius: 50%;
}

.avatar-wrapper {
    position: relative;
    display: inline-block;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    bottom: 2px;
    right: 2px;
}

.status-online {
    background-color: #10B981;
}

.status-offline {
    background-color: #9CA3AF;
}

.chat-input {
    border-radius: 2rem;
    padding: 0.75rem 1.25rem;
    border: 1px solid var(--border-color);
    background-color: var(--bg-main);
    color: var(--text-main);
}

.chat-input:focus {
    box-shadow: none;
    border-color: var(--primary);
    background-color: var(--bg-card);
}

/* Mobile Responsive Adjustments */
@media (max-width: 768px) {
    .chat-container {
        position: relative;
    }

    .sidebar-left,
    .sidebar-right {
        position: absolute;
        top: 0;
        height: 100vh;
        width: 100%;
        max-width: 100%;
        z-index: 1030;
        transition: transform 0.3s ease-in-out;
        background: white;
    }

    .sidebar-left {
        left: 0;
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.1);
    }

    .sidebar-right {
        right: 0;
        transform: translateX(100%);
        box-shadow: -20px 0 50px rgba(0, 0, 0, 0.1);
    }

    .chat-container.chat-opened .sidebar-left {
        transform: translateX(-100%);
    }

    .chat-container.requests-opened .sidebar-right {
        transform: translateX(0);
    }

    .chat-main {
        width: 100%;
        position: absolute;
        height: 100vh;
        left: 0;
        top: 0;
    }
}

/* Bell Shake Animation */
@keyframes shakeBell {
    0% {
        transform: rotate(0);
    }

    10% {
        transform: rotate(14deg);
    }

    20% {
        transform: rotate(-8deg);
    }

    30% {
        transform: rotate(14deg);
    }

    40% {
        transform: rotate(-4deg);
    }

    50% {
        transform: rotate(10deg);
    }

    60% {
        transform: rotate(0);
    }

    100% {
        transform: rotate(0);
    }
}

.shake-animation i {
    animation: shakeBell 0.8s cubic-bezier(.36, .07, .19, .97) both;
    display: inline-block;
}

.badge-notify {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #EF4444;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Profile Settings Premium Styles */
.clickable-username:hover {
    color: var(--primary-color);
    transition: color 0.2s ease;
}

#profileSettingsModal .modal-content {
    background: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
}

.profile-pic-setup img {
    border: 4px solid white;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.profile-pic-setup:hover img {
    transform: scale(1.05);
}

#profileSettingsModal .form-control:focus {
    background-color: white !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

#saveProfileBtn {
    transition: all 0.3s ease;
}

#saveProfileBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
}

.font-size-sm {
    font-size: 0.875rem;
}

.btn-xs {
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
}

/* Stories Styles */
.stories-container {
    background: var(--bg-sidebar);
    scrollbar-width: none;
}

.stories-container::-webkit-scrollbar {
    display: none;
}

.story-item {
    min-width: 65px;
    cursor: pointer;
    transition: transform 0.2s;
}

.story-item:hover {
    transform: scale(1.05);
}

/* Theme Toggle Switch */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
}

/* Premium Theme Switch */
.theme-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 30px;
}

.theme-switch input {
    display: none !important;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: .4s;
    border-radius: 34px;
    display: flex;
    align-items: center;
    padding: 0 6px;
    justify-content: space-between;
}

.slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(30px);
}

.slider i {
    font-size: 12px;
    z-index: 1;
}

.slider .fa-sun {
    color: #f59e0b;
}

.slider .fa-moon {
    color: #94a3b8;
}

/* Premium Action Sheet (Attachment Menu) */
.action-sheet .modal-content {
    border-radius: 1.5rem !important;
}

.action-sheet .list-group-item {
    transition: all 0.2s ease;
    cursor: pointer;
}

.action-sheet .list-group-item:hover {
    background-color: var(--bg-main) !important;
    transform: translateY(-2px);
}

.action-sheet i {
    font-size: 1.2rem;
    width: 30px;
}

[data-theme="dark"] .action-sheet .list-group-item:hover {
    background-color: #111 !important;
}

.hover-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.location-link-click:hover .hover-overlay {
    opacity: 1;
}

/* Shake animation for new friend request notification */
.shake-animation {
    animation: shake 0.6s cubic-bezier(.36, .07, .19, .97) both;
}

@keyframes shake {

    10%,
    90% {
        transform: rotate(-8deg);
    }

    20%,
    80% {
        transform: rotate(8deg);
    }

    30%,
    50%,
    70% {
        transform: rotate(-6deg);
    }

    40%,
    60% {
        transform: rotate(6deg);
    }
}

/* WhatsApp Style Unread Divider */
.whatsapp-unread-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin: 25px 0;
    pointer-events: none;
}

.whatsapp-unread-divider .line {
    flex-grow: 1;
    height: 1px;
    background-color: rgba(0, 0, 0, 0.08);
}

.whatsapp-unread-divider .unread-badge {
    background: #ffffff;
    padding: 6px 18px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #667781;
    text-transform: uppercase;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    letter-spacing: 0.8px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.unread-highlight.received {
    background-color: #f0f7ff !important;
    border-color: #e1effe !important;
}

/* Tick Status Colors */
.text-info {
    color: #34B7F1 !important;
    /* Read */
}

.text-muted {
    color: #8696a0 !important;
    /* Sent/Delivered */
}

/* Message Entry Animation */
.message-bounce {
    animation: bubble-bounce 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bubble-bounce {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

#newMessageAlert {
    animation: slide-up 0.5s ease-out;
}

@keyframes slide-up {
    from {
        transform: translate(-50%, 50px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* Chat Input Area Adjustments */
.chat-input-area {
    padding: 1.5rem;
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
}

.chat-input {
    border-radius: 100px !important;
    border: 1px solid var(--border-color) !important;
    padding: 0.75rem 1.5rem !important;
}

[data-theme="dark"] .slider .fa-moon {
    color: #f1f5f9;
}

/* Dashboard UI Fixes for Themes */
/* Force Full Black Theme on EVERYTHING */
[data-theme="dark"] {
    background-color: #000000 !important;
    color: #ffffff !important;
}

[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body,
[data-theme="dark"] .modal-footer {
    background-color: #000000 !important;
    color: #ffffff !important;
    border-color: #222 !important;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6,
[data-theme="dark"] span,
[data-theme="dark"] label,
[data-theme="dark"] p,
[data-theme="dark"] div:not(.btn):not(.badge) {
    color: #ffffff !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] small {
    color: #aaaaaa !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-panel,
[data-theme="dark"] .bg-light,
[data-theme="dark"] .modern-sidebar,
[data-theme="dark"] .sticky-top,
[data-theme="dark"] .chat-header {
    background-color: #000000 !important;
    background: #000000 !important;
    border-color: #111 !important;
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .chat-input,
[data-theme="dark"] .search-box,
[data-theme="dark"] .list-group-item {
    background-color: #0a0a0a !important;
    color: #ffffff !important;
    border-color: #222 !important;
}

[data-theme="dark"] .list-group-item:hover {
    background-color: #111 !important;
}

[data-theme="dark"] .btn-light {
    background-color: #111 !important;
    color: #ffffff !important;
    border-color: #222 !important;
}

[data-theme="dark"] .border,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-top {
    border-color: #222 !important;
}

[data-theme="dark"] ::placeholder {
    color: #666 !important;
}

[data-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}


.story-avatar-wrapper,
.story-avatar-wrapper.has-stories {
    width: 58px;
    height: 58px;
    padding: 3px;
    border-radius: 50%;
    border: 2px solid #25D366;
    /* WhatsApp Green */
    margin: 0 auto 5px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-avatar-wrapper.add-story {
    border-color: #E5E7EB;
}

.story-avatar-wrapper.viewed {
    border-color: #9CA3AF;
}

.story-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--bg-card);
}

.add-story-icon {
    position: absolute;
    bottom: 0;
    right: 0;
    background: #25D366;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-card);
}

.story-name {
    font-size: 0.75rem;
    display: block;
    color: var(--text-muted);
    width: 65px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.story-viewer-modal .modal-content {
    border-radius: 0;
}

.story-progress-container {
    gap: 4px;
}

.story-progress-bar {
    height: 2px;
    flex-grow: 1;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.story-progress-fill {
    height: 100%;
    background: white;
    width: 0%;
    transition: width linear;
}

/* Voice Recording UI */
#recordingUI {
    transition: all 0.3s ease;
    animation: slideInBottom 0.3s ease-out;
    border: 1px solid var(--border-color);
}

@keyframes slideInBottom {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.recording-dot {
    width: 12px;
    height: 12px;
    background-color: #ef4444;
    border-radius: 50%;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.3);
        opacity: 0.5;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Audio Player in Chat Bubble */
.audio-message-container {
    padding: 10px;
    min-width: 234px;
}

.audio-message-container audio {
    height: 35px;
    width: 100%;
}

[data-theme="dark"] audio::-webkit-media-controls-panel {
    background-color: hsl(0, 2%, 50%);
}

[data-theme="dark"] audio::-webkit-media-controls-current-time-display,
[data-theme="dark"] audio::-webkit-media-controls-time-remaining-display {
    color: #ffffff;
}

/* Hide Audio Download and Three Dots */
audio::-webkit-media-controls-download-button,
audio::-webkit-media-controls-overflow-button {
    display: none !important;
}

/* Voice Call Styles */
.avatar-xl {
    width: 120px;
    height: 120px;
}

.call-modal-bg {
    background: radial-gradient(circle at top, #ffffff 0%, #f8fafc 100%);
}

[data-theme="dark"] .call-modal-bg {
    background: radial-gradient(circle at top, #1a1a1a 0%, #000000 100%);
}

.pulse-ring {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: var(--primary-soft);
    animation: pulse 2s infinite;
    z-index: -1;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0.7;
    }

    70% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0;
    }

    100% {
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
    }
}

.call-action-btn {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.call-action-btn:hover {
    transform: scale(1.1);
}

.call-status {
    letter-spacing: 1px;
    font-weight: 500;
}

.shake-phone {
    animation: shakePhone 0.5s infinite;
}

@keyframes shakePhone {

    0%,
    100% {
        transform: rotate(0);
    }

    25% {
        transform: rotate(10deg);
    }

    75% {
        transform: rotate(-10deg);
    }
}