@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@200;300;400;600;700&display=swap');

:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #6366f1;
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);

    --bubble-out: linear-gradient(135deg, #059669, #10b981);
    --bubble-in: #334155;

    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    outline: none;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

a {
    text-decoration: none;
    color: inherit;
}

/* Layout */
/* Layout & Sidebar */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(10px);
    border-right: var(--glass-border);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    /* Sticky sidebar on desktop */
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    text-align: center;
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    flex: 1;
}

.nav-item {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: transparent;
    transition: 0.3s;
    cursor: pointer;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-icon {
    width: 20px;
    height: 20px;
    stroke-width: 2.5;
}

.nav-item:hover,
.nav-item.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

.nav-item.logout {
    margin-top: auto;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.nav-item.logout:hover {
    background: #ef4444;
    color: white;
}

.main-content {
    flex: 1;
    padding: 2rem;
    position: relative;
    overflow-y: auto;
    height: 100vh;
}

/* Mobile Bottom Navigation */
@media (max-width: 768px) {
    .admin-layout {
        flex-direction: column;
        min-height: auto;
        /* Allow scrolling content */
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        flex-direction: row;
        padding: 0.8rem 1.5rem;
        gap: 0;
        z-index: 1000;
        background: rgba(15, 23, 42, 0.95);
        border-right: none;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.3);
    }

    .brand {
        display: none;
    }

    .nav-links {
        flex-direction: row;
        justify-content: space-around;
        align-items: center;
        width: 100%;
    }

    .nav-item {
        flex-direction: column;
        padding: 0.5rem;
        font-size: 0.65rem;
        justify-content: center;
        border-radius: 12px;
        gap: 4px;
        color: var(--text-muted);
        flex: 1;
        /* Distribute space */
        text-align: center;
    }

    .nav-item:hover {
        background: transparent;
        color: var(--text-primary);
    }

    .nav-item.active {
        background: transparent;
        color: var(--accent);
        box-shadow: none;
    }

    .nav-item.active .nav-icon {
        filter: drop-shadow(0 0 8px var(--accent));
    }

    .nav-icon {
        width: 24px;
        height: 24px;
        margin: 0;
    }

    .nav-item.logout {
        margin-top: 0;
        background: transparent;
        color: var(--text-muted);
    }

    .nav-item.logout:hover {
        background: transparent;
        color: #ef4444;
    }

    .main-content {
        padding: 1rem 1rem 100px 1rem;
        /* Space for bottom bar and compact side padding */
        height: auto;
        min-height: 100vh;
        overflow-y: visible;
        /* Let body scroll? Or keep container scroll */
    }

    /* Ensure body scrolls nicely */
    body {
        overflow-y: auto;
    }
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: var(--glass-border);
}

h1 {
    font-size: 1.8rem;
}

/* Cards & Lists */
.card {
    background: var(--card-bg);
    border: var(--glass-border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--glass-shadow);
}

.chat-list,
.user-list {
    display: grid;
    gap: 1rem;
}

.chat-item,
.user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.user-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    background-color: var(--bg-dark);
    /* fallback for transparent imgs */
}

/* Hover effect for the card affects the avatar */
.user-item:hover .user-avatar {
    transform: scale(1.1);
    border-color: var(--accent);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.4);
}

/* Chat Messages Area - FIXED */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
}

/* New Chat Bubbles (Restored from previous step) */
.message-row {
    display: flex;
    margin-bottom: 1rem;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
}

.message-row.right {
    flex-direction: row-reverse;
}

.message-row.left {
    flex-direction: row;
}

.avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background-color: #555;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.message-bubble {
    max-width: 60%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Right Bubble (Greenish) */
.message-row.right .message-bubble {
    background: var(--bubble-out);
    color: white;
    border-bottom-right-radius: 2px;
}

/* Left Bubble (Gray) */
.message-row.left .message-bubble {
    background: var(--bubble-in);
    color: #f1f5f9;
    border-bottom-left-radius: 2px;
}

.sender-name {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
    opacity: 0.9;
    font-weight: 600;
}

.message-row.right .sender-name {
    text-align: right;
    color: #a7f3d0;
}

.message-row.left .sender-name {
    text-align: left;
    color: #94a3b8;
}

.timestamp {
    font-size: 0.65rem;
    text-align: right;
    margin-top: 0.4rem;
    opacity: 0.7;
}

.chat-media {
    max-width: 100%;
    border-radius: 8px;
    margin-top: 5px;
    display: block;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Login */
/* Login Modern Redesign */
.login-body {
    background-color: #0f172a;
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
}

/* Floating background blobs */
.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.6;
    animation: blob-bounce 10s infinite ease-in-out alternate;
    z-index: 0;
}

.blob-1 {
    width: 300px;
    height: 300px;
    background: #6366f1;
    top: -50px;
    left: -50px;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: #ec4899;
    bottom: -100px;
    right: -100px;
    animation-delay: -5s;
}

@keyframes blob-bounce {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(20px, -20px) scale(1.1);
    }
}

.login-card {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 3rem;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    z-index: 1;
    text-align: center;
    animation: fade-in-up 0.8s ease-out;
}

@keyframes fade-in-up {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-logo {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.5);
}

.login-logo svg {
    width: 40px;
    height: 40px;
    fill: white;
}

.login-title {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.login-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    /* Space for icon if any */
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-family: inherit;
    transition: 0.3s;
}

.login-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    background: rgba(15, 23, 42, 0.8);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: 0.3s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
}

.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.4);
}

.login-btn:active {
    transform: translateY(0);
}

.login-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-size: 0.9rem;
}

/* Search Bar */
.search-bar {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: var(--glass-border);
    border-radius: 12px;
    color: white;
    margin-bottom: 2rem;
}