/* فونت‌ها از خود برنامه بارگذاری می‌شوند (بدون وابستگی به اینترنت/CDN) — وزیرمتن، مجوز OFL */
@font-face { font-family: Vazirmatn; src: url('../fonts/Vazirmatn-FD-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Vazirmatn; src: url('../fonts/Vazirmatn-FD-Bold.woff2') format('woff2'); font-weight: 700 900; font-display: swap; }

/* رنگ‌های برند؛ مقدار واقعی را تنظیمات مهد (header/login) بعد از این فایل بازنویسی می‌کند */
:root {
    --teal: #1F6F5C;
    --teal-dark: #14483C;
    --teal-light: #2E9E6F;
    --day-strong: var(--teal);
    --day-deep: var(--teal-dark);
    --day-soft: var(--teal-light);
    --cream: #FAF7F0;
    --cream-2: #F1ECDF;
    --ink: #2B2B26;
    --danger: #D64545;
    --card-radius: 18px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.18);
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: Vazirmatn, Tahoma, sans-serif;
    background: var(--cream);
    color: var(--ink);
    direction: rtl;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
.latin { font-family: Tahoma, Arial, sans-serif !important; direction: ltr; text-align: left; }

/* ============ صفحات ورود/نصب ============ */
.auth-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    background: linear-gradient(135deg, var(--day-strong) 0%, var(--day-deep) 100%);
}
.auth-card {
    background: #fff;
    border-radius: 24px;
    box-shadow: var(--shadow-lg);
    padding: 34px 28px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.auth-logo { font-size: 48px; margin-bottom: 6px; line-height: 1.2; }
.auth-card h1 { font-size: 20px; margin: 6px 0 2px; color: var(--teal-dark); overflow-wrap: anywhere; }
.auth-subtitle { color: #8a8578; font-size: 14px; margin: 0 0 18px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; text-align: right; margin-top: 10px; }
.auth-form label { font-size: 13px; color: #6b6759; display: flex; flex-direction: column; gap: 6px; }
.auth-links { margin-top: 14px; font-size: 13px; }
.auth-links a { color: var(--teal); }

input, select, textarea {
    font-family: inherit;
    font-size: 15px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1.5px solid #E5E1D8;
    background: #fff;
    color: var(--ink);
    width: 100%;
    min-width: 0;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--teal-light);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
}

/* ============ دکمه‌ها و پیام‌ها ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: 12px;
    border: none;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(0.97); }
.btn-block { width: 100%; }
.btn-primary { background: linear-gradient(135deg, var(--day-soft), var(--day-strong)); color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18); }
.btn-outline { background: #fff; color: var(--teal); border: 1.5px solid var(--teal-light); }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.alert { padding: 12px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 14px; text-align: right; }
.alert-success { background: #E4F5EC; color: #1E7A4C; }
.alert-error { background: #FBE7E7; color: #B23A3A; }
.alert-warning { background: #FDF1DC; color: #96650F; }
.alert-info { background: #E9F0FA; color: #2F5C96; }

/* ============ چارچوب برنامه (بعد از ورود) ============ */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
    background: linear-gradient(120deg, var(--day-deep), var(--day-strong));
    color: #fff;
    padding: 12px 20px;
    padding-top: calc(12px + env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}
.app-header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; min-width: 0; }
.app-header .brand .bname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header .brand .emoji { font-size: 24px; }
.app-header .user-chip {
    background: rgba(255, 255, 255, 0.15);
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
}
.app-header .user-chip .uname { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-install-app {
    display: inline-flex; align-items: center; gap: 5px;
    border: 1px solid rgba(255, 255, 255, .5);
    background: rgba(255, 255, 255, 0.18);
    color: #fff; font-family: inherit; font-size: 12.5px; font-weight: 700;
    padding: 6px 12px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.app-main {
    flex: 1;
    padding: 18px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

.toast {
    position: fixed; bottom: calc(20px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
    background: var(--teal-dark); color: #fff; padding: 12px 22px; border-radius: 999px;
    font-size: 14px; box-shadow: var(--shadow-lg); z-index: 200; opacity: 0; transition: opacity .3s, transform .3s;
    pointer-events: none; max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-6px); }

.blogo { height: 32px; width: auto; max-width: 120px; object-fit: contain; border-radius: 6px; background: #fff; padding: 2px; flex-shrink: 0; }
.alogo { max-height: 84px; max-width: 220px; object-fit: contain; }
.blogo-prev { max-height: 64px; max-width: 200px; object-fit: contain; border: 1px solid #e2e8f0; border-radius: 8px; padding: 4px; background: #fff; }

/* ============ موبایل ============ */
@media (max-width: 640px) {
    .app-main { padding: 12px; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
    .app-header { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
    .app-header .brand { font-size: 15px; }
    .app-header .user-chip { font-size: 12px; padding: 6px 10px; gap: 6px; }
    .app-header .user-chip .uname { max-width: 80px; }
    .app-header .user-chip .urole { display: none; }
    .auth-card { padding: 26px 20px; }
    /* جلوگیری از زوم خودکار iOS هنگام فوکوس روی فیلدها */
    input, select, textarea { font-size: 16px; }
}
@media (max-width: 380px) {
    .app-header .brand .blogo { height: 26px; }
    .btn-install-app { padding: 5px 9px; }
}
@media print {
    .app-header, .toast { display: none !important; }
    html, body { background: #fff; }
}
