/* =========================================================
   BDSChat — Base Styles
   File: css/base.css
   Description: متغیرها، reset، دکمه‌ها، فرم‌ها، تم روشن/تیره
   ========================================================= */

/* =========================================================
   THEME VARIABLES — Light Theme (Default)
   ========================================================= */
:root {
    /* Brand Colors */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-soft: #e0e7ff;
    /* Text Colors */
    --text-dark: #1e293b;
    --text: #334155;
    --text-gray: #64748b;
    --text-light: #94a3b8;
    --text-muted: #cbd5e1;
    /* Background Colors */
    --bg-page: #f1f5f9;
    --bg-card: #ffffff;
    --bg-soft: #f8fafc;
    --bg-hover: #f1f5f9;
    --bg-active: #eef2ff;
    /* Border Colors */
    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #a5b4fc;
    /* Status Colors */
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --online: #22c55e;
    /* Chat Bubbles */
    --bubble-sent: #4f46e5;
    --bubble-sent-text: #ffffff;
    --bubble-received: #ffffff;
    --bubble-received-text: #1e293b;
    /* Sidebar */
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --sidebar-text: #cbd5e1;
    --sidebar-text-active: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.08);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.12);
    --shadow-primary: 0 4px 14px rgba(79, 70, 229, 0.3);
    /* Radii */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition: 200ms ease;
    --transition-slow: 300ms ease;
    /* Layout */
    --sidebar-width: 260px;
    --chats-list-width: 340px;
    --header-height: 70px;
    /* Z-Index */
    --z-dropdown: 100;
    --z-sidebar: 500;
    --z-modal: 1000;
    --z-call: 2000;
    --z-toast: 5000;
}

/* =========================================================
   DARK THEME
   ========================================================= */
body.theme-dark {
    /* Text Colors */
    --text-dark: #f1f5f9;
    --text: #cbd5e1;
    --text-gray: #94a3b8;
    --text-light: #64748b;
    --text-muted: #475569;
    /* Background Colors */
    --bg-page: #0f172a;
    --bg-card: #1e293b;
    --bg-soft: #1a2436;
    --bg-hover: #334155;
    --bg-active: #312e81;
    /* Border Colors */
    --border: #334155;
    --border-light: #1e293b;
    --border-focus: #6366f1;
    /* Chat Bubbles */
    --bubble-received: #1e293b;
    --bubble-received-text: #f1f5f9;
    /* Shadows (darker) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.6);
}

/* =========================================================
   RESET
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    width: 100%;
}

body {
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-dark);
    background-color: var(--bg-page);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color var(--transition), color var(--transition);
}

img,
svg {
    display: block;
    max-width: 100%;
}

button,
input,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    border: 0;
    background: none;
    cursor: pointer;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--transition);
}

    a:hover {
        color: var(--primary-hover);
    }

ul,
ol {
    list-style: none;
}

/* Focus visible (keyboard navigation) */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* =========================================================
   UTILITIES
   ========================================================= */
.hidden {
    display: none !important;
}

.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;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}

    .btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
        pointer-events: none;
    }

/* Primary */
.btn-primary {
    background-color: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-primary);
}

    .btn-primary:hover:not(:disabled) {
        background-color: var(--primary-hover);
        transform: translateY(-1px);
    }

    .btn-primary:active:not(:disabled) {
        transform: translateY(0);
    }

/* Outline */
.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

    .btn-outline:hover:not(:disabled) {
        background-color: var(--primary-light);
    }

/* Secondary */
.btn-secondary {
    background-color: var(--bg-hover);
    color: var(--text);
}

    .btn-secondary:hover:not(:disabled) {
        background-color: var(--border);
    }

/* Danger */
.btn-danger {
    background-color: var(--danger);
    color: #ffffff;
}

    .btn-danger:hover:not(:disabled) {
        background-color: #dc2626;
        transform: translateY(-1px);
    }

/* Ghost */
.btn-ghost {
    background-color: transparent;
    color: var(--text-gray);
}

    .btn-ghost:hover:not(:disabled) {
        background-color: var(--bg-hover);
        color: var(--text-dark);
    }

/* Icon Buttons */
.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    color: var(--text-gray);
    background: transparent;
    transition: all var(--transition);
    flex-shrink: 0;
}

    .icon-btn:hover {
        background-color: var(--bg-hover);
        color: var(--primary);
    }

    .icon-btn svg {
        width: 20px;
        height: 20px;
    }

/* =========================================================
   FORM ELEMENTS
   ========================================================= */
.form-group {
    width: 100%;
    margin-bottom: 16px;
    position: relative;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-dark);
    background-color: var(--bg-card);
    transition: all var(--transition);
    outline: none;
    direction: rtl;
}

    .form-input:focus {
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
    }

    .form-input::placeholder {
        color: var(--text-light);
    }

