/* =====================
   ساختمان‌یار - Main CSS
   ===================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --light-bg: #f8fafc;
    --card-radius: 12px;
    --sidebar-width: 250px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background-color: var(--light-bg);
    color: #1e293b;
}

/* Navbar */
.navbar-brand { font-size: 1.25rem; letter-spacing: -0.5px; }

/* Cards */
.card {
    border: none;
    border-radius: var(--card-radius);
    box-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 8px rgba(0,0,0,.04);
    transition: box-shadow .2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.card-header {
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    border-radius: var(--card-radius) var(--card-radius) 0 0 !important;
    font-weight: 600;
}

/* Stat Cards */
.stat-card {
    background: #fff;
    border-radius: var(--card-radius);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}
.stat-card .stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem; flex-shrink: 0;
}
.stat-card .stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { font-size: .8rem; color: var(--secondary); margin-top: 2px; }

/* Sidebar layout for building pages */
.building-layout {
    display: flex;
    min-height: calc(100vh - 56px);
}
.building-sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-left: 1px solid #e2e8f0;
    padding: 1rem 0;
    flex-shrink: 0;
    position: sticky;
    top: 56px;
    height: calc(100vh - 56px);
    overflow-y: auto;
}
.building-sidebar .nav-link.js-open-livechat,
.building-sidebar button.nav-link {
    border: none;
    background: transparent;
    cursor: pointer;
    width: 100%;
    text-align: inherit;
}
.building-content {
    flex: 1;
    padding: 1.5rem;
    overflow-x: hidden;
}

