/* ============================================
   K36 - Main Stylesheet (WeChat-Inspired)
   Color: clean white, soft slate, K36 blue-violet
   ============================================ */

:root {
    --primary: #5967F2;
    --primary-light: #7C8CFF;
    --primary-dark: #4352D9;
    --primary-glow: rgba(89, 103, 242, 0.18);
    --primary-soft: #EEF1FF;

    --bg-primary: #FFFFFF;
    --bg-secondary: #F6F7FB;
    --bg-tertiary: #ECEFF8;
    --bg-chat: #F2F4FA;
    --bg-hover: #EEF1F8;
    --bg-active: #E8ECFF;
    --bg-dark: #5967F2;
    --bg-dark-hover: #4C5AE6;

    --text-primary: #172033;
    --text-secondary: #5E6680;
    --text-muted: #98A0B6;
    --text-inverse: #FFFFFF;

    --border-color: #E2E6F2;
    --border-light: #EEF1F7;

    --shadow-sm: 0 1px 2px rgba(30,42,90,0.05);
    --shadow-md: 0 8px 24px rgba(30,42,90,0.08);
    --shadow-lg: 0 14px 36px rgba(30,42,90,0.12);
    --shadow-xl: 0 22px 64px rgba(30,42,90,0.16);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.4s cubic-bezier(0.4, 0, 0.2, 1);

    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;

    /* 由JS动态设置的断点标识 */
    --is-mobile: 0;
    --is-desktop: 1;
}

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: clamp(14px, 1.6vw, 16px);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    height: 100%;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    user-select: none;
    -webkit-user-select: none;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; color: inherit; }
input { font-family: inherit; font-size: inherit; border: none; outline: none; background: none; color: var(--text-primary); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }

/* Scrollbar - WeChat style thin scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #CCC; border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: #AAA; }

/* ==================== Animations ==================== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.92); }
    to { opacity: 1; transform: scale(1); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}
@keyframes slideOutRight {
    from { transform: translateX(0); }
    to { transform: translateX(100%); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
}
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-3px); }
    30%, 70% { transform: translateX(3px); }
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes notifyPulse {
    0% { box-shadow: 0 0 0 0 rgba(82, 116, 255, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(82, 116, 255, 0); }
    100% { box-shadow: 0 0 0 0 rgba(82, 116, 255, 0); }
}
@keyframes rippleEffect {
    to { transform: scale(4); opacity: 0; }
}
@keyframes badgeBounce {
    0% { transform: scale(0); }
    40% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

.fade-in { animation: fadeIn var(--transition-normal) ease forwards; }
.fade-in-up { animation: fadeInUp var(--transition-normal) ease forwards; }
.scale-in { animation: scaleIn var(--transition-normal) ease forwards; }

/* ==================== Buttons ==================== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: clamp(0.5rem, 1.2vw, 0.65rem) clamp(1rem, 2.5vw, 1.5rem);
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: #fff;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: clamp(0.85rem, 1.3vw, 0.95rem);
    transition: all var(--transition-fast);
    position: relative;
    overflow: hidden;
    letter-spacing: 0.02em;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 10px 24px var(--primary-glow);
}

.btn-primary:active {
    transform: scale(0.97);
    transition: transform 0.1s ease;
}

.btn-primary svg {
    width: clamp(16px, 2vw, 18px);
    height: clamp(16px, 2vw, 18px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary:active {
    transform: scale(0.97);
}

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; border-radius: var(--radius-xs); }

.btn-danger { color: #E74C3C; border-color: #F5C6CB; }
.btn-danger:hover { background: #FDF2F2; border-color: #E74C3C; color: #E74C3C; }

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: clamp(30px, 4vw, 36px);
    height: clamp(30px, 4vw, 36px);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    position: relative;
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.icon-btn:active {
    transform: scale(0.92);
}

.icon-btn svg {
    width: clamp(16px, 2.5vw, 20px);
    height: clamp(16px, 2.5vw, 20px);
}

/* ==================== Input Group ==================== */
.input-group {
    position: relative;
    margin-bottom: 0.85rem;
}

.input-group .input-icon {
    position: absolute;
    left: clamp(0.6rem, 1.5vw, 0.8rem);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.input-group .input-icon svg {
    width: clamp(16px, 2.2vw, 18px);
    height: clamp(16px, 2.2vw, 18px);
}

.input-group input {
    width: 100%;
    padding: clamp(0.55rem, 1.3vw, 0.7rem) clamp(0.6rem, 1.5vw, 0.8rem) clamp(0.55rem, 1.3vw, 0.7rem) clamp(2.3rem, 4vw, 2.6rem);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: all var(--transition-fast);
    font-size: clamp(0.85rem, 1.2vw, 0.93rem);
}

.input-group input:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(89,103,242,0.12);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* ==================== Loader ==================== */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.spinner {
    width: clamp(22px, 3vw, 28px);
    height: clamp(22px, 3vw, 28px);
    border: 2.5px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* ==================== Badge ==================== */
.badge-dot {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 14px;
    height: 14px;
    background: linear-gradient(135deg, #FBBF24, #F97316);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
    animation: badgeBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 5px;
    background: #F43530;
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: badgeBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    line-height: 1;
}

.avatar-wrapper {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

.avatar {
    width: clamp(36px, 4vw, 42px);
    height: clamp(36px, 4vw, 42px);
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
}

.avatar-sm {
    width: clamp(30px, 3.5vw, 36px);
    height: clamp(30px, 3.5vw, 36px);
    border-radius: var(--radius-xs);
    object-fit: cover;
    background: var(--bg-tertiary);
}

.avatar-lg {
    width: clamp(50px, 7vw, 64px);
    height: clamp(50px, 7vw, 64px);
    border-radius: var(--radius-md);
    object-fit: cover;
    background: var(--bg-tertiary);
}

/* Online status dot */
.status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.08);
}

.status-dot.online { background: #07C160; }
.status-dot.offline { background: #B0B0B0; }
.status-dot.busy { background: #F43530; }

/* ==================== Utilities ==================== */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.min-w-0 { min-width: 0; }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }

/* No select */
.no-select {
    user-select: none;
    -webkit-user-select: none;
}
