/* مسکن پرستیژ — CRM
   نسخه ساده/مینیمال، موبایل‌فرست، بدون فونت اختصاصی (فونت سیستم = سریع‌ترین و
   تمیزترین حالت ممکن، هیچ وابستگی به دانلود یا سرور خارجی نداره) */

:root {
    --primary: #0F6E5C;
    --primary-dark: #0B5347;
    --primary-light: #E4F3EF;
    --ink: #1A1D1B;
    --muted: #6B7269;
    --bg: #F7F8F6;
    --card: #FFFFFF;
    --line: #E4E6E1;
    --danger: #C0392B;
    --danger-bg: #FBEAE8;
    --success: #1F7A4D;
    --success-bg: #E7F4EC;
    --warn: #B8860B;
    --warn-bg: #FBF3E0;
    --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    margin: 0;
    direction: rtl;
    font-size: 15px;
    line-height: 1.55;
}

h1, h2, h3 { font-weight: 700; margin: 0 0 16px; color: var(--ink); }
h1 { font-size: 1.35rem; }
h3 { font-size: 1rem; margin: 26px 0 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.02em; font-size: 0.82rem; }

a { color: var(--primary); }

/* --- لوگو --- */
.logo-mark {
    display: inline-flex; align-items: center; gap: 8px;
}
.logo-mark svg { flex-shrink: 0; }
.logo-text { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }

/* --- نوار بالا: موبایل‌فرست، ثابت پایین صفحه در موبایل مثل اپ --- */
.topbar {
    background: var(--card);
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 56px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .brand { color: var(--primary); }
.topbar nav {
    display: none; /* در موبایل با منوی پایین صفحه جایگزین می‌شود */
}
.user-menu { display: flex; gap: 12px; align-items: center; font-size: 0.85rem; }
.user-menu span { display: none; }
.user-menu a { color: var(--muted); text-decoration: none; font-weight: 600; }

/* منوی پایین صفحه — استاندارد اپ‌های موبایل */
.bottom-nav {
    position: fixed; bottom: 0; right: 0; left: 0;
    background: var(--card);
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: space-around;
    padding: 6px 0 max(6px, env(safe-area-inset-bottom));
    z-index: 20;
}
.bottom-nav a {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted); text-decoration: none; font-size: 0.68rem; font-weight: 600;
    padding: 4px 10px; border-radius: 8px;
}
.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary); background: var(--primary-light); }
.bottom-nav svg { width: 22px; height: 22px; }

@media (min-width: 700px) {
    .topbar nav { display: flex; align-items: center; gap: 2px; }
    .topbar nav a { color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-size: 0.88rem; font-weight: 600; }
    .topbar nav a:hover { background: var(--primary-light); color: var(--primary-dark); }
    .user-menu span { display: inline; color: var(--muted); font-weight: 600; }
    .bottom-nav { display: none; }
    .container { padding-bottom: 36px; }
}

.container { max-width: 760px; margin: 0 auto; padding: 18px 16px 90px; }

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { margin: 0; }

/* --- کارت‌ها و فرم‌ها --- */
.form-card, .login-box {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
    margin-bottom: 20px;
}

.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); padding: 20px; }
.login-box { width: 100%; max-width: 360px; padding: 32px 26px; text-align: center; }
.login-box .brand-mark { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 6px; }
.login-box .logo-text { font-size: 1.4rem; color: var(--ink); }
.login-box .brand-tagline { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.1em; margin-bottom: 26px; font-weight: 600; }
.login-box h1 { text-align: center; font-size: 0.95rem; color: var(--muted); font-weight: 500; margin-bottom: 20px; }
.login-box form { text-align: right; }

.form-row { display: flex; flex-direction: column; gap: 14px; margin-bottom: 0; }
@media (min-width: 640px) {
    .form-row { flex-direction: row; gap: 16px; }
}
.form-row label, .full-width { flex: 1; display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); margin-bottom: 14px; }

input, select, textarea {
    font-family: inherit;
    padding: 12px 14px;
    border: 1.5px solid var(--line);
    border-radius: 10px;
    font-size: 1rem;   /* حداقل 16px معادل جلوگیری از زوم خودکار سافاری موبایل */
    color: var(--ink);
    background: #fff;
    width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

button, .btn-primary, .btn-secondary {
    padding: 13px 22px;
    border-radius: 10px;
    border: none;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px; /* حداقل اندازه لمسی مناسب موبایل */
    transition: background 0.15s ease, transform 0.1s ease;
}
button, .btn-primary { background: var(--primary); color: #fff; }
button:hover, .btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); }
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 0.87rem; font-weight: 600; }
.alert-error { background: var(--danger-bg); color: var(--danger); }

.search-bar { display: flex; gap: 8px; margin-bottom: 16px; }
.search-bar input { flex: 1; }