/* Checkbox */
.checkbox-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-gray);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

    .checkbox-container input[type="checkbox"] {
        width: 16px;
        height: 16px;
        accent-color: var(--primary);
        cursor: pointer;
    }

/* =========================================================
   CARDS
   ========================================================= */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition);
}

/* =========================================================
   AVATARS
   ========================================================= */
.avatar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #ffffff;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
    overflow: hidden;
    user-select: none;
}

    .avatar img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 50%;
    }

    .avatar.online::after {
        content: '';
        position: absolute;
        bottom: 1px;
        left: 1px;
        width: 12px;
        height: 12px;
        background: var(--online);
        border: 2px solid var(--bg-card);
        border-radius: 50%;
    }

.avatar-sm {
    width: 36px;
    height: 36px;
    font-size: 13px;
}

.avatar-md {
    width: 48px;
    height: 48px;
    font-size: 16px;
}

.avatar-lg {
    width: 64px;
    height: 64px;
    font-size: 20px;
}

/* Avatar gradient variants */
.avatar-1 {
    background: linear-gradient(135deg, #667eea, #764ba2);
}

.avatar-2 {
    background: linear-gradient(135deg, #f093fb, #f5576c);
}

.avatar-3 {
    background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.avatar-4 {
    background: linear-gradient(135deg, #43e97b, #38f9d7);
}

.avatar-5 {
    background: linear-gradient(135deg, #fa709a, #fee140);
}

.avatar-6 {
    background: linear-gradient(135deg, #30cfd0, #330867);
}

/* =========================================================
   SCROLLBAR
   ========================================================= */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: var(--radius-full);
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-light);
    }

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================
   SWEETALERT2 CUSTOM THEME
   ========================================================= */
.swal2-popup {
    font-family: 'Vazirmatn', sans-serif !important;
    border-radius: var(--radius-lg) !important;
    background-color: var(--bg-card) !important;
    color: var(--text-dark) !important;
    box-shadow: var(--shadow-xl) !important;
}

.swal2-title {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--text-dark) !important;
    padding-top: 10px !important;
}

.swal2-html-container {
    font-size: 14px !important;
    color: var(--text-gray) !important;
    line-height: 1.8 !important;
}

.swal2-confirm {
    background-color: var(--primary) !important;
    border-radius: var(--radius) !important;
    padding: 10px 24px !important;
    font-family: inherit !important;
    font-weight: 600 !important;
    font-size: 14px !important;
    box-shadow: var(--shadow-primary) !important;
}

    .swal2-confirm:hover {
        background-color: var(--primary-hover) !important;
    }

.swal2-cancel {
    background-color: var(--bg-hover) !important;
    color: var(--text) !important;
    border-radius: var(--radius) !important;
    padding: 10px 24px !important;
    font-family: inherit !important;
    font-weight: 600 !important;
    font-size: 14px !important;
}

    .swal2-cancel:hover {
        background-color: var(--border) !important;
    }

.swal2-toast {
    font-family: 'Vazirmatn', sans-serif !important;
    background-color: var(--bg-card) !important;
    color: var(--text-dark) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 12px 16px !important;
    font-size: 13px !important;
}

    .swal2-toast .swal2-title {
        font-size: 13px !important;
        font-weight: 600 !important;
        padding: 0 !important;
    }

/* Dark theme overrides for SweetAlert */
body.theme-dark .swal2-popup,
body.theme-dark .swal2-toast {
    background-color: #1e293b !important;
    color: #f1f5f9 !important;
}

body.theme-dark .swal2-title {
    color: #f1f5f9 !important;
}

body.theme-dark .swal2-html-container {
    color: #94a3b8 !important;
}

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
    .btn {
        min-height: 40px;
        padding: 0 16px;
        font-size: 13px;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
    }

    .form-input {
        padding: 10px 14px;
        font-size: 13px;
    }
}

/* =========================================================
   PWA INSTALL BUTTON
   ========================================================= */
.pwa-install-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 5000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #667eea, #4f46e5);
    color: #fff;
    border: none;
    border-radius: 14px;
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 25px rgba(79, 70, 229, 0.4);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(20px);
}

    .pwa-install-btn.visible {
        opacity: 1;
        transform: translateY(0);
    }

    .pwa-install-btn:hover {
        transform: translateY(-2px);
        box-shadow: 0 12px 30px rgba(79, 70, 229, 0.5);
    }

    .pwa-install-btn svg {
        width: 18px;
        height: 18px;
    }

    .pwa-install-btn .pwa-close-btn {
        position: absolute;
        top: -8px;
        left: -8px;
        width: 22px;
        height: 22px;
        border-radius: 50%;
        background: #ef4444;
        color: #fff;
        border: 2px solid #fff;
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
    }

        .pwa-install-btn .pwa-close-btn:hover {
            background: #dc2626;
        }

@media (max-width: 600px) {
    .pwa-install-btn {
        bottom: 80px;
        right: 12px;
        padding: 10px 14px;
        font-size: 12.5px;
    }
}
