/* ==========================================================================
   SMART TECH CRM - Enterprise theme
   Palette: navy / blue / white. Supports light + dark and RTL + LTR
   (logical properties are used so one stylesheet serves both directions).
   ========================================================================== */

@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url('../vendor/fonts/cairo-arabic-400-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url('../vendor/fonts/cairo-arabic-600-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url('../vendor/fonts/cairo-arabic-700-normal.woff2') format('woff2'); unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: 'Cairo'; font-weight: 400; font-display: swap; src: url('../vendor/fonts/cairo-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Cairo'; font-weight: 600; font-display: swap; src: url('../vendor/fonts/cairo-latin-600-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }
@font-face { font-family: 'Cairo'; font-weight: 700; font-display: swap; src: url('../vendor/fonts/cairo-latin-700-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+2000-206F, U+20AC, U+2122; }

:root {
    --st-navy: #0b1f3a;
    --st-navy-2: #12305a;
    --st-blue: #1d6fe0;
    --st-blue-dark: #1556b3;
    --st-sidebar-w: 260px;
    --st-radius: 12px;
    --st-shadow: 0 1px 2px rgba(11, 31, 58, .06), 0 4px 16px rgba(11, 31, 58, .06);
    --bs-font-sans-serif: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    --bs-primary: #1d6fe0;
    --bs-primary-rgb: 29, 111, 224;
    --bs-link-color: #1d6fe0;
    --bs-link-hover-color: #1556b3;
    --bs-body-bg: #f3f6fb;
    --st-card-bg: #ffffff;
    --st-border: #e3e9f2;
    --st-muted-bg: #f7f9fc;
}
[data-bs-theme="dark"] {
    --bs-body-bg: #0a1424;
    --bs-body-color: #d7e0ee;
    --st-card-bg: #101f36;
    --st-border: #1f3354;
    --st-muted-bg: #0d1a2e;
    --bs-link-color: #6aa6ff;
    --bs-border-color: #1f3354;
    --st-shadow: 0 1px 2px rgba(0, 0, 0, .4);
}

body { font-family: var(--bs-font-sans-serif); background: var(--bs-body-bg); }
.btn-primary { --bs-btn-bg: var(--st-blue); --bs-btn-border-color: var(--st-blue); --bs-btn-hover-bg: var(--st-blue-dark); --bs-btn-hover-border-color: var(--st-blue-dark); --bs-btn-active-bg: var(--st-blue-dark); }
.card { background: var(--st-card-bg); border: 1px solid var(--st-border); border-radius: var(--st-radius); box-shadow: var(--st-shadow); }
.card-header { background: transparent; border-bottom: 1px solid var(--st-border); font-weight: 600; padding: .9rem 1.1rem; }
.form-label { font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select { border-radius: 8px; border-color: var(--st-border); background-color: var(--st-card-bg); }
.form-control:focus, .form-select:focus { border-color: var(--st-blue); box-shadow: 0 0 0 .2rem rgba(29, 111, 224, .15); }
[data-bs-theme="dark"] .form-control, [data-bs-theme="dark"] .form-select { background-color: #0d1a2e; }

/* ---- Shell ------------------------------------------------------------ */
.app-shell { display: flex; min-height: 100vh; }
.app-sidebar {
    width: var(--st-sidebar-w); flex: 0 0 var(--st-sidebar-w);
    background: linear-gradient(180deg, var(--st-navy) 0%, #0d2748 100%);
    color: #cfe0f7; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; z-index: 1040; overflow-y: auto;
}
.sidebar-brand { display: flex; align-items: center; gap: .75rem; padding: 1.1rem 1.1rem; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.brand-mark { width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, #2f86ff, #1556b3); display: grid; place-items: center; color: #fff; font-size: 1.3rem; flex: 0 0 auto; box-shadow: 0 4px 12px rgba(29, 111, 224, .45); }
.brand-mark-lg { width: 64px; height: 64px; font-size: 2rem; border-radius: 16px; }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 10px; background: #fff; padding: 3px; }
.brand-name { color: #fff; font-weight: 700; font-size: .98rem; line-height: 1.2; }
.brand-sub { font-size: .72rem; opacity: .6; }
.sidebar-nav { padding: .75rem .75rem; flex: 1; }
.nav-group-title { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; opacity: .5; padding: 1rem .75rem .4rem; }
.nav-item-link { display: flex; align-items: center; gap: .75rem; padding: .62rem .85rem; border-radius: 10px; color: #cfe0f7; text-decoration: none; font-weight: 500; font-size: .92rem; transition: background .15s, color .15s; margin-bottom: 2px; }
.nav-item-link i { font-size: 1.1rem; width: 1.3rem; text-align: center; opacity: .85; }
.nav-item-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item-link.active { background: var(--st-blue); color: #fff; box-shadow: 0 4px 12px rgba(29, 111, 224, .35); }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid rgba(255, 255, 255, .08); }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar { position: sticky; top: 0; z-index: 1030; height: 64px; display: flex; align-items: center; gap: .75rem; padding: 0 1.25rem; background: var(--st-card-bg); border-bottom: 1px solid var(--st-border); }
.topbar-title { font-weight: 700; font-size: 1.1rem; }
.topbar-actions { display: flex; align-items: center; gap: .4rem; }
.btn-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-grid; place-items: center; border: 0; background: transparent; color: inherit; font-size: 1.15rem; padding: 0; }
.btn-icon:hover { background: var(--st-muted-bg); }
.lang-btn { border: 1px solid var(--st-border); }
.user-btn { display: flex; align-items: center; gap: .5rem; border: 0; padding: .25rem .5rem; border-radius: 10px; }
.user-btn:hover { background: var(--st-muted-bg); }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.avatar-text { display: inline-grid; place-items: center; background: var(--st-blue); color: #fff; font-weight: 700; font-size: .85rem; }
.user-name { font-weight: 600; font-size: .9rem; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-dot { position: absolute; top: 4px; inset-inline-end: 3px; min-width: 18px; height: 18px; border-radius: 9px; background: #e5484d; color: #fff; font-size: .65rem; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.notif-menu { width: 360px; max-width: 92vw; border-radius: var(--st-radius); overflow: hidden; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--st-border); }
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-item { display: block; padding: .75rem 1rem; border-bottom: 1px solid var(--st-border); text-decoration: none; color: inherit; }
.notif-item:hover { background: var(--st-muted-bg); }
.notif-item.unread { background: rgba(29, 111, 224, .07); }
.notif-item .t { font-weight: 600; font-size: .88rem; }
.notif-item .b { font-size: .8rem; opacity: .75; }
.notif-item .m { font-size: .72rem; opacity: .55; margin-top: 2px; }
.notif-foot { display: block; text-align: center; padding: .65rem; font-size: .85rem; text-decoration: none; border-top: 1px solid var(--st-border); }

.app-content { padding: 1.5rem; flex: 1; }
.app-footer { padding: 1rem 1.5rem; font-size: .78rem; color: var(--bs-secondary-color); border-top: 1px solid var(--st-border); }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--bs-secondary-color); font-size: .88rem; }

/* ---- KPI + tables ------------------------------------------------------ */
.kpi { padding: 1.1rem 1.2rem; display: flex; align-items: center; gap: 1rem; height: 100%; }
.kpi-icon { width: 50px; height: 50px; border-radius: 13px; display: grid; place-items: center; font-size: 1.5rem; flex: 0 0 auto; }
.kpi-blue { background: rgba(29, 111, 224, .12); color: #1d6fe0; }
.kpi-green { background: rgba(25, 135, 84, .12); color: #198754; }
.kpi-amber { background: rgba(255, 159, 28, .15); color: #e08a00; }
.kpi-red { background: rgba(229, 72, 77, .12); color: #e5484d; }
.kpi-purple { background: rgba(124, 77, 255, .13); color: #7c4dff; }
.kpi-label { font-size: .8rem; color: var(--bs-secondary-color); font-weight: 600; }
.kpi-value { font-size: 1.55rem; font-weight: 700; line-height: 1.2; }
.table { --bs-table-bg: transparent; }
.table > :not(caption) > * > * { padding: .8rem 1rem; vertical-align: middle; }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--bs-secondary-color); background: var(--st-muted-bg); border-bottom: 1px solid var(--st-border); white-space: nowrap; }
.table-hover tbody tr:hover { background: var(--st-muted-bg); }
.filter-bar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; padding: 1rem 1.1rem; border-bottom: 1px solid var(--st-border); }
.filter-bar .form-control, .filter-bar .form-select { min-width: 150px; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--bs-secondary-color); }
.empty-state i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: .5rem; }
.confirm-icon { width: 64px; height: 64px; border-radius: 50%; background: rgba(229, 72, 77, .12); color: #e5484d; display: inline-grid; place-items: center; font-size: 1.9rem; }
.perm-module { border: 1px solid var(--st-border); border-radius: 10px; padding: .85rem 1rem; height: 100%; background: var(--st-muted-bg); }
.perm-module .form-check { margin-bottom: .25rem; }
.plan-card { position: relative; height: 100%; transition: transform .15s, box-shadow .15s; }
.plan-card:hover { transform: translateY(-3px); }
.plan-card.current { border-color: var(--st-blue); box-shadow: 0 0 0 2px rgba(29, 111, 224, .25); }
.plan-card .ribbon { position: absolute; top: 12px; inset-inline-end: 12px; }
.plan-price { font-size: 2rem; font-weight: 700; }
.timeline-item { display: flex; gap: .75rem; padding: .7rem 0; border-bottom: 1px dashed var(--st-border); }
.timeline-item:last-child { border-bottom: 0; }
.timeline-dot { width: 34px; height: 34px; border-radius: 50%; background: rgba(29, 111, 224, .12); color: var(--st-blue); display: grid; place-items: center; flex: 0 0 auto; }
.chart-box { position: relative; height: 280px; }
.qr-box { background: #fff; padding: 12px; border-radius: 10px; display: inline-block; }
.secret-code { font-family: Consolas, monospace; letter-spacing: .12em; background: var(--st-muted-bg); border: 1px dashed var(--st-border); border-radius: 8px; padding: .4rem .7rem; word-break: break-all; direction: ltr; display: inline-block; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"], [dir="rtl"] input[type="tel"], [dir="rtl"] input[type="password"] { text-align: end; }
[dir="rtl"] input[type="email"], [dir="rtl"] input[type="url"], [dir="rtl"] input[type="password"], .ltr-text { direction: ltr; }
[dir="rtl"] input[type="email"]::placeholder, [dir="rtl"] input[type="url"]::placeholder { text-align: end; }
.ltr-text { unicode-bidi: plaintext; direction: ltr; display: inline-block; }
td.ltr-text, th.ltr-text { display: table-cell; text-align: start; }

/* ---- Auth ------------------------------------------------------------- */
.auth-body { background: var(--bs-body-bg); }
.auth-split { display: flex; min-height: 100vh; }
.auth-hero { flex: 1 1 46%; background: radial-gradient(circle at 20% 10%, #1d4f9f 0%, var(--st-navy) 55%, #07142a 100%); color: #fff; align-items: center; justify-content: center; padding: 3rem; }
.auth-hero-inner { max-width: 460px; }
.auth-features li { padding: .45rem 0; font-size: 1.02rem; }
.auth-features i { color: #5fd3a0; margin-inline-end: .6rem; }
.auth-panel { flex: 1 1 54%; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.5rem; position: relative; }
.auth-topbar { position: absolute; top: 1rem; inset-inline-end: 1rem; display: flex; gap: .5rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card.wide { max-width: 640px; }
.auth-card h2 { font-weight: 700; }

/* ---- Print (invoices) -------------------------------------------------- */
.print-body { background: #eef1f6; }
.print-toolbar { max-width: 820px; margin: 1rem auto; display: flex; gap: .5rem; }
.print-sheet { background: #fff; color: #111; max-width: 820px; margin: 0 auto 2rem; padding: 2.5rem; box-shadow: 0 4px 24px rgba(0, 0, 0, .1); border-radius: 6px; }
@media print {
    .no-print { display: none !important; }
    .print-body { background: #fff; }
    .print-sheet { box-shadow: none; margin: 0; max-width: none; padding: 0; }
}

/* ---- Responsive ------------------------------------------------------- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .app-sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; transform: translateX(-100%); transition: transform .25s; width: 280px; }
    [dir="rtl"] .app-sidebar { transform: translateX(100%); }
    body.sidebar-open .app-sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 1035; }
    .app-content { padding: 1rem; }
    .app-topbar { padding: 0 .75rem; }
}
@media (max-width: 575.98px) {
    .kpi-value { font-size: 1.3rem; }
    .table-responsive-stack td { display: block; }
}

/* ---- Kanban pipeline ---------------------------------------------------- */
.kanban { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kb-col { flex: 0 0 280px; background: var(--st-muted-bg); border: 1px solid var(--st-border); border-radius: var(--st-radius); min-height: 220px; transition: background .15s, outline .15s; }
.kb-col.over { outline: 2px dashed var(--st-blue); background: rgba(29, 111, 224, .06); }
.kb-head { padding: .75rem .9rem; border-radius: var(--st-radius) var(--st-radius) 0 0; background: var(--st-card-bg); border-bottom: 1px solid var(--st-border); }
.kb-list { padding: .6rem; display: flex; flex-direction: column; gap: .6rem; min-height: 120px; }
.kb-card { background: var(--st-card-bg); border: 1px solid var(--st-border); border-radius: 10px; padding: .75rem .85rem; box-shadow: var(--st-shadow); cursor: grab; }
.kb-card.dragging { opacity: .45; }
.kb-card[data-status="won"] { border-inline-start: 4px solid #198754; }
.kb-card[data-status="lost"] { border-inline-start: 4px solid #e5484d; }
.stage-row { display: grid; grid-template-columns: auto 1fr 90px 60px auto; gap: .5rem; align-items: center; }

/* ---- Calendar ------------------------------------------------------------ */
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head > div { padding: .6rem; font-weight: 600; font-size: .8rem; text-align: center; background: var(--st-muted-bg); border-bottom: 1px solid var(--st-border); }
.cal-cell { min-height: 110px; padding: .35rem; border-inline-end: 1px solid var(--st-border); border-bottom: 1px solid var(--st-border); overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.cal-cell.other { background: var(--st-muted-bg); opacity: .65; }
.cal-cell.today { outline: 2px solid var(--st-blue); outline-offset: -2px; }
.cal-num { font-weight: 700; font-size: .85rem; text-decoration: none; }
.cal-add { opacity: 0; text-decoration: none; font-weight: 700; }
.cal-cell:hover .cal-add { opacity: 1; }
.cal-chip { display: block; font-size: .7rem; padding: 1px 5px; border-radius: 5px; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 767.98px) { .cal-cell { min-height: 64px; } .cal-chip { font-size: .62rem; } }

/* Collapsible sidebar groups */
.nav-group-toggle { display: flex; width: 100%; align-items: center; justify-content: space-between; background: none; border: 0; color: inherit; font-size: 1rem; font-weight: 600; opacity: .95; padding: .8rem .75rem; cursor: pointer; text-align: start; }
.nav-group-toggle:hover { opacity: 1; }
.nav-group-toggle i { transition: transform .2s; font-size: .85rem; }
.nav-group-toggle.open i { transform: rotate(180deg); }
.nav-group-items { display: none; }
.nav-group-items.open { display: block; }
