/* ==========================================================
   Nabd AI – Application stylesheet
   Brand: orange (#E87722) / dark gray (#2B2B2B) / white
   ========================================================== */

:root {
    --brand-primary: #E87722;
    --brand-primary-600: #D26A1A;
    --brand-dark: #2B2B2B;
    --brand-dark-2: #1F1F1F;
    --brand-light: #FFFFFF;
    --brand-bg: #F5F6F8;
    --brand-border: #E5E7EB;
    --sidebar-w: 250px;
    --topbar-h: 60px;
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
}

body {
    font-family: 'Cairo', system-ui, -apple-system, 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--brand-bg);
    color: #222;
    margin: 0;
}

/* Bootstrap brand overrides */
.btn-primary,
.btn-primary:focus {
    --bs-btn-bg: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary-600);
    --bs-btn-hover-border-color: var(--brand-primary-600);
    --bs-btn-active-bg: var(--brand-primary-600);
    --bs-btn-active-border-color: var(--brand-primary-600);
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-primary);
    --bs-btn-border-color: var(--brand-primary);
    --bs-btn-hover-bg: var(--brand-primary);
    --bs-btn-hover-border-color: var(--brand-primary);
}
.text-primary { color: var(--brand-primary) !important; }
.bg-primary   { background-color: var(--brand-primary) !important; }
a { color: var(--brand-primary); }
a:hover { color: var(--brand-primary-600); }

/* ==========================================================
   App shell
   ========================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.app-sidebar {
    width: var(--sidebar-w);
    background: var(--brand-dark);
    color: #d9d9d9;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.app-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    padding: 24px;
    flex: 1;
}

.app-footer {
    border-top: 1px solid var(--brand-border);
    background: #fff;
}

/* ==========================================================
   Sidebar
   ========================================================== */
.sidebar-brand {
    padding: 18px 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-bottom: 1px solid #3a3a3a;
}
.brand-mark {
    width: 42px; height: 42px;
    border-radius: 12px;
    background: var(--brand-primary);
    color: #fff;
    display: grid; place-items: center;
    font-size: 22px;
    box-shadow: 0 4px 12px rgba(232,119,34,0.35);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 800; font-size: 16px; color: #fff; line-height: 1.5; }
.brand-tag  { font-size: 11px; color: #b3b3b3; }

.sidebar-nav {
    padding: 12px 0;
    flex: 1;
}
.nav-section {
    padding: 14px 20px 6px;
    font-size: 11px;
    color: #888;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.sidebar-nav .nav-link {
    color: #d9d9d9;
    padding: 10px 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    border-right: 3px solid transparent;
    text-decoration: none;
    font-size: 14.5px;
    transition: all .15s ease;
}
.sidebar-nav .nav-link i { width: 20px; text-align: center; font-size: 18px; }
.sidebar-nav .nav-link:hover {
    background: #353535;
    color: #fff;
}
.sidebar-nav .nav-link.active {
    background: linear-gradient(90deg, rgba(232,119,34,0.12), transparent);
    color: #fff;
    border-right-color: var(--brand-primary);
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid #3a3a3a;
    color: #888;
}

/* ==========================================================
   Topbar
   ========================================================== */
.app-topbar {
    height: var(--topbar-h);
    background: #fff;
    border-bottom: 1px solid var(--brand-border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky; top: 0;
    z-index: 100;
}
.topbar-tenant {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700;
}
.tenant-name { color: var(--brand-dark); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--brand-primary);
    color: #fff;
    display: inline-grid; place-items: center;
    font-weight: 700; font-size: 13px;
}

/* ==========================================================
   Page header
   ========================================================== */
.page-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--brand-dark);
    margin: 0;
}

/* ==========================================================
   KPI cards
   ========================================================== */
.kpi-card {
    background: #fff;
    border: 1px solid var(--brand-border);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    gap: 14px;
    align-items: center;
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.06);
}
.kpi-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: grid; place-items: center;
    color: #fff;
    font-size: 22px;
    flex-shrink: 0;
}
.kpi-body { min-width: 0; }
.kpi-label { font-size: 13px; color: #6c757d; }
.kpi-value { font-size: 24px; font-weight: 800; color: var(--brand-dark); line-height: 1.2; }
.kpi-sub   { font-size: 12px; color: #9aa0a6; }

.kpi-positive { border-left: 4px solid #198754; }
.kpi-negative { border-left: 4px solid #dc3545; }
.kpi-neutral  { border-left: 4px solid #6c757d; }
.kpi-alert    { border-left: 4px solid var(--brand-primary); }

/* ==========================================================
   Generic card tweaks
   ========================================================== */
.card {
    border: 1px solid var(--brand-border);
    border-radius: 14px;
}
.card-header { border-radius: 14px 14px 0 0 !important; font-weight: 700; }
.table > :not(caption) > * > * { vertical-align: middle; }

/* Badges – ensure readability with our brand */
.badge { font-weight: 600; padding: .45em .7em; }

/* ==========================================================
   Login page
   ========================================================== */
.auth-body {
    background: linear-gradient(135deg, var(--brand-dark) 0%, #444 100%);
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}
.auth-shell {
    width: 100%;
    max-width: 460px;
}
.auth-card {
    background: #fff;
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 18px 60px rgba(0,0,0,0.25);
}
.auth-mark {
    width: 64px; height: 64px;
    border-radius: 16px;
    background: var(--brand-primary);
    color: #fff;
    margin: 0 auto 12px;
    font-size: 30px;
    display: grid; place-items: center;
    box-shadow: 0 8px 24px rgba(232,119,34,0.4);
}
.auth-name {
    font-size: 32px; font-weight: 800;
    color: var(--brand-dark); margin: 0;
}
.auth-tag { color: #6c757d; font-size: 14px; }
.auth-demo code { background: #f1f3f5; padding: 1px 6px; border-radius: 6px; }

/* ==========================================================
   Responsive sidebar (collapses below lg)
   ========================================================== */
@media (max-width: 1199.98px) {
    .app-wrapper {
        display: block;
    }
    .app-main {
        width: 100%;
        min-height: 100vh;
    }
    .app-sidebar {
        position: fixed;
        top: 0;
        right: -320px;
        width: 280px;
        height: 100%;
        z-index: 1050;
        transition: right .25s ease;
    }
    .app-sidebar.open {
        right: 0;
        box-shadow: -4px 0 16px rgba(0,0,0,.25);
    }
    .sidebar-toggle { display: inline-block; }
}
@media (min-width: 1200px) {
    .sidebar-toggle { display: none; }
}

#sidebarBackdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,.45);
    z-index: 1040;
}
body.sidebar-open #sidebarBackdrop {
    display: block;
}

/* Hide horizontal overflow on small screens for tables */
.table-responsive { -webkit-overflow-scrolling: touch; }

/* ==========================================================
   Posts table — desktop table, mobile-condensed
   ========================================================== */
.post-content-cell {
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Topic drill-down: full content wraps to multiple lines so the
   reader can read each post inline without opening it. */
.post-content-wrap {
    white-space: normal;
    line-height: 1.7;
    font-size: 0.95rem;
    word-break: break-word;
}
@media (max-width: 767.98px) {
    .posts-table .hide-sm { display: none !important; }
    .post-content-cell {
        max-width: 100%;
        white-space: normal;
        line-height: 1.4;
    }
    .post-content-wrap {
        font-size: 0.9rem;
        line-height: 1.6;
    }
}

/* Subtle scrollbar in the sidebar */
.app-sidebar::-webkit-scrollbar { width: 6px; }
.app-sidebar::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
