/* ===================================
   MebhaTalkz - Main Styles
   =================================== */

/* CSS Variables */
:root {
    --primary: #06b6d4;
    --primary-dark: #0891b2;
    --primary-light: #22d3ee;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --background: #ffffff;
    --background-secondary: #f3f4f6;
    --surface: #ffffff;
    --surface-secondary: #f9fafb;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --transition: 0.2s ease;
}

/* Dark Mode */
.dark {
    --primary: #22d3ee;
    --primary-dark: #22d3ee;
    --primary-light: #67e8f9;
    --background: #111827;
    --background-secondary: #1f2937;
    --surface: #1f2937;
    --surface-secondary: #374151;
    --text: #f9fafb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --border: #374151;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
}


/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* FIX: Use dynamic viewport height for mobile fit */
    height: 100dvh; 
    width: 100vw;
    overflow: hidden; /* Prevent body scroll, handle inside containers */
    touch-action: manipulation;
}

input, textarea, select, button {
    font-family: inherit;
    font-size: inherit;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

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

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



/* App Container */
#app {
    height: 100dvh;
    width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Screens */
.screen {
    display: none;
    height: 100dvh;
    width: 100%;
    overflow: hidden;
    background-color: var(--background);
}

.screen.active {
    display: flex;
    flex-direction: column;
}

/* ===================================
   Auth Screens
   =================================== */

.auth-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 40px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.logo {
    text-align: center;
    margin-bottom: 40px;
}

.logo-emoji {
    font-size: 64px;
    display: block;
    margin-bottom: 10px;
}

.logo h1 {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.logo p {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Forms */
.auth-form, .onboarding-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    position: relative;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    background-color: var(--surface);
    color: var(--text);
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
}

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

.form-group select[multiple] {
    min-height: 120px;
}

.hint {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.char-count {
    text-align: right;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.validation-icon {
    position: absolute;
    right: 12px;
    top: 38px;
    font-size: 18px;
}

/* Range Slider */
input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: none;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    transition: all var(--transition);
    text-align: center;
}

.btn-full {
    width: 100%;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
}

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

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

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

.btn-outline:hover {
    background-color: var(--primary);
    color: white;
}

.btn-ghost {
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text);
}

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

.btn-danger:hover {
    background-color: #dc2626;
}

/* Auth Links */
.auth-links {
    text-align: center;
    margin-top: -10px;
}

.auth-links .link {
    font-size: 14px;
    color: var(--primary);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider span {
    padding: 0 10px;
    color: var(--text-tertiary);
    font-size: 14px;
}

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

/* Security Info */
.security-info {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.security-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}


/* Google Sign-In Button Container */
.g_id_signin {
    display: flex;
    justify-content: center;
    width: 100%;
}

.verify-box {
    margin-bottom: 20px;
}




/* ===================================
   Verify Email & Forgot Password Styles
   =================================== */

.verify-box {
    text-align: center;
    padding: 20px;
    background: var(--surface-secondary);
    border-radius: 12px;
    margin-bottom: 20px;
}

.verify-box h3 {
    margin-bottom: 10px;
    color: var(--primary);
}

/* Google Sign-In Button Container */
.g_id_signin {
    display: flex;
    justify-content: center;
    width: 100%;
    margin-bottom: 20px;
}

/* ===================================
   Onboarding
   =================================== */


.onboarding-container {
    max-width: 500px;
    width: 100%;
    margin: 0 auto;
    padding: 40px 20px 80px 20px; /* Added bottom padding so the last button isn't hidden */
    height: 100%; /* Changed: Fills the parent screen height exactly */
    overflow-y: auto; /* Added: Enables scrolling within the container */
    -webkit-overflow-scrolling: touch; /* Added: Smooth scrolling on iOS */
}

.onboarding-header {
    text-align: center;
    margin-bottom: 40px;
}

.onboarding-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.onboarding-header p {
    color: var(--text-secondary);
}

/* ===================================
   Main Screen
   =================================== */

.main-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

.tab-content {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.tab-content.active {
    display: flex;
}
/* Tab Headers */
.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.tab-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background-color: var(--surface-secondary);
    transition: all var(--transition);
}

.icon-btn:hover {
    background-color: var(--border);
}

/* Sub Tabs */
.sub-tabs {
    display: flex;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
}

.sub-tab {
    flex: 1;
    padding: 14px 16px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    transition: all var(--transition);
}

.sub-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.sub-tab .badge {
    background-color: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    margin-left: 4px;
}

/* Search Box */
.search-box {
    position: relative;
    flex: 1;
    max-width: 300px;
}

.search-box input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-secondary);
    font-size: 14px;
}

.search-box .search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

/* Inline search box for explore tab */
.header-with-search {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.header-with-search h2 {
    flex-shrink: 0;
    margin: 0;
}

.search-box-inline {
    position: relative;
    flex: 1;
    max-width: 250px;
}

.search-box-inline input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background-color: var(--surface-secondary);
    font-size: 13px;
}

.search-box-inline .search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.explore-header {
    padding: 16px 20px;
    background-color: var(--surface-secondary);
}

/* Lists (Chats, Users, Friends) */
.chats-list,
.users-list,
.friends-content {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Smooth iOS scroll */
    scroll-behavior: smooth;
    width: 100%;
    padding-bottom: 80px; /* Space for bottom nav */
}

.chats-list {
    /* Additional styling for chats list */
    max-height: calc(100dvh - 180px); /* Use dynamic viewport height on mobile */
    padding-bottom: 100px; /* Extra padding for mobile navigation */
}

/* Chat Card */
.chat-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color var(--transition);
}

