/* ============================================
   Curty.co WhatsApp Web - Premium Design System
   Black & Gold Theme with Animations
   ============================================ */

/* === CSS Reset & Base === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    /* Prevent scrollbars on the iframe window itself */
}

/* ... */

:root {
    /* Black Palette */
    --black-primary: #0a0a0a;
    --black-secondary: #121212;
    --black-tertiary: #1a1a1a;
    --black-elevated: #1f1f1f;
    --black-surface: #252525;

    /* Gold Palette */
    --gold-primary: #d4af37;
    --gold-light: #f4c430;
    --gold-bright: #ffd700;
    --gold-dark: #b8941f;

    /* Accent Colors */
    --white: #ffffff;
    --white-soft: #f5f5f5;
    --gray-light: #8b8b8b;
    --gray-medium: #5a5a5a;
    --success: #00d856;
    --online: #25d366;

    /* Shadows & Effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-gold: 0 4px 20px rgba(212, 175, 55, 0.3);
    --shadow-gold-hover: 0 6px 30px rgba(212, 175, 55, 0.5);

    /* Transitions */
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    --transition-slow: 0.5s ease;
}

body.light-theme {
    /* Palette swapping for Light Mode */
    --black-primary: #f0f2f5;
    --black-secondary: #ffffff;
    --black-tertiary: #ffffff;
    --black-elevated: #ffffff;
    --black-surface: #e5e5e5;

    --white: #111111;
    --white-soft: #333333;
    --gray-light: #666666;
    --gray-medium: #cccccc;

    --gold-primary: #d4af37;
    --gold-light: #f4c430;
    --gold-bright: #b8941f;
    --gold-dark: #8a6d1c;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.1);
}


body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--black-primary) 0%, var(--black-secondary) 100%);
    color: var(--white-soft);
    min-height: 100%;
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    line-height: 1.6;
    /* Crisper font rendering across browsers */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Smooth anchor/programmatic scrolling */
    scroll-behavior: smooth;
}

/* === Typography === */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.2;
}

/* === Main Container === */
.container {
    max-width: 1920px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.6s ease;
}

/* === Header === */
.header {
    background: var(--black-secondary);
    padding: 1.25rem 2rem;
    border-bottom: 1px solid rgba(212, 175, 55, 0.3);
    box-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
    overflow: hidden;
}



.header-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.logo {
    height: 56px;
    width: auto;
    filter: drop-shadow(0 0 6px rgba(212, 175, 55, 0.25));
}

.header-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold-primary) 50%, var(--gold-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.5px;
    animation: textShine 3s ease-in-out infinite;
}

.header-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    z-index: 1;
}

.menu-toggle {
    display: none;
    background: var(--black-elevated);
    border: 1px solid var(--gold-primary);
    color: var(--gold-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 1.25rem;
}

.menu-toggle:hover {
    background: var(--gold-primary);
    color: var(--black-primary);
    box-shadow: var(--shadow-gold-hover);
    transform: scale(1.05);
}

/* === Main Content === */
.main-content {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

/* === Sidebar === */
.sidebar {
    width: 30%;
    min-width: 280px;
    max-width: 400px;
    background: var(--black-secondary);
    border-right: 1px solid var(--gold-dark);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-medium);
    animation: slideInLeft 0.5s ease;
    position: relative;
}

.sidebar::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, transparent, var(--gold-primary), transparent);
    animation: borderPulse 2s ease-in-out infinite;
}

.search-container {
    padding: 1.25rem;
    background: var(--black-tertiary);
    border-bottom: 1px solid var(--gold-dark);
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 0.875rem 1rem 0.875rem 3rem;
    background: var(--black-elevated);
    border: 1px solid var(--gray-medium);
    border-radius: 12px;
    color: var(--white-soft);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1), var(--shadow-gold);
    transform: translateY(-2px);
}

.search-box::before {
    content: '';
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1rem;
}

/* === Chat List === */
.chat-list {
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-primary) var(--black-tertiary);
}

.chat-list::-webkit-scrollbar {
    width: 8px;
}

.chat-list::-webkit-scrollbar-track {
    background: var(--black-tertiary);
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--gold-primary);
    border-radius: 4px;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    background: var(--gold-bright);
}