.sidebar-nav .nav-link {
    color: #475569;
    padding: .6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: .6rem;
    border-radius: 0;
    font-size: .9rem;
    transition: all .15s;
}
.sidebar-nav .nav-link:hover, .sidebar-nav .nav-link.active {
    background: #eff6ff;
    color: var(--primary);
}
.sidebar-nav .nav-link i { font-size: 1.1rem; width: 20px; }
.sidebar-section-label {
    padding: .35rem 1.25rem;
    font-size: .7rem;
    color: #94a3b8;
    letter-spacing: .6px;
    font-weight: 700;
}
.sidebar-subsection {
    padding: .2rem 1.25rem .15rem;
    font-size: .72rem;
    color: #64748b;
    font-weight: 700;
}
.sidebar-nav .nav-link-sub {
    padding-right: 1.75rem;
    font-size: .86rem;
}
.sidebar-badge {
    margin-right: auto;
    background: #f59e0b;
    color: #fff;
    font-size: .65rem;
    font-weight: 800;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Tables */
.table { font-size: .9rem; }
.table th { font-weight: 600; background: #f8fafc; border-color: #e2e8f0; }
.table td { border-color: #f1f5f9; vertical-align: middle; }

/* Forms */
.form-control, .form-select {
    border-radius: 8px;
    border-color: #e2e8f0;
    font-size: .9rem;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-label { font-weight: 500; font-size: .875rem; color: #374151; }

/* Buttons */
.btn { border-radius: 8px; font-size: .9rem; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* Badges */
.badge { border-radius: 6px; font-weight: 500; }

/* Chat */
.chat-container {
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}
.chat-bubble {
    max-width: 70%;
    margin-bottom: .75rem;
}
.chat-bubble.mine { margin-right: auto; margin-left: 0; }
.chat-bubble.theirs { margin-left: auto; margin-right: 0; }
.chat-bubble .bubble-body {
    padding: .6rem .9rem;
    border-radius: 12px;
    font-size: .9rem;
    line-height: 1.5;
}
.chat-bubble.mine .bubble-body {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.chat-bubble.theirs .bubble-body {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 3px;
}
.chat-bubble .bubble-meta { font-size: .72rem; color: #94a3b8; margin-top: 2px; }

/* Notification bell animation */
@keyframes ring {
    0%, 100% { transform: rotate(0); }
    20%, 60% { transform: rotate(10deg); }
    40%, 80% { transform: rotate(-10deg); }
}
.bell-animate { animation: ring .5s ease-in-out; }

/* Mobile bottom nav */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-around;
    padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom));
    z-index: 1040;
    box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.mobile-bottom-nav .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #64748b;
    font-size: .65rem;
    padding: .25rem .5rem;
    min-width: 48px;
    border: none;
    background: transparent;
    cursor: pointer;
}
.mobile-bottom-nav .bottom-nav-item i { font-size: 1.25rem; margin-bottom: 2px; }
.mobile-bottom-nav .bottom-nav-item.active,
.mobile-bottom-nav .bottom-nav-item:hover { color: var(--primary); }

.has-bottom-nav { padding-bottom: 72px; }
.has-bottom-nav + footer { margin-bottom: 60px; }

/* Auth pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: #fff;
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 10px 40px rgba(37,99,235,.12);
}
.auth-logo { font-size: 2rem; font-weight: 800; color: var(--primary); }

.captcha-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.captcha-row .captcha-image {
    width: 200px;
    height: 56px;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    object-fit: contain;
}
.captcha-row .form-control {
    flex: 1;
    min-width: 140px;
}
.captcha-row .btn {
    height: 42px;
    width: 42px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.page-header h4 { margin: 0; font-weight: 700; }

/* Empty state */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; display: block; }

/* Responsive */
@media (max-width: 768px) {
    .building-sidebar { display: none; }
    .building-content { padding: 1rem; }
    .stat-card .stat-value { font-size: 1.25rem; }
    .auth-card { margin: 0.75rem; }
}

/* Auto-wrap tables that aren't already in .table-responsive */
@media (max-width: 991.98px) {
    .building-content .card-body:has(> .table),
    .building-content .card-body:has(> table),
    .panel-content .card-body:has(> .table),
    .panel-content .card-body:has(> table) {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Flash toasts — compact system feedback */
.flash-toast-stack {
    position: fixed;
    top: max(16px, env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(420px, calc(100vw - 24px));
    pointer-events: none;
}
.navbar ~ .flash-toast-stack,
.panel-main > .flash-toast-stack {
    top: calc(68px + env(safe-area-inset-top, 0px));
}
body.has-bottom-nav .flash-toast-stack {
    top: auto;
    bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}
.flash-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px 14px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
    overflow: hidden;
    animation: flashToastIn 0.35s ease both;
}
.flash-toast.is-leaving {
    animation: flashToastOut 0.28s ease forwards;
}
.flash-toast-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}
.flash-toast-body {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.45;
    color: #0f172a;
    padding-top: 2px;
}
.flash-toast-close {
    border: none;
    background: transparent;
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
.flash-toast-close:hover {
    background: #f1f5f9;
    color: #475569;
}
.flash-toast-progress {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    height: 3px;
    transform-origin: right center;
    animation: flashToastProgress 4.2s linear forwards;
}
.flash-toast:hover .flash-toast-progress {
    animation-play-state: paused;
}

.flash-toast--success { border-color: #bbf7d0; }
.flash-toast--success .flash-toast-icon { background: #dcfce7; color: #16a34a; }
.flash-toast--success .flash-toast-progress { background: #22c55e; }

.flash-toast--danger,
.flash-toast--error { border-color: #fecaca; }
.flash-toast--danger .flash-toast-icon,
.flash-toast--error .flash-toast-icon { background: #fee2e2; color: #dc2626; }
.flash-toast--danger .flash-toast-progress,
.flash-toast--error .flash-toast-progress { background: #ef4444; }

.flash-toast--warning { border-color: #fde68a; }
.flash-toast--warning .flash-toast-icon { background: #fef3c7; color: #d97706; }
.flash-toast--warning .flash-toast-progress { background: #f59e0b; }

.flash-toast--info,
.flash-toast--secondary { border-color: #bfdbfe; }
.flash-toast--info .flash-toast-icon,
.flash-toast--secondary .flash-toast-icon { background: #dbeafe; color: #2563eb; }
.flash-toast--info .flash-toast-progress,
.flash-toast--secondary .flash-toast-progress { background: #3b82f6; }

@keyframes flashToastIn {
    from { opacity: 0; transform: translateY(-10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes flashToastOut {
    to { opacity: 0; transform: translateY(-8px) scale(0.96); }
}
@keyframes flashToastProgress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 576px) {
    .flash-toast-stack {
        width: calc(100vw - 16px);
    }
    body.has-bottom-nav .flash-toast-stack {
        bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }
}

/* Site footer */
.site-footer {
    line-height: 1.7;
}
.site-footer-sep {
    margin: 0 .35rem;
    opacity: .55;
}
.site-footer-author {
    color: var(--primary, #2563eb);
    font-weight: 700;
    text-decoration: none;
}
.site-footer-author:hover {
    text-decoration: underline;
}
.panel-footer {
    text-align: center;
    color: #94a3b8;
    font-size: .78rem;
    padding: 1.25rem 1rem 1.5rem;
    margin-top: auto;
}
.panel-footer a {
    color: #60a5fa;
    font-weight: 700;
    text-decoration: none;
}
.panel-footer a:hover { text-decoration: underline; }

/* ── Sticky hamburger + right drawer (mobile building menu) ── */
.site-navbar {
    z-index: 1030;
}
.site-navbar-inner {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: nowrap;
}
.building-menu-toggle {
    order: -1;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 12px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 1.45rem;
    line-height: 1;
    padding: 0;
    margin-inline-end: .15rem;
}
.building-menu-toggle:active,
.building-menu-toggle[aria-expanded="true"] {
    background: rgba(255, 255, 255, .22);
}
.building-drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 1040;
    opacity: 0;
    transition: opacity .28s ease;
}
.building-drawer-backdrop.is-open {
    opacity: 1;
}
.building-mobile-drawer {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: min(320px, 88vw);
    background: #ffffff;
    color: #0f172a;
    z-index: 1050;
    box-shadow: -12px 0 40px rgba(15, 23, 42, .18);
    transform: translateX(105%);
    transition: transform .3s cubic-bezier(.22, 1, .36, 1);
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0);
    padding-bottom: env(safe-area-inset-bottom, 0);
}
.building-mobile-drawer.is-open {
    transform: translateX(0);
}
.building-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1rem 1rem .85rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 2;
}
.building-drawer-head strong {
    display: block;
    font-size: 1.05rem;
    color: #0f172a;
}
.building-drawer-head small {
    display: block;
    color: #64748b;
    font-size: .8rem;
    margin-top: .15rem;
}
.building-drawer-close {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #0f172a;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
}
.building-drawer-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: .75rem 0 1.5rem;
    flex: 1;
}
.building-mobile-drawer .sidebar-nav .nav-link,
.building-drawer-extra .nav-link {
    color: #1e293b !important;
    font-size: 1.02rem;
    font-weight: 600;
    padding: .85rem 1.2rem;
    gap: .75rem;
    min-height: 48px;
}
.building-mobile-drawer .sidebar-nav .nav-link i,
.building-drawer-extra .nav-link i {
    color: #334155;
    font-size: 1.25rem;
    width: 24px;
}
.building-mobile-drawer .sidebar-nav .nav-link:hover,
.building-mobile-drawer .sidebar-nav .nav-link.active,
.building-drawer-extra .nav-link:hover {
    background: #eff6ff;
    color: #1d4ed8 !important;
}
.building-mobile-drawer .sidebar-section-label {
    color: #64748b;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    padding: .55rem 1.2rem .25rem;
}
.building-mobile-drawer .sidebar-subsection {
    color: #94a3b8;
    font-size: .8rem;
    padding: .35rem 1.2rem;
}
.building-drawer-extra {
    margin-top: .75rem;
    padding-top: .5rem;
    border-top: 1px solid #e2e8f0;
}
.building-drawer-extra .nav-link {
    display: flex;
    align-items: center;
    border: none;
    background: transparent;
    width: 100%;
    text-align: right;
}
body.building-drawer-open {
    overflow: hidden;
}
@media (min-width: 992px) {
    .building-menu-toggle,
    .building-mobile-drawer,
    .building-drawer-backdrop {
        display: none !important;
    }
}
