/* ================================================
   YOUTH REMOTE – Global Stylesheet
   Clean, Professional Design System
   ================================================ */

/* ---------- CSS Reset & Base ---------- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Primary – Emerald */
    --primary: #10B981;
    --primary-dark: #059669;
    --primary-light: #34D399;
    --primary-bg: rgba(16, 185, 129, 0.08);

    /* Accent – Amber */
    --accent: #F59E0B;
    --accent-dark: #D97706;
    --accent-light: #FCD34D;

    /* Success */
    --success: #10B981;
    --success-bg: rgba(16, 185, 129, 0.1);

    /* Warnings */
    --warning: #F59E0B;
    --warning-bg: rgba(245, 158, 11, 0.1);

    /* Neutral Palette */
    --dark: #111827;
    --dark-2: #0F172A;
    --gray-900: #111827;
    --gray-800: #1F2937;
    --gray-700: #374151;
    --gray-600: #6b7280;
    --gray-500: #9ca3af;
    --gray-400: #d1d5db;
    --gray-300: #e5e7eb;
    --gray-200: #f3f4f6;
    --gray-100: #f9fafb;
    --white: #ffffff;

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #10B981 0%, #059669 100%);
    --gradient-hero: linear-gradient(135deg, #0F172A 0%, #111827 100%);
    --gradient-warm: linear-gradient(135deg, #F59E0B 0%, #F97316 100%);
    --gradient-cool: linear-gradient(135deg, #0EA5E9 0%, #0284C7 100%);
    --gradient-dark: linear-gradient(135deg, #0F172A 0%, #111827 100%);

    /* Typography */
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;
    --space-4xl: 96px;

    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
    --shadow-xl: 0 16px 48px rgba(0,0,0,0.16);
    --shadow-glow: 0 0 40px rgba(16, 185, 129, 0.2);
    --shadow-card: 0 2px 16px rgba(0,0,0,0.06);
    --shadow-card-hover: 0 8px 30px rgba(0,0,0,0.12);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
    --transition-spring: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Container */
    --container-max: 1200px;
    --container-narrow: 800px;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-main);
    color: var(--gray-900);
    background: var(--gray-100);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--primary-dark);
}

img {
    max-width: 100%;
    height: auto;
}

ul, ol {
    list-style: none;
}

/* ---------- Typography ---------- */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: 1.2;
    color: var(--dark);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h3 { font-size: clamp(1.25rem, 2.5vw, 1.75rem); }
h4 { font-size: 1.25rem; }

p {
    color: var(--gray-600);
    line-height: 1.7;
}

/* ---------- Container ---------- */
.container {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

.container-narrow {
    max-width: var(--container-narrow);
    margin: 0 auto;
    padding: 0 var(--space-lg);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
}

.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.2), transparent);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.btn:hover::after {
    opacity: 1;
}

.btn-primary {
    background: var(--gradient-primary);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.45);
    color: var(--white);
}

.btn-secondary {
    background: var(--white);
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

.btn-dark {
    background: var(--dark);
    color: var(--white);
}

.btn-dark:hover {
    background: var(--gray-800);
    transform: translateY(-2px);
}

.btn-accent {
    background: var(--accent);
    color: var(--white);
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.35);
}

.btn-accent:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
    color: var(--white);
}

.btn-ghost {
    background: transparent;
    color: var(--gray-700);
    padding: 10px 20px;
}

.btn-ghost:hover {
    background: var(--gray-200);
    color: var(--dark);
}

.btn-sm {
    padding: 8px 18px;
    font-size: 0.85rem;
}

.btn-lg {
    padding: 16px 36px;
    font-size: 1.1rem;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-md);
}

/* ---------- Cards ---------- */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: all var(--transition-base);
    border: 1px solid rgba(0,0,0,0.04);
}

.card:hover {
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-4px);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
    letter-spacing: 0.02em;
}

.badge-primary {
    background: var(--primary-bg);
    color: var(--primary);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-accent {
    background: rgba(255, 107, 107, 0.1);
    color: var(--accent);
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: var(--space-lg);
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: var(--space-sm);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font-main);
    font-size: 0.95rem;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--dark);
    transition: all var(--transition-fast);
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-bg);
}

.form-input::placeholder {
    color: var(--gray-500);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

/* ---------- Flash Messages ---------- */
.flash-messages {
    position: fixed;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: max-content;
    max-width: min(480px, 92vw);
    pointer-events: none;
}

.flash-message {
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    animation: slideInDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(10px);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    pointer-events: all;
    text-align: center;
}

.flash-message.success {
    background: rgba(46, 213, 115, 0.95);
    color: white;
}

.flash-message.error {
    background: rgba(255, 107, 107, 0.95);
    color: white;
}

.flash-message.info {
    background: rgba(108, 99, 255, 0.95);
    color: white;
}

/* ---------- Section Styles ---------- */
.section {
    padding: var(--space-4xl) 0;
}

.section-header {
    text-align: center;
    margin-bottom: var(--space-3xl);
}

.section-header h2 {
    margin-bottom: var(--space-md);
}

.section-header p {
    max-width: 600px;
    margin: 0 auto;
    font-size: 1.1rem;
}

.section-label {
    display: inline-block;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--space-sm);
}