.chat-item {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--black-elevated);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    gap: 1rem;
    align-items: center;
    position: relative;
    animation: fadeInUp 0.4s ease backwards;
}

.chat-item:nth-child(1) {
    animation-delay: 0.1s;
}

.chat-item:nth-child(2) {
    animation-delay: 0.15s;
}

.chat-item:nth-child(3) {
    animation-delay: 0.2s;
}

.chat-item:nth-child(4) {
    animation-delay: 0.25s;
}

.chat-item:nth-child(5) {
    animation-delay: 0.3s;
}

.chat-item:hover {
    background: var(--black-elevated);
    transform: translateX(5px);
}

.chat-item.active {
    background: linear-gradient(90deg, rgba(212, 175, 55, 0.1) 0%, transparent 100%);
    border-left: 3px solid var(--gold-primary);
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    flex-shrink: 0;
    box-shadow: var(--shadow-gold);
    position: relative;
    transition: all var(--transition-fast);
}

.chat-item:hover .chat-avatar {
    transform: scale(1.1);
    box-shadow: var(--shadow-gold-hover);
}

.chat-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--online);
    border: 2px solid var(--black-secondary);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.chat-info {
    flex: 1;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--white);
}

.chat-time {
    font-size: 0.75rem;
    color: var(--gray-light);
}

.chat-preview {
    font-size: 0.875rem;
    color: var(--gray-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-badge {
    background: var(--gold-primary);
    color: var(--black-primary);
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    box-shadow: var(--shadow-gold);
    animation: bounce 0.5s ease;
}

/* === Chat Area === */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--black-primary);
    position: relative;
    animation: fadeIn 0.5s ease;
}

.chat-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(212, 175, 55, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(212, 175, 55, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.chat-header-bar {
    background: var(--black-tertiary);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gold-dark);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    z-index: 1;
}

.current-chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold-primary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: var(--shadow-gold);
}

.current-chat-info h3 {
    color: var(--white);
    font-size: 1.1rem;
    margin-bottom: 0.125rem;
}

.current-chat-status {
    font-size: 0.875rem;
    color: var(--online);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.current-chat-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: var(--online);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

/* === Messages === */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-primary) var(--black-secondary);
    z-index: 1;
}

.messages-container::-webkit-scrollbar {
    width: 8px;
}

.messages-container::-webkit-scrollbar-track {
    background: var(--black-secondary);
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--gold-primary);
    border-radius: 4px;
}

.message {
    max-width: 65%;
    padding: 0.875rem 1.125rem;
    border-radius: 12px;
    position: relative;
    animation: messageSlideIn 0.3s ease backwards;
    word-wrap: break-word;
}

.message.sent {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-dark) 100%);
    color: var(--black-primary);
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-gold);
    margin-left: auto;
}

.message.received {
    align-self: flex-start;
    background: var(--black-elevated);
    color: var(--white-soft);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--black-surface);
}

.message-time {
    font-size: 0.7rem;
    margin-top: 0.375rem;
    opacity: 0.8;
    text-align: right;
}

.message.sent .message-time {
    color: var(--black-secondary);
}

.message.received .message-time {
    color: var(--gray-light);
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-self: flex-start;
    padding: 1rem 1.25rem;
    background: var(--black-elevated);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.typing-indicator.active {
    display: flex;
    gap: 0.375rem;
    animation: fadeIn 0.3s ease;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--gold-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* === Message Input === */
.message-input-container {
    background: var(--black-tertiary);
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--gold-dark);
    display: flex;
    gap: 1rem;
    align-items: center;
    box-shadow: var(--shadow-md);
    z-index: 1;
}

.message-input {
    flex: 1;
    padding: 1rem 1.25rem;
    background: var(--black-elevated);
    border: 1px solid var(--gray-medium);
    border-radius: 24px;
    color: var(--white-soft);
    font-size: 0.95rem;
    resize: none;
    font-family: inherit;
    transition: all var(--transition-fast);
    max-height: 120px;
}

.message-input:focus {
    outline: none;
    border-color: var(--gold-primary);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.1), var(--shadow-gold);
}