/* --- لیست‌ها: کارت به‌جای جدول عریض در موبایل --- */
.data-table { width: 100%; border-collapse: collapse; }
.data-table thead { display: none; }
.data-table tbody { display: flex; flex-direction: column; gap: 10px; }
.data-table tr {
    display: flex; flex-direction: column; gap: 4px;
    background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px;
}
.data-table td { border: none; padding: 2px 0; font-size: 0.88rem; }
.data-table td:first-child { font-weight: 700; font-size: 0.95rem; }
.data-table tr[data-href] { cursor: pointer; }
.data-table tr[data-href]:active { background: var(--primary-light); }
.data-table .empty { text-align: center; color: var(--muted); padding: 30px 10px; background: none; border: none; }

@media (min-width: 700px) {
    .data-table { background: var(--card); border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
    .data-table thead { display: table-header-group; }
    .data-table tbody { display: table-row-group; }
    .data-table tr { display: table-row; border: none; border-radius: 0; padding: 0; border-bottom: 1px solid var(--line); }
    .data-table tr:last-child { border-bottom: none; }
    .data-table th, .data-table td { padding: 13px 14px; text-align: right; }
    .data-table th { background: var(--bg); color: var(--muted); font-weight: 700; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
    .data-table td { font-size: 0.89rem; }
    .data-table td:first-child { font-weight: 600; font-size: 0.89rem; }
    .data-table tr[data-href]:hover { background: var(--primary-light); }
    .data-table tr[data-href]:active { background: var(--primary-light); }
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 700; background: var(--line); color: var(--muted); }
.badge-new { background: #E1EEFB; color: #1D5A96; }
.badge-in_progress { background: var(--warn-bg); color: var(--warn); }
.badge-negotiating { background: var(--primary-light); color: var(--primary-dark); }
.badge-closed_won { background: var(--success-bg); color: var(--success); }
.badge-closed_lost { background: var(--danger-bg); color: var(--danger); }

.detail-grid { display: grid; grid-template-columns: 1fr; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; margin-bottom: 18px; font-size: 0.88rem; }
@media (min-width: 640px) { .detail-grid { grid-template-columns: 1fr 1fr; gap: 10px 24px; } }
.detail-grid strong { color: var(--ink); }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.timeline-meta { font-size: 0.76rem; color: var(--muted); margin-bottom: 8px; font-weight: 600; }
.timeline-meta a { color: var(--primary); font-weight: 700; }
.timeline-note { font-size: 0.9rem; }

.entry-type-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.entry-type-tabs label {
    flex: 1; flex-direction: row; align-items: center; justify-content: center; gap: 6px; display: flex;
    color: var(--muted); font-weight: 600; font-size: 0.85rem; margin-bottom: 0;
    border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer;
}
.entry-type-tabs input[type="radio"] { width: auto; accent-color: var(--primary); }
.entry-type-tabs label:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

.recorder-box { margin-bottom: 14px; }
.record-btn, .stop-btn {
    display: inline-flex; align-items: center; gap: 8px; width: 100%;
    background: var(--primary); color: #fff; border: none;
    padding: 14px 22px; border-radius: 12px; font-size: 0.95rem; font-weight: 700; cursor: pointer;
}
.record-btn:hover, .stop-btn:hover { background: var(--primary-dark); }
.stop-btn { background: var(--danger); }
.recording-ui { display: flex; align-items: center; gap: 12px; background: var(--danger-bg); border-radius: 12px; padding: 12px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; flex-shrink: 0; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.recorded-preview { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.recorded-preview audio { flex: 1; min-width: 200px; }

.voice-bubble { display:flex; align-items:center; gap:10px; background:var(--primary-light); border-radius:12px; padding:12px 14px; }
.voice-bubble .play-btn { background:var(--primary); color:#fff; border-radius:50%; width:34px; height:34px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.voice-wave { flex:1; height:20px; background: repeating-linear-gradient(90deg, var(--primary) 0 3px, transparent 3px 6px); opacity:0.5; border-radius: 4px; }
.voice-duration { font-size:0.78rem; color:var(--primary-dark); font-weight: 700; }

.reassign-form { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; }
@media (min-width: 640px) { .reassign-form { flex-direction: row; align-items: flex-end; } }
.reassign-form label { flex: 1; margin-bottom: 0; }
.reassign-form .form-actions { margin: 0; }

.stat-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 8px; text-align: center; }
.stat-num { font-size: 1.5rem; font-weight: 800; color: var(--primary); }
.stat-label { font-size: 0.7rem; color: var(--muted); margin-top: 4px; font-weight: 600; }
@media (min-width: 640px) {
    .stat-card { padding: 22px; }
    .stat-num { font-size: 2rem; }
    .stat-label { font-size: 0.8rem; }
}

.comment-list { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.comment-item { background: var(--bg); border-radius: 10px; padding: 9px 12px; margin-bottom: 6px; font-size: 0.85rem; }
.comment-item strong { color: var(--primary-dark); }
.comment-item .comment-date { color: var(--muted); font-size: 0.72rem; margin-right: 8px; display: block; margin-top: 2px; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form input[type="text"] { flex: 1; }
.comment-form button { padding: 10px 16px; font-size: 0.85rem; min-height: 40px; }
.comment-form .mic-toggle-btn { flex-shrink: 0; padding: 10px 14px; }