/* ---------- Navbar ---------- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 16px 0;
    transition: all var(--transition-base);
    background: rgba(255, 255, 255, 0.0);
}

.navbar.scrolled {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 1px 20px rgba(0,0,0,0.06);
    padding: 10px 0;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--dark);
    text-decoration: none;
}

.nav-logo .logo-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: white;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 32px;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    transition: color var(--transition-fast);
    position: relative;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--primary);
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px;
    transition: width var(--transition-base);
}

.nav-links a:hover::after,
.nav-links a.active::after {
    width: 100%;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.nav-user:hover {
    background: var(--gray-300);
    color: var(--dark);
}

.nav-user-avatar {
    width: 28px;
    height: 28px;
    background: var(--gradient-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    color: white;
    font-weight: 700;
}

/* Mobile Nav */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 1001;
}

.nav-toggle span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--dark);
    margin: 6px 0;
    transition: all var(--transition-base);
    border-radius: 2px;
}

@media (max-width: 768px) {
    .nav-toggle { display: block; }

    .nav-links, .nav-actions {
        display: none;
    }

    .nav-links.open {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--white);
        justify-content: center;
        align-items: center;
        gap: 24px;
        z-index: 999;
        animation: fadeIn 0.3s ease;
    }

    .nav-links.open a {
        font-size: 1.3rem;
    }

    .nav-actions.open {
        display: flex;
        position: fixed;
        bottom: 40px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 999;
    }
}

/* ---------- Footer ---------- */
.footer {
    background: #0F172A;
    color: var(--gray-400);
    padding: var(--space-3xl) 0 var(--space-xl);
}

.footer-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: var(--space-2xl);
    margin-bottom: var(--space-2xl);
}

.footer-brand h3 {
    color: var(--white);
    font-size: 1.4rem;
    margin-bottom: var(--space-md);
}

.footer-brand p {
    color: var(--gray-500);
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 300px;
}

.footer-col h4 {
    color: var(--white);
    font-size: 1rem;
    margin-bottom: var(--space-md);
}

.footer-col a {
    display: block;
    color: var(--gray-500);
    font-size: 0.9rem;
    padding: 4px 0;
    transition: color var(--transition-fast);
}

.footer-col a:hover {
    color: var(--primary-light);
}

.footer-bottom {
    border-top: 1px solid var(--gray-800);
    padding-top: var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.footer-socials {
    display: flex;
    gap: 16px;
}

.footer-socials a {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gray-800);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    transition: all var(--transition-fast);
    font-size: 0.9rem;
}

.footer-socials a:hover {
    background: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
}

@media (max-width: 768px) {
    .footer-grid {
        grid-template-columns: 1fr;
        gap: var(--space-xl);
    }
    .footer-bottom {
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }
}

/* ---------- Animations & Keyframes ---------- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideInDown {
    from {
        opacity: 0;
        transform: translateY(-24px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-40px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-20px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes blob {
    0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
    50% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
}

/* Scroll reveal */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-delay-1 { transition-delay: 0.1s; }
.reveal-delay-2 { transition-delay: 0.2s; }
.reveal-delay-3 { transition-delay: 0.3s; }
.reveal-delay-4 { transition-delay: 0.4s; }
.reveal-delay-5 { transition-delay: 0.5s; }
.reveal-delay-6 { transition-delay: 0.6s; }

/* ---------- Utility Classes ---------- */
.text-center { text-align: center; }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-gray { color: var(--gray-600); }
.text-white { color: var(--white); }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.1rem; }
.text-gradient {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }
.mt-4 { margin-top: var(--space-xl); }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

/* ---------- Page Transition ---------- */
.page-content {
    animation: fadeIn 0.5s ease;
    min-height: 100vh;
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-200);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}

/* ---------- Selection ---------- */
::selection {
    background: var(--primary);
    color: var(--white);
}

/* ================================================
   CHAT SYSTEM
   ================================================ */

/* Navbar chat icon badge */
.chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #EF4444;
    color: white;
    font-size: 0.62rem;
    font-weight: 800;
    min-width: 17px;
    height: 17px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    border: 2px solid white;
    line-height: 1;
    animation: pulse 2s infinite;
}

.nav-chat-btn:hover {
    background: var(--primary-bg) !important;
    color: var(--primary) !important;
}

/* ── Chat Inbox ── */
.chat-page {
    padding-top: 80px;
    min-height: 100vh;
    background: var(--gray-100);
}

.chat-inbox-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    height: calc(100vh - 80px);
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-300);
}

@media (max-width: 768px) {
    .chat-inbox-layout {
        grid-template-columns: 1fr;
    }
}

.chat-sidebar {
    border-right: 1px solid var(--gray-300);
    display: flex;
    flex-direction: column;
    background: var(--white);
    overflow: hidden;
}

.chat-sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--gray-300);
    background: var(--white);
    flex-shrink: 0;
}

