@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;500;700;900&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --bg-main: #f0f2f5;
    --sidebar-bg: rgba(30, 32, 40, 0.95);
    --text-dark: #1e293b;
    --text-light: #cbd5e1;
    --white: #ffffff;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
    --shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Vazirmatn', sans-serif; }
body { background-color: var(--bg-main); color: var(--text-dark); line-height: 1.6; overflow-x: hidden; }

.glass-effect { background: var(--glass-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--glass-border); border-radius: 20px; box-shadow: var(--shadow); }

/* Auth */
.login-bg { min-height: 100vh; display: flex; justify-content: center; align-items: center; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); padding: 20px; }
.auth-card { width: 100%; max-width: 420px; padding: 40px; text-align: center; animation: fadeUp 0.8s ease-out; }
.auth-card h2 { color: var(--text-dark); margin-bottom: 5px; font-weight: 800; }
.sub-text { color: #64748b; font-size: 0.9rem; margin-bottom: 30px; }
.logo-circle { width: 80px; height: 80px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; margin: 0 auto 20px; box-shadow: 0 10px 20px rgba(99, 102, 241, 0.4); }
.auth-switch { margin-top: 25px; font-size: 0.9rem; color: #64748b; }
.auth-switch a { color: var(--primary); text-decoration: none; font-weight: 700; }
.auth-switch a:hover { text-decoration: underline; }

.input-group { position: relative; margin-bottom: 20px; }
.input-group input, .input-group textarea { width: 100%; padding: 16px 15px 8px; border: 2px solid #e2e8f0; border-radius: 12px; font-size: 1rem; background: #fff; transition: all 0.3s ease; outline: none; font-family: 'Vazirmatn', sans-serif; }
.input-group label { position: absolute; right: 15px; top: 50%; transform: translateY(-50%); color: #94a3b8; font-size: 0.95rem; transition: all 0.3s ease; pointer-events: none; background: transparent; padding: 0 5px; }
.input-group textarea ~ label { top: 20px; transform: none; }
.input-group input:focus, .input-group textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1); }
.input-group input:focus + label, .input-group input:not(:placeholder-shown) + label, .input-group textarea:focus + label, .input-group textarea:not(:placeholder-shown) + label { top: 0; font-size: 0.75rem; color: var(--primary); background: #fff; transform: none; }

.btn-gradient { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border: none; padding: 14px 28px; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 1rem; transition: all 0.3s ease; box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3); font-family: 'Vazirmatn', sans-serif; }
.btn-gradient:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5); }
.btn-gradient:disabled { opacity: 0.6; transform: none; cursor: not-allowed; }
.btn-gradient.small { padding: 10px 20px; font-size: 0.85rem; }
.btn-gradient.outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); box-shadow: none; }
.btn-gradient.outline:hover { background: var(--primary); color: white; }
.btn-gradient.danger { background: transparent; border: 2px solid var(--danger); color: var(--danger); box-shadow: none; }
.btn-gradient.danger:hover { background: var(--danger); color: white; }
.btn-gradient.full-width { width: 100%; margin-top: 20px; padding: 18px; font-size: 1.1rem; }

