/* ========================================
   9chat.vn — Main Styles
   ======================================== */

:root {
    --primary: #3E1F91;
    --primary-dark: #2E1570;
    --primary-light: #EDE7F6;
    --secondary: #8E44AD;
    --accent: #FF6F61;
    --success: #00C853;
    --danger: #FF3B30;
    --warning: #FF9500;
    --bg: #FDFEFE;
    --bg-white: #FFFFFF;
    --bg-hover: #F5F5F5;
    --bg-active: #F3E5F5;
    --text: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-light: #7F8C8D;
    --border: #E0E6ED;
    --border-light: #F0F0F0;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --radius-full: 50%;
    --transition: 0.2s ease;
    --sidebar-width: 340px;
    --header-height: 60px;
    --bottom-bar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    font-size: inherit;
}

input, textarea {
    font-family: inherit;
    font-size: inherit;
    outline: none;
}

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #C4C4C4;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #A0A0A0;
}

/* ========================================
   Buttons
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 500;
    transition: all var(--transition);
    white-space: nowrap;
}

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

.btn-secondary {
    background: var(--bg);
    color: var(--text);
}
.btn-secondary:hover {
    background: var(--border);
}

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.btn-ghost:hover {
    background: var(--bg-hover);
}

.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* ========================================
   Form
   ======================================== */
.form-group {
    margin-bottom: 16px;
}

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

.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-white);
    transition: border-color var(--transition);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(62,31,145,0.1);
}

.form-input::placeholder {
    color: var(--text-light);
}

.form-error {
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
}

/* ========================================
   Avatar
   ======================================== */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.avatar-lg {
    width: 56px;
    height: 56px;
    font-size: 22px;
}

.avatar-xl {
    width: 80px;
    height: 80px;
    font-size: 32px;
}

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

/* Online indicator */
.online-dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border: 2px solid var(--bg-white);
    border-radius: var(--radius-full);
    position: absolute;
    bottom: 0;
    right: 0;
}

/* ========================================
   Badge
   ======================================== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    color: #fff;
    background: var(--danger);
}

/* ========================================
   Utilities
   ======================================== */
.hidden { display: none !important; }
.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-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.text-sm { font-size: 13px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.relative { position: relative; }

/* Toast notification */
.toast-container {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius);
    background: var(--text);
    color: #fff;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    max-width: 360px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

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

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: var(--radius-full);
    animation: spin 0.6s linear infinite;
}

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

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    padding: 24px;
    min-width: 400px;
    max-width: 90vw;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: transparent;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
}
.modal-close:hover {
    background: var(--bg-hover);
}

/* Close button outside modal */
.modal-close-outside {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    border: none;
}
.modal-close-outside:hover {
    background: rgba(255,255,255,0.35);
}

/* Friend request modal */
.modal-friend-request {
    position: relative;
    min-width: 420px;
    max-width: 480px;
    padding: 28px 32px;
}

@media (max-width: 768px) {
    .modal-friend-request {
        min-width: 86vw;
        max-width: 92vw;
        padding: 24px 20px;
    }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