.send-button {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold-primary) 100%);
    border: none;
    border-radius: 50%;
    color: var(--black-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-gold);
    flex-shrink: 0;
}

.send-button:hover {
    transform: scale(1.1) rotate(15deg);
    box-shadow: var(--shadow-gold-hover);
}

.send-button:active {
    transform: scale(0.95) rotate(15deg);
}

/* === Animations === */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }

    to {
        transform: translateX(0);
    }
}



@keyframes logoGlow {
    from {
        filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.5));
    }

    to {
        filter: drop-shadow(0 0 20px rgba(212, 175, 55, 0.8));
    }
}

@keyframes textShine {

    0%,
    100% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(0.9);
    }
}

@keyframes borderPulse {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-10px);
    }
}

/* === Responsive Design === */

/* Tablet: 3-column grid, moderate card size */
@media (max-width: 1200px) and (min-width: 769px) {
    .desktop-container {
        grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
        grid-auto-rows: 180px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 35%;
        /* Slightly wider percent on medium screens */
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0.875rem 1rem;
    }

    .header-title {
        font-size: 1.25rem;
    }

    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: 85%;
        max-width: 350px;
        z-index: 100;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .message {
        max-width: 80%;
    }

    .message-input-container {
        padding: 1rem;
    }

    .messages-container {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.75rem;
    }

    .logo {
        height: 25px;
    }

    .header-title {
        font-size: 1rem;
    }

    .sidebar {
        width: 90%;
    }

    .search-container {
        padding: 1rem;
    }

    .chat-item {
        padding: 0.875rem 1rem;
    }

    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .message-input-container {
        padding: 0.875rem;
        gap: 0.5rem;
    }

    .send-button {
        width: 45px;
        height: 45px;
        font-size: 1.25rem;
    }
}

/* === QR Code Modal === */
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.3s ease;
}

.qr-modal.active {
    display: flex;
}

.qr-modal-content {
    background: var(--black-tertiary);
    border-radius: 16px;
    border: 2px solid var(--gold-primary);
    box-shadow: var(--shadow-gold-hover);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: messageSlideIn 0.3s ease;
}

.qr-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gold-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.qr-modal-header h2 {
    color: var(--gold-primary);
    font-size: 1.5rem;
    margin: 0;
}

.qr-close {
    background: transparent;
    border: none;
    color: var(--white-soft);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition-fast);
}

.qr-close:hover {
    background: var(--gold-primary);
    color: var(--black-primary);
    transform: scale(1.1);
}

.qr-modal-body {
    padding: 2rem;
}

.qr-code-container {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.qr-code-container img {
    max-width: 100%;
    height: auto;
}

.qr-loading {
    text-align: center;
    color: var(--black-primary);
}

.spinner {
    border: 4px solid var(--gray-light);
    border-top: 4px solid var(--gold-primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.qr-instructions {
    background: var(--black-elevated);
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--gold-dark);
}

.qr-instructions h3 {
    color: var(--gold-light);
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.qr-instructions ol {
    margin-left: 1.5rem;
    color: var(--white-soft);
}

.qr-instructions li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.qr-instructions strong {
    color: var(--gold-primary);
}

.qr-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--gold-dark);
    display: flex;
    justify-content: center;
}

.qr-refresh {
    padding: 0.875rem 2rem;
    background: linear-gradient(135deg, var(--gold-bright) 0%, var(--gold-primary) 100%);
    border: none;
    border-radius: 8px;
    color: var(--black-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-gold);
}

.qr-refresh:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-gold-hover);
}

/* === Connection Status === */
.connection-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--black-elevated);
    border: 1px solid var(--gold-primary);
    border-radius: 24px;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-gold);
    z-index: 999;
    animation: slideInRight 0.5s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--gray-medium);
    animation: pulse 2s ease-in-out infinite;
}

.connection-status.connected .status-indicator {
    background: var(--online);
}

.connection-status.disconnected .status-indicator {
    background: #ff4444;
}

.status-text {
    font-size: 0.875rem;
    color: var(--white-soft);
    font-weight: 500;
}