.chat-sidebar-header h2 {
    font-size: 1.1rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-conversations-list {
    overflow-y: auto;
    flex: 1;
}

.chat-conv-item {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    cursor: pointer;
    border-bottom: 1px solid var(--gray-200);
    transition: background var(--transition-fast);
    text-decoration: none;
    color: inherit;
}

.chat-conv-item:hover,
.chat-conv-item.active {
    background: var(--primary-bg);
}

.chat-conv-item.active {
    border-left: 3px solid var(--primary);
}

.chat-conv-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    color: white;
    font-weight: 800;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-conv-info {
    flex: 1;
    min-width: 0;
}

.chat-conv-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-conv-preview {
    font-size: 0.78rem;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.chat-conv-time {
    font-size: 0.7rem;
    color: var(--gray-500);
}

.chat-unread-badge {
    background: var(--primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 99px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* ── Chat Conversation ── */
.chat-main {
    display: flex;
    flex-direction: column;
    background: var(--gray-100);
    overflow: hidden;
}

.chat-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border-bottom: 1px solid var(--gray-300);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--gradient-primary);
    color: white;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-header-info { flex: 1; }
.chat-header-name { font-weight: 700; font-size: 0.95rem; color: var(--dark); }
.chat-header-sub { font-size: 0.75rem; color: var(--gray-500); }

.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-lg);
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    scroll-behavior: smooth;
}

.chat-msg {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-end;
    max-width: 75%;
    animation: fadeInUp 0.2s ease;
}

.chat-msg.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-msg.theirs {
    align-self: flex-start;
}

.chat-msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--gradient-primary);
    color: white;
    font-size: 0.72rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-bubble {
    padding: var(--space-sm) var(--space-md);
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.5;
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
}

.chat-msg.mine .chat-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-msg.theirs .chat-bubble {
    background: var(--white);
    color: var(--dark);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-300);
}

.chat-bubble-time {
    font-size: 0.65rem;
    margin-top: 3px;
    display: block;
    text-align: right;
}

.chat-msg.mine .chat-bubble-time { color: rgba(255,255,255,0.7); }
.chat-msg.theirs .chat-bubble-time { color: var(--gray-500); }

/* Attachment in bubble */
.chat-attachment {
    margin-top: var(--space-sm);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.chat-attachment img {
    max-width: 240px;
    max-height: 180px;
    display: block;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.chat-attachment img:hover { opacity: 0.9; }

.chat-attachment-file {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.2);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    text-decoration: none;
    transition: background var(--transition-fast);
}

.chat-msg.mine .chat-attachment-file {
    background: rgba(255,255,255,0.2);
    color: white;
}

.chat-msg.theirs .chat-attachment-file {
    background: var(--gray-100);
    color: var(--dark);
}

.chat-attachment-file:hover { background: rgba(255,255,255,0.3); }

/* Date separator */
.chat-date-sep {
    text-align: center;
    font-size: 0.72rem;
    color: var(--gray-500);
    padding: var(--space-sm) 0;
    position: relative;
}

.chat-date-sep::before, .chat-date-sep::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 30%;
    height: 1px;
    background: var(--gray-300);
}

.chat-date-sep::before { left: 0; }
.chat-date-sep::after { right: 0; }

/* ── Chat Input ── */
.chat-input-area {
    padding: var(--space-md) var(--space-lg);
    background: var(--white);
    border-top: 1px solid var(--gray-300);
    flex-shrink: 0;
}

.chat-input-preview {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--primary-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    font-size: 0.82rem;
    color: var(--primary-dark);
    border: 1px solid rgba(16,185,129,0.2);
}

.chat-input-preview.visible { display: flex; }

.chat-input-preview-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-input-preview-remove {
    cursor: pointer;
    color: var(--gray-500);
    font-size: 1rem;
    line-height: 1;
}

.chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
}

.chat-input-box {
    flex: 1;
    background: var(--gray-100);
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-full);
    padding: 10px 18px;
    font-size: 0.92rem;
    font-family: var(--font-main);
    resize: none;
    max-height: 120px;
    min-height: 44px;
    overflow-y: auto;
    transition: border-color var(--transition-fast);
    color: var(--dark);
    line-height: 1.5;
}

.chat-input-box:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--white);
}

.chat-input-attach {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    border: 1.5px solid var(--gray-300);
    background: var(--white);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.chat-input-attach:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-bg);
}

.chat-send-btn {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    background: var(--gradient-primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-fast);
    box-shadow: 0 2px 8px rgba(16,185,129,0.3);
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(16,185,129,0.4);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ── Empty state ── */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    gap: var(--space-md);
    padding: var(--space-xl);
}

.chat-empty-icon {
    width: 72px;
    height: 72px;
    background: var(--primary-bg);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.chat-empty h3 {
    font-size: 1.1rem;
    color: var(--dark);
    font-weight: 700;
}

.chat-empty p {
    font-size: 0.88rem;
    text-align: center;
    max-width: 300px;
    line-height: 1.6;
}

/* Standalone conversation page */
.chat-standalone {
    padding-top: 80px;
    min-height: 100vh;
    background: var(--gray-100);
}

.chat-standalone-inner {
    max-width: 860px;
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
}

.chat-standalone-card {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-300);
    min-height: 0;
}


