/* ============================================================
   ChatPulse - Base Styles
   Reset, typography, scrollbar, and global element styles
   ============================================================ */

/* ---- CSS Reset ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent !important;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-base);
    font-weight: var(--font-weight-normal);
    line-height: var(--line-height-normal);
    color: var(--text-primary);
    background-color: var(--bg-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    min-height: 100vh;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important;
}

/* ---- Text Selection Styling ---- */
::selection {
    background: rgba(108, 92, 231, 0.4);
    color: #ffffff;
}

::-moz-selection {
    background: rgba(108, 92, 231, 0.4);
    color: #ffffff;
}

/* Allow selection ONLY in editable form inputs & textareas */
input,
textarea,
[contenteditable="true"],
.allow-text-select {
    user-select: text !important;
    -webkit-user-select: text !important;
    -moz-user-select: text !important;
    -ms-user-select: text !important;
    -webkit-touch-callout: default !important;
}

/* Strict UI & Message Selection Lock (Prevent native mobile selection handles & Google search bar on tap-and-hold) */
.message,
.message *,
.message-bubble,
.message-bubble *,
.message-content,
.message-content *,
.message-text,
.message-text *,
.message-reactions-bar,
.message-reactions-bar *,
.message-context-menu,
.message-context-menu *,
.chat-messages,
.chat-messages *,
.sidebar,
.sidebar *,
.chat-header,
.chat-header *,
.chat-list-header,
.chat-list-header *,
.page-header,
.page-header *,
.btn,
.btn *,
button,
.badge,
.status-dot,
.nav-item,
.nav-section-title,
.message-preview,
.message-preview *,
.dropdown,
.dropdown-menu,
img,
svg {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    -webkit-touch-callout: none !important;
    -webkit-user-drag: none !important;
}

/* ---- Typography ---- */
h1, h2, h3, h4, h5, h6 {
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-tight);
    color: var(--text-primary);
}

h1 { font-size: var(--font-3xl); }
h2 { font-size: var(--font-2xl); }
h3 { font-size: var(--font-xl); }
h4 { font-size: var(--font-lg); }
h5 { font-size: var(--font-md); }
h6 { font-size: var(--font-base); }

p {
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

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

a:hover {
    color: var(--accent-secondary-hover);
}

small {
    font-size: var(--font-sm);
    color: var(--text-tertiary);
}

strong { font-weight: var(--font-weight-semibold); }

/* ---- Lists ---- */
ul, ol { list-style: none; }

/* ---- Images ---- */
img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: var(--scrollbar-width);
    height: var(--scrollbar-width);
}

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

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: var(--radius-full);
}

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

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

/* ---- Focus Styles ---- */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ---- HR ---- */
hr {
    border: none;
    height: 1px;
    background: var(--glass-border);
    margin: var(--space-lg) 0;
}

/* ---- Table ---- */
table {
    width: 100%;
    border-collapse: collapse;
}

/* ---- Utility Classes ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent-primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.gap-xs { gap: var(--space-xs); }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

.mt-xs { margin-top: var(--space-xs); }
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }

.w-full { width: 100%; }
.h-full { height: 100%; }
.relative { position: relative; }
.overflow-hidden { overflow: hidden; }
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