/* === Utility Classes === */
.hidden {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* === Empty State & Loading === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-light);
    font-size: 1.1rem;
    animation: fadeIn 0.5s ease;
}

.empty-state::before {
    content: '';
    font-size: 3rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 0 10px rgba(212, 175, 55, 0.3));
    animation: pulse 3s infinite ease-in-out;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--black-elevated);
    border-top: 3px solid var(--gold-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Home Chat Grid */
.home-chat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    padding: 2rem;
    width: 100%;
    max-width: 1200px;
}

.home-chat-card {
    background: rgba(30, 30, 30, 0.6);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
    backdrop-filter: blur(10px);
}

.home-chat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(212, 175, 55, 0.6);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    background: rgba(30, 30, 30, 0.8);
}

.home-chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #000;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.home-chat-info {
    overflow: hidden;
}

.home-chat-name {
    color: #ffd700;
    font-weight: 600;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.home-chat-preview {
    color: #aaa;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Message Sender Name */
.message-sender {
    font-size: 0.75rem;
    font-weight: bold;
    color: #d4af37;
    margin-bottom: 4px;
    display: block;
}

/* Force Chat Area Layout */
.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.message-input-container {
    flex-shrink: 0;
    background-color: #202c33;
    padding: 10px 16px;
}

/* Corrected Chat Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: 100%;
}

.chat-area {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
}

/* === Desktop Interface (Cards) === */
.desktop-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Leave space for taskbar */
    padding: 20px 20px 100px 20px;
    z-index: 10;
    background: radial-gradient(circle at center, var(--black-secondary) 0%, var(--black-primary) 100%);

    /* Grid Layout */
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-rows: 200px;
    gap: 20px;
    align-content: start;
    overflow-y: auto;
}

.desktop-background-text {
    display: none;
    /* Removed — cleaner look */
}

.chat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    /* Very subtle glass */
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    position: relative;
    user-select: none;
}

.chat-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--gold-primary);
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.chat-card {
    will-change: transform;
    /* hint GPU to composite this layer */
}

.chat-card .card-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gold-primary);
    color: var(--black-primary);
    font-size: 1.6rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    border: 2px solid var(--black-secondary);
    margin-bottom: 12px;
}

/* Real profile picture from /chats/overview */
.chat-card .card-avatar-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--gold-primary);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    margin-bottom: 12px;
}