/* Desktop Layout */
.app-container { display: flex; min-height: 100vh; }
.sidebar { width: 280px; background: var(--sidebar-bg); color: var(--text-light); display: flex; flex-direction: column; padding: 30px 0; position: fixed; right: 0; top: 0; bottom: 0; z-index: 100; border-radius: 0; border: none; backdrop-filter: none; box-shadow: -5px 0 15px rgba(0,0,0,0.1); transition: all 0.3s ease; }
.sidebar-header { display: flex; align-items: center; gap: 12px; padding: 0 25px 30px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.sidebar-logo { font-size: 2rem; }
.sidebar-header h3 { font-weight: 700; font-size: 1.2rem; color: white; }
.sidebar-menu { list-style: none; margin-top: 20px; flex-grow: 1; }
.sidebar-menu li { padding: 15px 25px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all 0.3s ease; border-right: 4px solid transparent; font-size: 0.95rem; }
.sidebar-menu li:hover { background: rgba(255,255,255,0.05); color: white; }
.sidebar-menu li.active { background: rgba(99, 102, 241, 0.2); border-right-color: var(--primary-light); color: var(--primary-light); }
.sidebar-footer { padding: 20px 25px; border-top: 1px solid rgba(255,255,255,0.1); }
.user-info { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.avatar { width: 45px; height: 45px; background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 1.2rem; color: white; }
.user-info p { font-weight: 700; color: white; font-size: 0.95rem; }
.user-info small { color: #94a3b8; font-size: 0.75rem; }
.btn-logout { width: 100%; background: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); padding: 10px; border-radius: 10px; cursor: pointer; font-family: 'Vazirmatn', sans-serif; font-weight: 600; transition: all 0.3s ease; }
.btn-logout:hover { background: var(--danger); color: white; border-color: var(--danger); }

.main-content { flex-grow: 1; margin-right: 280px; padding: 40px; }
.content-section { display: none; animation: fadeUp 0.5s ease-out; }
.content-section.active { display: block; }
.section-title { font-size: 1.8rem; font-weight: 900; margin-bottom: 30px; color: var(--text-dark); }

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; }
.stat-card { padding: 25px; border-radius: 16px; color: white; transition: transform 0.3s ease; }
.stat-card:hover { transform: translateY(-5px); }
.stat-card.blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-card.green { background: linear-gradient(135deg, #10b981, #059669); }
.stat-card.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-card.red { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-card h4 { font-size: 0.9rem; opacity: 0.9; margin-bottom: 10px; font-weight: 500; }
.stat-card p { font-size: 2rem; font-weight: 900; }

.warning-box { display: flex; gap: 15px; background: #fffbeb; border: 1px solid #fde68a; padding: 20px; border-radius: 16px; align-items: flex-start; }
.warning-box span { font-size: 1.5rem; }
.warning-box h4 { color: #92400e; margin-bottom: 5px; }
.warning-box p { color: #78350f; font-size: 0.9rem; }

.contacts-actions { background: white; padding: 25px; border-radius: 16px; box-shadow: var(--shadow); margin-bottom: 25px; }
.inline-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 15px; align-items: end; }
.divider-text { text-align: center; color: #94a3b8; margin: 20px 0; position: relative; }
.divider-text:before, .divider-text:after { content: ''; position: absolute; top: 50%; width: 40%; height: 1px; background: #e2e8f0; }
.divider-text:before { right: 0; }
.divider-text:after { left: 0; }
.upload-form { display: flex; align-items: center; gap: 15px; }
.file-label { flex-grow: 1; padding: 12px; border: 2px dashed #cbd5e1; border-radius: 12px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: #64748b; transition: all 0.3s ease; }
.file-label:hover { border-color: var(--primary); color: var(--primary); background: rgba(99, 102, 241, 0.05); }

.table-container { background: white; padding: 20px; border-radius: 16px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: right; }
th { background: #f8fafc; color: #64748b; padding: 15px; font-weight: 600; border-bottom: 2px solid #e2e8f0; vertical-align: top; }
td { padding: 15px; border-bottom: 1px solid #f1f5f9; color: #334155; }
tr:hover td { background: #f8fafc; }
.empty-state { text-align: center; padding: 40px; color: #94a3b8; }
.empty-state span { font-size: 3rem; display: block; margin-bottom: 10px; }

/* SMS Section */
.sms-box { padding: 30px; background: white; }
.sms-selection-area { display: flex; gap: 15px; align-items: flex-end; margin-bottom: 15px; flex-wrap: wrap; }
.group-filter-wrapper select, .search-wrapper input { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-family: 'Vazirmatn'; background: #fff; outline: none; transition: border-color 0.3s; }
.group-filter-wrapper select:focus, .search-wrapper input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }
.action-buttons { display: flex; gap: 10px; }
.selected-count { margin-right: auto; font-size: 0.85rem; color: var(--primary); font-weight: 700; }
.phone-chips { display: flex; flex-wrap: wrap; gap: 10px; min-height: 50px; padding: 15px; background: #f8fafc; border-radius: 12px; margin-bottom: 10px; }
.chip { background: var(--primary); color: white; padding: 6px 12px; border-radius: 20px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; animation: popIn 0.3s ease; }
.chip span { cursor: pointer; opacity: 0.8; }
.chip span:hover { opacity: 1; }
.results-box { margin-top: 20px; padding: 15px; background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 12px; display: none; }
.results-box h4 { color: #166534; margin-bottom: 10px; }
.results-box p { font-size: 0.9rem; color: #14532d; padding: 4px 0; border-bottom: 1px dashed #dcfce7; }

.settings-card { max-width: 600px; background: white; padding: 30px; }

/* Toast */
#toast-container { position: fixed; top: 20px; left: 20px; z-index: 99999; }
.toast { background: white; padding: 16px 24px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; min-width: 300px; animation: slideIn 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); transition: all 0.3s ease; }
.toast.success { border-right: 5px solid var(--success); }
.toast.error { border-right: 5px solid var(--danger); }

/* Modal */
.modal-overlay { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); backdrop-filter: blur(5px); justify-content: center; align-items: center; }
.modal-content { background: white; padding: 30px; border-radius: 20px; width: 90%; max-width: 500px; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); animation: fadeUp 0.3s ease-out; position: relative; }
.modal-content h3 { margin-bottom: 20px; color: var(--text-dark); font-weight: 800; text-align: center; }

/* Search results dropdown */
.search-results-dropdown { position: absolute; top: 100%; right: 0; left: 0; background: white; border: 1px solid #e2e8f0; border-radius: 0 0 12px 12px; max-height: 250px; overflow-y: auto; z-index: 50; box-shadow: 0 10px 25px rgba(0,0,0,0.1); display: none; }
.search-result-item { padding: 10px 15px; border-bottom: 1px solid #f1f5f9; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: background 0.2s; }
.search-result-item:hover { background: #f8fafc; }
.search-result-item:last-child { border-bottom: none; }
.result-name { font-weight: 600; color: var(--text-dark); }
.result-phone { font-size: 0.85rem; color: #64748b; direction: ltr; }
.result-add-btn { background: var(--primary); color: white; border: none; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; cursor: pointer; }

/* Filters */
.filter-input, .filter-select { width: 100%; margin-top: 8px; padding: 6px; font-size: 0.75rem; border: 1px solid #e2e8f0; border-radius: 6px; font-family: 'Vazirmatn'; background: #f8fafc; transition: all 0.2s; }
.filter-input:focus, .filter-select:focus { border-color: var(--primary); background: #fff; outline: none; }
input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }

select { appearance: none; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%236366f1%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: left 15px top 50%; background-size: 12px auto; padding-left: 40px !important; }

/* Animations */
@keyframes fadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes popIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }
