/* ============================================================
   CRM الماس - استایل اصلی - نسخه ۲.۰
   ============================================================ */

@font-face {
    font-family: 'IranSansX';
    src: url('/assets/fonts/iransansx.woff') format('woff');
    font-weight: normal;
    font-style: normal;
}
@font-face {
    font-family: 'IranSansX';
    src: url('/assets/fonts/iransansxbold.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
}
:root {
    --primary:   #011830;
    --secondary: #2d6a9f;
    --accent:    #e8a917;
    --success:   #28a745;
    --danger:    #dc3545;
    --warning:   #ffc107;
    --sidebar-w: 260px;
    --header-h:  60px;
}

* { box-sizing: border-box; }

body {
    font-family: 'IranSansX', Tahoma, Arial, sans-serif;
    background: #f0f2f5;
    margin: 0; padding: 0;
    direction: rtl;
    color: #2c3e50;
}

/* ---- LAYOUT ---- */
.wrapper { display: flex; flex-direction: column; min-height: 100vh; }

.main-header {
    background: var(--primary);
    color: white;
    height: var(--header-h);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    position: fixed;
    top: 0; right: 0; left: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}

.main-header .logo-area { display: flex; align-items: center; gap: 10px; }
.main-header .logo-area img { height: 36px; }
.main-header .logo-area span { font-size: 16px; font-weight: bold; }
.main-header .user-info { display: flex; align-items: center; gap: 12px; font-size: 14px; }

.btn-logout {
    background: rgba(255,255,255,.15);
    color: white;
    border: 1px solid rgba(255,255,255,.3);
    padding: 5px 14px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 13px;
    transition: .2s;
}
.btn-logout:hover { background: var(--danger); color: white; }

/* ---- SIDEBAR ---- */
.page-body { display: flex; margin-top: var(--header-h); }

.main-sidebar {
    width: var(--sidebar-w);
    background: var(--primary);
    min-height: calc(100vh - var(--header-h));
    position: fixed;
    top: var(--header-h);
    right: 0;
    overflow-y: auto;
    z-index: 900;
}

.main-sidebar ul { list-style: none; padding: 10px 0; margin: 0; }
.main-sidebar ul li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    border-right: 3px solid transparent;
    transition: .2s;
}
.main-sidebar ul li a:hover,
.main-sidebar ul li a.active {
    background: rgba(255,255,255,.08);
    color: white;
    border-right-color: var(--accent);
}
.main-sidebar ul li a .nav-icon { font-size: 18px; width: 22px; text-align: center; }
.sidebar-section {
    padding: 8px 20px 4px;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 10px;
}

/* ---- CONTENT ---- */
.content-area {
    margin-right: var(--sidebar-w);
    flex: 1;
    padding: 24px;
    min-height: calc(100vh - var(--header-h));
}

/* ---- PAGE TITLE ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.page-title { font-size: 20px; font-weight: bold; color: var(--primary); margin: 0; }
.page-title small { font-size: 13px; color: #64748b; }

/* ---- STAT CARDS ---- */
.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,.06);
    border-top: 4px solid transparent;
    transition: transform .2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-card.blue  { border-top-color: #3498db; }
.stat-card.green { border-top-color: var(--success); }
.stat-card.gold  { border-top-color: var(--accent); }
.stat-card.red   { border-top-color: var(--danger); }
.stat-card.purple{ border-top-color: #9b59b6; }
.stat-card h3    { font-size: 28px; font-weight: bold; margin: 0 0 6px; color: var(--primary); }
.stat-card p     { margin: 0; color: #64748b; font-size: 13px; }

/* ---- CARDS ---- */
.card { border: none; box-shadow: 0 2px 8px rgba(0,0,0,.06); border-radius: 10px; }
.card-header { background: white; border-bottom: 1px solid #f0f2f5; font-weight: bold; padding: 14px 20px; }

/* ---- TABLES ---- */
.table-container { background: white; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,.06); overflow: hidden; }
.table-container .table-toolbar { padding: 14px 16px; border-bottom: 1px solid #f0f2f5; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.table-container table { margin: 0; }
.table thead th { background: var(--primary); color: white; border: none; padding: 12px 10px; font-size: 13px; font-weight: normal; }
.table tbody tr:hover { background: #f8fafc; }
.table td { vertical-align: middle; padding: 10px; font-size: 13px; border-color: #f0f2f5; }

/* ---- SEARCH ---- */
.search-box { position: relative; }
.search-box input { padding-right: 36px; border-radius: 8px; border: 1px solid #e2e8f0; font-family: 'IranSansX'; font-size: 13px; }
.search-box::before { content: '🔍'; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-size: 14px; }

/* ---- BADGES ---- */
.badge-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: normal;
}
.badge-waiting   { background: #e3f2fd; color: #1565c0; }
.badge-scheduled { background: #e8f5e9; color: #2e7d32; }
.badge-failed    { background: #fce4ec; color: #c62828; }
.badge-active    { background: #e8f5e9; color: #2e7d32; }
.badge-cancelled { background: #fce4ec; color: #c62828; }
.badge-converted { background: #f3e5f5; color: #6a1b9a; }
.badge-no_show   { background: #fff3e0; color: #e65100; }

/* ---- LOGIN PAGE ---- */
body.login-page {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    text-align: center;
}
.login-box img { height: 60px; margin-bottom: 20px; }
.login-box h2 { font-size: 18px; margin-bottom: 30px; color: var(--primary); }
.login-box .form-control { text-align: right; font-family: 'IranSansX';font-size: 16px; }
.btn-login {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-family: 'IranSansX';
    font-size: 15px;
    cursor: pointer;
    transition: .2s;
    margin-top: 10px;
}
.btn-login:hover { background: var(--secondary); }
.login-error { background: #fce4ec; color: #c62828; padding: 10px; border-radius: 8px; margin-bottom: 16px; font-size: 13px; }

/* ---- MODALS ---- */
.modal-content { border-radius: 12px; border: none; }
.modal-header  { background: var(--primary); color: white; border-radius: 12px 12px 0 0; }
.modal-header .btn-close { filter: invert(1); }
.modal-title   { font-size: 16px; }

/* ---- FORMS ---- */
.form-label    { font-size: 13px; color: #475569; margin-bottom: 4px;}
.form-control, .form-select { font-family: 'IranSansX'; font-size: 13px; border-radius: 7px; border: 1px solid #e2e8f0; }
.form-control:focus, .form-select:focus { border-color: var(--secondary); box-shadow: 0 0 0 2px rgba(45,106,159,.15); }

/* ---- BUTTONS ---- */
.btn { font-family: 'IranSansX'; font-size: 13px; border-radius: 7px; }
.btn-primary   { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--secondary); border-color: var(--secondary); }

/* ---- CUSTOMER DETAIL ---- */
.customer-timeline { position: relative; padding-right: 30px; }
.customer-timeline::before { content:''; position:absolute; right:12px; top:0; bottom:0; width:2px; background:#e2e8f0; }
.timeline-item { position:relative; margin-bottom:24px; }
.timeline-item::before { content:''; position:absolute; right:-22px; top:6px; width:12px; height:12px; border-radius:50%; background:var(--secondary); border:2px solid white; box-shadow:0 0 0 2px var(--secondary); }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .main-sidebar { width: 200px; }
    .content-area { margin-right: 200px; padding: 16px; }
}

/* ---- TOAST NOTIFICATIONS ---- */
#toast-container { position: fixed; top: 80px; left: 20px; z-index: 9999; }
.toast-msg {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    margin-bottom: 8px;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    animation: slideIn .3s ease;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
@keyframes slideIn { from { transform: translateX(-20px); opacity:0; } to { transform:translateX(0); opacity:1; } }

/* ---- AREA CHECKBOXES ---- */
.area-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.area-chip { display: flex; align-items: center; gap: 6px; }
.area-chip input { display: none; }
.area-chip label {
    padding: 5px 12px;
    border: 2px solid #e2e8f0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: .2s;
    user-select: none;
}
.area-chip input:checked + label { background: var(--secondary); color: white; border-color: var(--secondary); }

/* ============================================================
   CRM v2.0 - Additions
   ============================================================ */

/* Sortable table headers */
th[data-sort]:hover { background: rgba(0,0,0,0.05); }
th.sort-asc::after  { content: ' ↑'; color: #0d6efd; font-size:12px; }
th.sort-desc::after { content: ' ↓'; color: #0d6efd; font-size:12px; }

/* Money input - فیلد تومان */
.money-input { font-family: inherit; }

/* Nav tabs */
.nav-tabs .nav-link { color: #495057; }
.nav-tabs .nav-link.active { font-weight: 600; }

/* Spinner */
.spinner-border { width:2rem; height:2rem; }

/* Badge status improvements */
.badge { font-size: 12px; }

/* List group in search results */
.list-group-item.customer-select-item { cursor:pointer; }

/* ---- v5 additions ---- */
.header-date-box { flex:1; text-align:center; }
.jalali-today-badge { background:rgba(255,255,255,.18); color:#fff; padding:5px 16px; border-radius:20px; font-size:13px; }
/* tooltip buttons */
.btn-icon { position:relative; }
.btn-icon:hover::after { content:attr(data-tip); position:absolute; bottom:calc(100% + 6px); left:50%; transform:translateX(-50%);
  background:#1a3c5e; color:#fff; padding:4px 10px; border-radius:6px; font-size:12px; white-space:nowrap; z-index:9999; pointer-events:none; }
.btn-icon:hover::before { content:''; position:absolute; bottom:calc(100% + 2px); left:50%; transform:translateX(-50%);
  border:4px solid transparent; border-top-color:#1a3c5e; z-index:9999; }
/* toast */
.toast-msg { position:fixed; bottom:24px; left:24px; z-index:99999; padding:12px 24px; border-radius:8px; color:#fff;
  font-size:14px; box-shadow:0 4px 15px rgba(0,0,0,.2); animation:slideUp .3s ease; }
.toast-success { background:#28a745; } .toast-error { background:#dc3545; }
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }
/* area chips */
.area-grid { display:flex; flex-wrap:wrap; gap:8px; }
.area-chip input[type=checkbox] { display:none; }
.area-chip label { padding:5px 14px; border:1px solid #dee2e6; border-radius:20px; cursor:pointer; font-size:13px; transition:.15s; user-select:none; }
.area-chip input:checked + label { background:#1a3c5e; color:white; border-color:#1a3c5e; }
/* sort */
.si { color:#ffc107; font-size:10px; }
/* load more */
#leadsTable_loadmore, #failedLeadsTable_loadmore, #fsTable_loadmore, #failedFSTable_loadmore,
#contractsTable_loadmore, #sessionsTable_loadmore, #customersTable_loadmore { border-top:1px solid #f0f2f5; }