.chat-card .card-name {
    color: var(--white);
    font-weight: 600;
    font-size: 1rem;
    text-align: center;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.chat-card .card-preview {
    color: var(--gray-light);
    font-size: 0.8rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.card-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
    border-radius: 50%;
    min-width: 26px;
    height: 26px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    box-shadow: 0 0 0 3px rgba(20, 20, 20, 0.9), 0 0 12px rgba(255, 65, 108, 0.6);
    z-index: 10;
    animation: badgePop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards,
               badgePulseGlow 2s ease-in-out 0.35s infinite;
}

/* Card glow when a new message arrives */
.chat-card.has-notification {
    border-color: rgba(255, 65, 108, 0.6);
    box-shadow: 0 0 0 2px rgba(255, 65, 108, 0.25),
                0 0 20px rgba(255, 65, 108, 0.2);
    animation: cardNewMsg 0.6s ease forwards;
}

@keyframes cardNewMsg {
    0%   { transform: translateY(0) scale(1); }
    20%  { transform: translateY(-8px) scale(1.04); }
    40%  { transform: translateY(-4px) scale(1.02); }
    60%  { transform: translateY(-6px) scale(1.03); }
    80%  { transform: translateY(-2px) scale(1.01); }
    100% { transform: translateY(-5px) scale(1); }
}

@keyframes badgePop {
    0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
    70%  { transform: scale(1.25) rotate(5deg);  opacity: 1; }
    100% { transform: scale(1)    rotate(0deg);  opacity: 1; }
}

@keyframes badgePulseGlow {
    0%, 100% { box-shadow: 0 0 0 3px rgba(20,20,20,0.9), 0 0 10px rgba(255,65,108,0.5); }
    50%       { box-shadow: 0 0 0 3px rgba(20,20,20,0.9), 0 0 22px rgba(255,65,108,0.9); }
}

/* Taskbar notification badge for minimized / background windows */
.taskbar-item .taskbar-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ff416c 0%, #ff4b2b 100%);
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    padding: 0 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    box-shadow: 0 0 0 2px rgba(20,20,20,0.9), 0 0 8px rgba(255,65,108,0.6);
    z-index: 10;
    animation: badgePop 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

/* Taskbar item attention shake when a new message arrives */
@keyframes taskbarAttention {
    0%,100% { transform: translateY(-5px) scale(1.1) rotate(0deg); }
    20%      { transform: translateY(-5px) scale(1.1) rotate(-8deg); }
    40%      { transform: translateY(-5px) scale(1.1) rotate(8deg); }
    60%      { transform: translateY(-5px) scale(1.1) rotate(-4deg); }
    80%      { transform: translateY(-5px) scale(1.1) rotate(4deg); }
}

.taskbar-item.has-notification {
    animation: taskbarAttention 0.5s ease;
}

/* === Chat Overlay === */
.chat-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: flex;
    visibility: hidden;
    opacity: 0;
    transition: visibility 0.3s, opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.chat-overlay.active {
    visibility: visible;
    opacity: 1;
}

.chat-overlay .chat-area {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    height: 100%;
    background: var(--black-secondary);
    border-left: 1px solid var(--gold-dark);
    border-right: 1px solid var(--gold-dark);
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    transform: translateY(100px);
    transition: transform 0.4s cubic-bezier(0.19, 1, 0.22, 1);
}

.chat-overlay.active .chat-area {
    transform: translateY(0);
}

.close-chat-btn {
    position: absolute;
    top: 20px;
    right: 30px;
    background: none;
    border: none;
    color: var(--gold-primary);
    font-size: 2rem;
    cursor: pointer;
    z-index: 1001;
    transition: transform 0.2s ease, color 0.2s ease;
}

.close-chat-btn:hover {
    transform: scale(1.1) rotate(90deg);
    color: var(--white);
}

/* Hide original sidebar elements in bubble mode */
.bubble-mode .sidebar,
.bubble-mode .search-container {
    display: none !important;
}

/* =========================================
   OS Interface Styles
   ========================================= */

/* Use a clean desktop wallpaper feel for body if desired, but keeping current gradient is fine */

/* === Taskbar === */
.os-taskbar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid rgba(212, 175, 55, 0.2);
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    gap: 12px;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
    min-width: 100px;
    /* Ensure visibility */
    height: 64px;
    align-items: center;
}

.os-taskbar:hover {
    border-color: rgba(212, 175, 55, 0.5);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

.taskbar-item {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-size: cover;
    background-position: center;
    border: 2px solid transparent;
}

.taskbar-item:hover {
    transform: translateY(-5px) scale(1.1);
}

.taskbar-item.active {
    border-color: var(--gold-primary);
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.taskbar-item.minimized {
    opacity: 0.7;
    filter: grayscale(0.5);
}

.taskbar-item::after {
    /* Active indicator dot */
    content: '';
    position: absolute;
    bottom: -6px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: var(--gold-primary);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.3s;
}

.taskbar-item.open::after {
    opacity: 1;
}


/* === Windows Container === */
#windowsContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 100;
    /* Ensure it sits above desktop icons but below overlay */
    overflow: hidden;
    /* Prevent windows from causing scrollbars */
}

/* === Windows === */
.os-window {
    pointer-events: auto;
    /* Re-enable clicks for windows */
    position: absolute;
    top: 100px;
    left: 100px;
    width: clamp(320px, 40vw, 500px);
    height: clamp(400px, 60vh, 700px);
    background: var(--black-secondary);
    border: 1px solid var(--gold-dark);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    resize: both;
    /* Allow resizing if browser supports */
    min-width: 320px;
    min-height: 400px;
    animation: openWindow 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    will-change: transform, width, height;
}

@keyframes openWindow {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.os-window.active {
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8), 0 0 0 1px var(--gold-primary);
    z-index: 100 !important;
    /* Managed by JS, but default high */
}

.window-header {
    height: 40px;
    background: linear-gradient(to right, var(--black-elevated), var(--black-tertiary));
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    cursor: grab;
    user-select: none;
}

.window-header:active {
    cursor: grabbing;
}

.window-title {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--gold-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.window-icon {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: var(--black-primary);
    border: 1px solid var(--gold-dark);
}

.window-controls {
    display: flex;
    gap: 6px;
}

.win-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--gray-light);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.win-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--white);
}