.chat-card:hover {
    background-color: var(--surface-secondary);
}

.chat-card .avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background-color: var(--border);
}

.chat-card .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-card .online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: var(--success);
    border: 2px solid var(--surface);
    border-radius: 50%;
}

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

.chat-card .name {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-card .username {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.chat-card .last-message {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-card .meta {
    text-align: right;
    flex-shrink: 0;
}

.chat-card .time {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 4px;
}

.chat-card .unread-badge {
    background-color: var(--primary);
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

/* User Card */
.user-card {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background-color: var(--surface);
    transition: background-color 0.2s;
}


.user-card:active {
    background-color: var(--surface-secondary);
}

.user-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}


/* User Card Avatar - Small and Circular */
.user-card .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    background-color: var(--border);
}

.user-card .avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.user-card .online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background-color: var(--success);
    border: 2px solid var(--surface);
    border-radius: 50%;
}

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

.user-card .user-name {
    font-weight: 600;
    font-size: 16px;
}

.user-card .user-username {
    font-size: 13px;
    color: var(--text-tertiary);
}

.user-card .user-badges-count {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 12px;
    color: var(--text-secondary);
}

.badges-count-icon {
    font-size: 14px;
}

.badges-count-number {
    font-weight: 600;
}

/* User Intent Status in Explore Tab */
/* User Intent Status in Explore Tab */
.user-intent-row {
    display: inline-flex; /* Changed to inline-flex so it wraps content */
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text);
    background-color: var(--surface-secondary); /* Light background */
    padding: 4px 10px; /* Padding for pill shape */
    border-radius: 12px; /* Rounded corners */
    margin-top: 8px; /* Space from bio */
    margin-bottom: 8px;
    border: 1px solid var(--border); /* Subtle border */
    font-weight: 500;
}

/* Optional: Add color coding based on text content (Modern browser support) */
.user-intent-row:has-text("Chatty"), 
.user-intent-row:has-text("Serious") {
    color: var(--primary);
    border-color: var(--primary-light);
    background-color: rgba(34, 211, 238, 0.1);
}

.user-intent-row:has-text("Do Not Disturb") {
    color: var(--danger);
    border-color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

.user-card .user-details {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.user-card .user-bio {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

.user-card .user-actions {
    display: flex;
    gap: 8px;
}

/* Friend Request Card */
.friend-request-card {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.friend-request-card .request-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.friend-request-card .request-actions {
    display: flex;
    gap: 8px;
}

/* Bottom Navigation */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 100;
    height: 60px;
    padding-bottom: env(safe-area-inset-bottom); /* Fixes home indicator issue */
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 20px;
    transition: all var(--transition);
}

.nav-btn span:last-child {
    font-size: 11px;
    margin-top: 4px;
}

.nav-btn.active {
    color: var(--primary);
}

/* ===================================
   Profile
   =================================== */

.profile-container {
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    height: 100%;
    padding-bottom: 100px; /* Space for scrolling past bottom nav */
}
.profile-header {
    text-align: center;
    margin-bottom: 24px;
}

.avatar-large {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 16px;
}

.avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--border);
}

.avatar-edit {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: 3px solid var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
}

.profile-header h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.profile-header p {
    color: var(--text-secondary);
}

/* Profile Stats */
.profile-stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius);
    margin-bottom: 24px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.stat-icon {
    font-size: 24px;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Profile Sections */
.profile-section {
    margin-bottom: 24px;
}

.profile-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Intent Status */
.intent-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius);
}

.intent-value {
    font-weight: 600;
}

.intent-duration {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Profile Languages */
.profile-languages {
    margin-top: 12px;
}

.language-tag {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.lang-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.lang-value {
    font-size: 14px;
}

.lang-learning {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.learning-badge {
    background-color: var(--primary-light);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* Badges Grid */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 12px;
}

.badge-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 12px 8px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius-sm);
}

.badge-emoji {
    font-size: 32px;
    margin-bottom: 4px;
}

.badge-name {
    font-size: 11px;
    color: var(--text-secondary);
}

.no-badges {
    color: var(--text-tertiary);
    font-style: italic;
    text-align: center;
}

/* Profile Badges Section */
.profile-badges-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.profile-badges-section h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 12px;
}

/* Settings List */
.settings-list {
    background-color: var(--surface-secondary);
    border-radius: var(--radius);
    overflow: hidden;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.setting-item:last-child {
    border-bottom: none;
}

/* Toggle Switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: var(--transition);
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: var(--transition);
    border-radius: 50%;
}

.toggle input:checked + .toggle-slider {
    background-color: var(--primary);
}

.toggle input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ===================================
   Chat Room
   =================================== */

.chat-room-container {
    display: flex;
    flex-direction: column;
    height: 100dvh; /* Full viewport height */
    width: 100%;
    overflow: hidden; /* IMPORTANT: Prevents the whole container from scrolling */
    background-color: var(--background);
    position: relative;
}

/* Chat Header - Sticky Logic */
.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px; /* Slightly more padding for touch */
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    
    /* FIX: Ensures header stays at top even when scrolling messages */
    position: sticky; 
    top: 0;
    z-index: 100; /* High z-index to stay above messages */
    
    flex-shrink: 0; /* Prevents header from shrinking */
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}



.back-btn {
    font-size: 24px;
    padding: 8px;
    color: var(--text);
    background: none;
    border: none;
    flex-shrink: 0;
}

.chat-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1; /* Takes up remaining space */
    min-width: 0; /* Allows text truncation */
    overflow: hidden;
    cursor: default;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background-color: var(--border);
    flex-shrink: 0;
}


.chat-user-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* FIX: Make it look clickable */
    cursor: pointer; 
    color: var(--text);
    transition: color 0.2s;
}

/* Hover effect for desktop/touch feedback */
.chat-user-info h3:hover, .chat-user-info h3:active {
    color: var(--primary);
}

.chat-user-info p {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* New Header Buttons */
.chat-action-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--surface-secondary);
    color: var(--text);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    transition: background-color 0.2s;
    cursor: pointer;
}

.chat-action-btn:hover, .chat-action-btn:active {
    background-color: var(--border);
}

.menu-btn {
    font-size: 24px;
    padding: 6px;
    color: var(--text);
    background: none;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
}

/* Chat Menu Popup */
.chat-menu-popup {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1500;
    display: none;
    align-items: flex-end; /* Show from bottom on mobile */
    justify-content: center;
}

.chat-menu-popup.active {
    display: flex;
}

.chat-menu-popup-content {
    background-color: var(--surface);
    width: 100%;
    max-width: 400px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-menu-popup-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-menu-popup-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.close-popup-btn {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color var(--transition);
}

.close-popup-btn:hover {
    background-color: var(--surface-secondary);
}

.chat-menu-popup-body {
    padding: 8px 0;
}

.chat-menu-popup .menu-item {
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 16px;
    color: var(--text);
    transition: background-color var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.chat-menu-popup .menu-item:hover {
    background-color: var(--surface-secondary);
}

.chat-menu-popup .menu-item.danger {
    color: var(--danger);
}

.chat-menu-popup .menu-divider {
    height: 1px;
    background-color: var(--border);
    margin: 8px 0;
}

/* Desktop: Center popup */
@media (min-width: 641px) {
    .chat-menu-popup {
        align-items: center;
        padding: 20px;
    }

    .chat-menu-popup-content {
        border-radius: var(--radius-lg);
    }
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
    color: var(--text);
    transition: background-color var(--transition);
}

.menu-item:hover {
    background-color: var(--surface-secondary);
}

.menu-item.danger {
    color: var(--danger);
}

.menu-divider {
    height: 1px;
    background-color: var(--border);
    margin: 4px 0;
}

/* Message Context Menu */
.message-context-menu {
    position: fixed;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    min-width: 200px;
    overflow: hidden;
}

.message-context-menu .menu-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: background-color var(--transition);
}

.message-context-menu .menu-item:hover {
    background-color: var(--surface-secondary);
}

.message-context-menu .menu-item.danger {
    color: var(--danger);
}

/* Dual Timer Banner */
.dual-timer-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--primary-light);
    color: white;
}

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

.timer-time {
    font-weight: 600;
    font-family: monospace;
}

.timer-controls {
    display: flex;
    gap: 8px;
}

.timer-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.25);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--transition);
}

.timer-btn:hover {
    background-color: rgba(255, 255, 255, 0.35);
}



/* Messages Area */
.messages-area {
    flex: 1; /* Takes all remaining vertical space */
    overflow-y: auto; /* ONLY this area scrolls */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 16px;
    background-color: var(--background);
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    position: relative; /* Context for sticky messages if needed later */
}

/* Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message.received {
    align-self: flex-start;
    align-items: flex-start;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
}

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

.message.received .message-bubble {
    background-color: var(--surface-secondary);
    color: var(--text);
    border-bottom-left-radius: 4px;
}

.message-image {
    max-width: 250px;
    border-radius: var(--radius-sm);
}

.message-time {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.message-status {
    font-size: 12px;
    margin-left: 4px;
}

.message.edited::after {
    content: ' (edited)';
    font-size: 11px;
    opacity: 0.7;
}

/* Reply Preview */
.reply-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: var(--surface-secondary);
    border-left: 3px solid var(--primary);
    font-size: 13px;
    flex-shrink: 0;
}

.close-reply,
.close-edit {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
}

/* Edit Preview */
.edit-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background-color: var(--warning-light);
    font-size: 13px;
    flex-shrink: 0;
}

/* Message Input */
.message-input {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    /* Handle safe area for newer iPhones */
    padding-bottom: max(10px, env(safe-area-inset-bottom)); 
    background-color: var(--surface);
    border-top: 1px solid var(--border);
    flex-shrink: 0; /* Prevents input from shrinking */
    z-index: 100;
}
.input-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background-color: var(--surface-secondary);
    transition: background-color var(--transition);
}

.input-btn:hover {
    background-color: var(--border);
}

.message-input input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background-color: var(--surface-secondary);
    font-size: 15px;
}

.message-input input:focus {
    outline: none;
    border-color: var(--primary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: background-color var(--transition);
}

.send-btn:hover {
    background-color: var(--primary-dark);
}

/* Recording Indicator */
.recording-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--danger);
    color: white;
    flex-shrink: 0;
}

.cancel-record {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

/* ===================================
   Dialogs
   =================================== */

.dialog {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.dialog-content {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

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

.dialog-header h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

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

.dialog-body {
    padding: 20px;
}

.dialog-footer {
    display: flex;
    gap: 12px;
    padding: 20px;
    border-top: 1px solid var(--border);
}

/* Intent Options */
.intent-option {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    text-align: left;
    transition: all var(--transition);
}

.intent-option:hover {
    border-color: var(--primary);
    background-color: var(--surface-secondary);
}

.intent-option span:first-child {
    font-weight: 600;
}

/* Badges Selection */
.badges-selection {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.badge-select-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: none;
    cursor: pointer;
    transition: all var(--transition);
}

.badge-select-btn:hover {
    border-color: var(--primary);
}

.badge-select-btn.selected {
    border-color: var(--primary);
    background-color: var(--surface-secondary);
}

/* ===================================
   Toast Notifications
   =================================== */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    background-color: var(--surface);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    max-width: 300px;
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

.toast.info {
    border-left: 4px solid var(--primary);
}

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

/* ===================================
   Responsive Design
   =================================== */

/* Mobile Styles (max-width: 640px) */
@media (max-width: 640px) {
    /* Base adjustments */
    * {
        -webkit-tap-highlight-color: transparent;
    }

    body {
        font-size: 14px;
    }

    /* Auth containers */
    .auth-container,
    .onboarding-container {
        max-width: 100%;
        padding: 20px;
    }

    .logo h1 {
        font-size: 28px;
    }

    /* Main container */
    .main-container {
        padding: 0;
        height: 100vh;
    }

    /* Chat room */
    .chat-room-container {
        height: 100vh;
    }

    .chat-header {
        padding: 10px 12px;
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
    }

    .chat-user-name {
        font-size: 16px;
    }

    .chat-user-status {
        font-size: 12px;
    }

    /* Messages */
    .message {
        max-width: 85%;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 14px;
    }

    .message-time {
        font-size: 11px;
    }

    /* Chat input area */
    .chat-input-area {
        padding: 10px;
    }

    .input-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    #message-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Bottom navigation */
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .nav-btn {
        padding: 8px 0;
    }

    .nav-btn span:last-child {
        font-size: 10px;
        margin-top: 2px;
    }

    /* Tabs */
    .tab-header h2 {
        font-size: 18px;
    }

    .header-actions button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }

    /* User cards */
    .user-card,
    .chat-card {
        padding: 12px 16px;
    }

    .user-card .avatar,
    .chat-card .avatar {
        width: 44px;
        height: 44px;
    }

    .user-name,
    .chat-card .name {
        font-size: 15px;
    }

    .user-username,
    .chat-card .username {
        font-size: 12px;
    }

    /* Profile */
    .profile-avatar-large {
        width: 80px;
        height: 80px;
    }

    .profile-section h3 {
        font-size: 16px;
    }

    /* Dialogs */
    .dialog-content {
        width: 95%;
        max-height: 90vh;
        margin: 5% auto;
    }

    .dialog-header h3 {
        font-size: 18px;
    }

    /* Filter dialog */
    .form-group label {
        font-size: 13px;
    }

    select,
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea {
        font-size: 16px; /* Prevents zoom on iOS */
    }

    /* Voice recording */
    .recording-indicator {
        padding: 8px 16px;
    }

    /* Message context menu */
    .message-context-menu {
        min-width: 180px;
    }

    .message-context-menu .menu-item {
        padding: 12px 14px;
        font-size: 14px;
    }

    /* Buttons */
    .btn {
        min-height: 44px; /* Touch target size */
    }

    .input-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Tablet Styles (min-width: 641px) */
@media (min-width: 640px) {
    .auth-container,
    .onboarding-container {
        max-width: 480px;
    }

    .profile-container {
        max-width: 700px;
    }

    .message {
        max-width: 70%;
    }
}

/* Desktop Styles (min-width: 1024px) */
@media (min-width: 1024px) {
    .main-container {
        max-width: 1200px;
        margin: 0 auto;
        padding: 0;
    }

    .profile-container {
        max-width: 800px;
    }
}

/* ===================================
   Utility Classes
   =================================== */

.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-2 {
    margin-top: 8px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-4 {
    margin-bottom: 16px;
}

.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* View Profile Dialog Styles */
.view-profile-container {
    text-align: center;
    padding: 20px;
}

.profile-avatar-large {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 16px;
}

.profile-avatar-large img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}

.online-status {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid var(--surface);
}

.online-status.online {
    background-color: var(--success);
}

.online-status.offline {
    background-color: var(--text-tertiary);
}

.view-profile-container h2 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.view-profile-container p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius-sm);
}

.stat-box .stat-icon {
    font-size: 24px;
    margin-bottom: 8px;
}

.stat-box .stat-value {
    font-weight: 600;
    font-size: 16px;
    color: var(--text);
    margin-bottom: 4px;
}

.stat-box .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.profile-details {
    text-align: left;
    padding: 16px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius-sm);
}

.profile-details p {
    margin-bottom: 12px;
    color: var(--text);
}

.profile-details p:last-child {
    margin-bottom: 0;
}

.profile-details strong {
    color: var(--text-secondary);
}

/* Voice Message Player */
.voice-message-player {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 300px;
    padding: 12px;
    background-color: var(--surface-secondary);
    border-radius: var(--radius-sm);
}

.voice-play-btn,
.voice-stop-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background-color var(--transition);
    flex-shrink: 0;
}

.voice-play-btn:hover,
.voice-stop-btn:hover {
    background-color: var(--primary-dark);
}

.voice-play-btn:disabled,
.voice-stop-btn:disabled {
    background-color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
}

.voice-progress {
    flex: 1;
    height: 6px;
    background-color: var(--border);
    border-radius: 3px;
    overflow: hidden;
}

.voice-progress-bar {
    height: 100%;
    background-color: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.voice-duration {
    min-width: 40px;
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Voice player in sent messages */
.message.sent .voice-message-player {
    background-color: rgba(255, 255, 255, 0.15);
}

.message.sent .voice-play-btn,
.message.sent .voice-stop-btn {
    background-color: white;
    color: var(--primary);
}

.message.sent .voice-play-btn:hover,
.message.sent .voice-stop-btn:hover {
    background-color: var(--background);
}

.message.sent .voice-duration {
    color: rgba(255, 255, 255, 0.8);
}

/* Dark mode adjustments */
.dark .voice-message-player {
    background-color: var(--surface-secondary);
}

.message-image {
    max-width: 300px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}


/* Add this to the bottom of assets/css/style.css */

/* ===================================
   System & Badge Messages in Chat
   =================================== */

.message-system .message-bubble,
.message-badge .message-bubble {
    background-color: transparent;
    color: var(--text-secondary);
    padding: 4px 12px;
    font-size: 12px;
    text-align: center;
    width: 100%;
    border: none;
    box-shadow: none;
    border-radius: 0;
}

/* Specific style for Badge Event in Chat */
.message-badge {
    align-self: center !important;
    width: 100%;
    max-width: 90%;
}

.message-badge .message-bubble {
    background-color: rgba(16, 185, 129, 0.1); /* Light green tint */
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px;
}

.message-badge .badge-icon-large {
    font-size: 32px;
    display: block;
    margin-bottom: 2px;
}

.message-badge .badge-text-title {
    font-weight: 600;
    color: var(--text);
}

/* Notification Center Indicator (Optional: for a bell icon in future) */
.notification-dot {
    width: 10px;
    height: 10px;
    background-color: var(--danger);
    border-radius: 50%;
    position: absolute;
    top: -2px;
    right: -2px;
    border: 2px solid var(--surface);
}