.win-btn.close:hover {
    background: #ff4444;
    color: white;
}

.window-content {
    flex: 1;
    background: var(--black-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Ensure inner chat areas fit perfectly */
.window-content .chat-area {
    height: 100%;
}

/* Remove fixed positioning from chat overlay styles if they conflict */
/* Actually we reused .chat-area but it's flex:1 inside window-content so it should be fine */

/* Minimize Animation */
.os-window.minimizing {
    transition: all 0.3s ease;
    opacity: 0;
    transform: scale(0.5) translateY(200px);
    pointer-events: none;
}

/* === Mobile Window Overrides === */
@media (max-width: 768px) {

    /* Full screen windows on mobile */
    .os-window {
        width: 100% !important;
        height: 100% !important;
        top: 0 !important;
        left: 0 !important;
        /* ... */
        border-radius: 0 !important;
        border: none !important;
        resize: none !important;
        box-shadow: none !important;
        animation: slideUpWindow 0.3s ease-out;
    }

    @keyframes slideUpWindow {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .os-window.maximized {
        /* Already handled by base style above, but ensure it */
        width: 100% !important;
        height: 100% !important;
    }

    .window-header {
        height: 50px;
        /* Taller header for touch */
        background: var(--black-elevated);
    }

    .window-title {
        font-size: 1rem;
    }

    /* Hide minimize/maximize on mobile, they don't make sense */
    .win-btn.minimize,
    .win-btn.maximize {
        display: none;
    }

    .win-btn.close {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
        background: rgba(255, 0, 0, 0.1);
        color: #ff4444;
    }

    /* Adjust desktop grid for mobile */
    .desktop-container {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        grid-auto-rows: 150px;
        gap: 12px;
        padding: 15px 15px 80px 15px;
    }

    .chat-card {
        padding: 8px;
    }

    .chat-card .card-avatar {
        width: 45px;
        height: 45px;
        font-size: 1rem;
    }

    .chat-card .card-name {
        font-size: 0.8rem;
    }

    .chat-card .card-preview {
        font-size: 0.7rem;
    }

    .desktop-background-text {
        font-size: 20vw;
    }
}
/* === Real-time Robustness Extras === */
.message-ticks {
    margin-left: 5px;
    font-size: 0.8rem;
    color: var(--gray-light);
    display: inline-block;
    vertical-align: middle;
}
.message-ticks.sent { color: var(--gray-light); }
.message-ticks.delivered { color: var(--gray-light); }
.message-ticks.read { color: #34b7f1; }
.card-typing { font-size: 0.75rem; color: var(--success); font-style: italic; animation: pulse 1.5s infinite; }
.window-status { font-size: 0.75rem; margin-left: 8px; transition: all 0.3s; }
.card-badge { animation: badgePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes badgePop { 0% { transform: scale(0); } 100% { transform: scale(1); } }

/* === Comprehensive Media Support === */
.message.is-sticker {
    background: none !important;
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
}
.message-sticker-container img {
    max-width: 160px !important;
    border-radius: 0 !important;
}
.message-video-container video,
.message-image-container img {
    display: block;
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    background-color: rgba(255, 255, 255, 0.05);
    background-repeat: no-repeat;
    background-position: center;
    background-size: cover;
    min-width: 200px;
    min-height: 150px;
}
.message-audio-container audio {
    max-width: 100%;
    height: 36px;
    filter: brightness(0.9);
}
.message-document-container {
    transition: background var(--transition-fast);
}
.message-document-container:hover {
    background: rgba(255, 255, 255, 0.15) !important;
}
.message.sent .message-document-container {
    background: rgba(0, 0, 0, 0.1) !important;
}
.message.sent .doc-name {
    color: var(--black-primary) !important;
}
.message.sent .doc-size {
    color: rgba(0, 0, 0, 0.6) !important;
}
