/* ============================================================
   NEOTRISH Reviews - Main Stylesheet (Light Mode)
   Bootstrap 5 | RTL/LTR Support
   ============================================================ */

:root {
    --nr-primary:         #0d9488;
    --nr-primary-dark:    #0f766e;
    --nr-primary-light:   #e6f7f5;
    --nr-secondary:       #64748b;
    --nr-success:         #16a34a;
    --nr-danger:          #dc2626;
    --nr-warning:         #d97706;
    --nr-info:            #0891b2;

    --sidebar-width:      270px;
    --sidebar-bg:         #ffffff;
    --sidebar-text:       #334155;
    --sidebar-hover:      #f1f5f9;
    --sidebar-active-bg:  var(--nr-primary-light);
    --sidebar-active-text:var(--nr-primary-dark);
    --sidebar-border:     #eef2f2;

    --topbar-height:      64px;
    --topbar-bg:          #ffffff;
    --topbar-border:      #e2e8f0;
    --topbar-shadow:      0 1px 4px rgba(0,0,0,.05);

    --body-bg:            #f7f8fa;
    --card-bg:            #ffffff;
    --card-border:        #edf1f1;
    --card-radius:        16px;
    --card-shadow:        0 1px 3px rgba(15,23,42,.05), 0 1px 2px rgba(15,23,42,.03);
    --card-shadow-hover:  0 6px 20px rgba(15,23,42,.08);

    --text-primary:       #1e293b;
    --text-secondary:     #64748b;
    --text-muted:         #94a3b8;
    --border-color:       #e7ebeb;
    --input-bg:           #ffffff;
    --input-border:       #d8dee0;
    --input-focus:        var(--nr-primary);

    --badge-radius:       999px;
    --btn-radius:         10px;
    --transition:         all .2s ease;
    --font-ar:            'Tajawal', 'Segoe UI', sans-serif;
    --font-en:            'Inter', 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html[dir="rtl"] body { font-family: var(--font-ar); }
html[dir="ltr"] body { font-family: var(--font-en); }

body {
    background: var(--body-bg);
    color: var(--text-primary);
    font-size: .925rem;
    min-height: 100vh;
}

a { text-decoration: none; }

/* ---- Preloader ---- */
.page-preloader {
    position: fixed; inset: 0; background: var(--body-bg);
    display: flex; align-items: center; justify-content: center; z-index: 99999;
    transition: opacity .3s ease;
}
.page-preloader.hide { opacity: 0; pointer-events: none; }

/* ---- Layout ---- */
.wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    border-inline-end: 1px solid var(--sidebar-border);
    position: fixed; top: 0; bottom: 0;
    inset-inline-start: 0;
    display: flex; flex-direction: column;
    z-index: 1030;
    transition: transform .25s ease;
}
html[dir="rtl"] .sidebar { border-inline-end: 0; border-inline-start: 1px solid var(--sidebar-border); }

.sidebar-brand {
    height: var(--topbar-height);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.sidebar-brand .brand-logo {
    font-weight: 800; font-size: 1.35rem; color: var(--nr-primary); letter-spacing: -.02em;
    display: flex; align-items: center; gap: .5rem;
}
.sidebar-brand .brand-logo .brand-dot { color: var(--nr-primary); }

.sidebar-close-btn {
    display: none; border: 0; background: transparent; font-size: 1.25rem; color: var(--text-secondary);
}

.sidebar-nav { flex: 1; overflow-y: auto; padding: .75rem .75rem; }
.sidebar-nav .nav-link {
    display: flex; align-items: center; justify-content: space-between;
    gap: .75rem; padding: .7rem .9rem; border-radius: 12px;
    color: var(--sidebar-text); font-weight: 500; margin-bottom: .2rem;
    transition: var(--transition);
}
.sidebar-nav .nav-link .nav-link-main { display: flex; align-items: center; gap: .75rem; }
.sidebar-nav .nav-link i { font-size: 1.15rem; color: var(--text-secondary); }
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); }
.sidebar-nav .nav-link.active {
    background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 700;
}
.sidebar-nav .nav-link.active i { color: var(--sidebar-active-text); }
.sidebar-nav .nav-link.disabled { color: var(--text-muted); cursor: default; }
.sidebar-nav .nav-link.disabled i { color: var(--text-muted); }

.nav-badge {
    font-size: .65rem; font-weight: 700; padding: .18rem .55rem;
    border-radius: var(--badge-radius);
}
.nav-badge.badge-new { background: var(--nr-primary); color: #fff; }
.nav-badge.badge-soon { background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border-color); }

.sidebar-footer-nav {
    border-top: 1px solid var(--sidebar-border);
    padding: .75rem;
}

/* ---- Main content ---- */
.main-content {
    flex: 1;
    margin-inline-start: var(--sidebar-width);
    min-width: 0;
    display: flex; flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--topbar-border);
    box-shadow: var(--topbar-shadow);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 1.25rem;
    position: sticky; top: 0; z-index: 1020;
}
.sidebar-toggle-btn {
    display: none; border: 0; background: transparent; font-size: 1.3rem; color: var(--text-secondary);
}

.page-body { padding: 1.5rem; flex: 1; }

.branch-select {
    border-radius: var(--btn-radius); border: 1px solid var(--input-border);
    padding: .45rem .9rem; font-size: .875rem; background: #fff;
}

/* ---- User menu ---- */
.user-menu-btn {
    display: flex; align-items: center; gap: .6rem; border: 0; background: transparent; padding: .25rem;
}
.user-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--nr-primary-light);
    color: var(--nr-primary-dark); display: flex; align-items: center; justify-content: center;
    font-weight: 700; overflow: hidden; flex-shrink: 0;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.dropdown-menu-user { min-width: 230px; padding: 0; overflow: hidden; }
.dropdown-menu-user .user-menu-header { padding: .9rem 1rem; border-bottom: 1px solid var(--border-color); }
.dropdown-menu-user .user-menu-header .u-name { font-weight: 700; font-size: .9rem; }
.dropdown-menu-user .user-menu-header .u-email { font-size: .78rem; color: var(--text-muted); }
.dropdown-menu-user .dropdown-item { padding: .65rem 1rem; display: flex; align-items: center; gap: .6rem; }
.dropdown-menu-user .lang-section-label { padding: .4rem 1rem 0; font-size: .72rem; color: var(--text-muted); }
.dropdown-menu-user .lang-item.active-lang::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--nr-primary); margin-inline-start: auto; }

/* ---- Service Banner ---- */
.service-banner {
    background: #fff; border: 1px solid var(--border-color); border-radius: var(--card-radius);
    padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--card-shadow);
    display: flex; gap: 1rem; align-items: flex-start; position: relative;
}
.service-banner .service-icon {
    width: 40px; height: 40px; border-radius: 50%; background: var(--nr-primary-light);
    color: var(--nr-primary-dark); display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.service-banner .banner-close { position: absolute; top: .75rem; inset-inline-start: .75rem; border: 0; background: transparent; color: var(--text-muted); }
.service-banner h6 { font-weight: 700; margin-bottom: .25rem; }
.service-banner p { color: var(--text-secondary); font-size: .85rem; margin-bottom: .6rem; }

/* ---- Cards ---- */
.card {
    background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--card-radius);
    box-shadow: var(--card-shadow); transition: var(--transition);
}
.card-header-plain { padding: 1.25rem 1.25rem 0; border: 0; background: transparent; }
.card-header-plain h5 { font-weight: 700; margin: 0; }
.card-header-plain p { color: var(--text-secondary); font-size: .82rem; margin: .2rem 0 0; }

.icon-btn {
    width: 38px; height: 38px; border-radius: var(--btn-radius); border: 1px solid var(--input-border);
    background: #fff; display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary);
}
.icon-btn:hover { background: var(--sidebar-hover); }

/* ---- KPI cards ---- */
.kpi-card { padding: 1.25rem; display: flex; align-items: center; justify-content: space-between; }
.kpi-card .kpi-label { color: var(--text-secondary); font-size: .82rem; margin-bottom: .5rem; }
.kpi-card .kpi-value { font-size: 1.65rem; font-weight: 800; }
.kpi-card .kpi-icon {
    width: 40px; height: 40px; border-radius: 12px; background: var(--nr-primary-light);
    color: var(--nr-primary-dark); display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
}
.kpi-card .kpi-sentiment-badge { font-size: .78rem; color: var(--text-secondary); margin-top: .15rem; }

/* ---- Reputation score circle ---- */
.score-circle-wrap { display: flex; justify-content: center; padding: 1rem 0 1.5rem; }
.score-circle {
    width: 150px; height: 150px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.4rem; font-weight: 800;
    border: 10px solid;
}
.score-circle.score-empty { border-color: #fbdada; background: #fef2f2; color: var(--nr-danger); }
.score-circle.score-low   { border-color: #fde68a; background: #fffbeb; color: var(--nr-warning); }
.score-circle.score-good  { border-color: #bbf0e8; background: var(--nr-primary-light); color: var(--nr-primary-dark); }

/* ---- Empty state box ---- */
.empty-box {
    border: 1px dashed var(--border-color); border-radius: 12px; min-height: 220px;
    display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: .85rem;
}

/* ---- Analysis cards (complaints/praise) ---- */
.analysis-card { padding: 1.25rem; }
.analysis-card.card-danger { border-color: #fbdada; background: #fffafa; }
.analysis-card.card-success { border-color: #c9f1e7; background: #fafffe; }
.analysis-card .analysis-title { display: flex; align-items: center; gap: .5rem; font-weight: 700; margin-bottom: .3rem; }
.analysis-card .analysis-sub { color: var(--text-secondary); font-size: .82rem; margin-bottom: .9rem; }
.analysis-card .analysis-empty { color: var(--text-muted); font-size: .82rem; padding-top: .5rem; border-top: 1px dashed var(--border-color); }

/* ---- Sentiment emoji badge ---- */
.sentiment-emoji { font-size: 1.3rem; }

/* ---- Badges (status pills) ---- */
.badge-soft { padding: .3rem .7rem; border-radius: var(--badge-radius); font-size: .75rem; font-weight: 600; }
.badge-soft-success { background: #e8f8f0; color: var(--nr-success); }
.badge-soft-danger  { background: #fdeaea; color: var(--nr-danger); }
.badge-soft-warning { background: #fff4e0; color: var(--nr-warning); }
.badge-soft-neutral { background: #f1f5f9; color: var(--text-secondary); }
.badge-soft-primary { background: var(--nr-primary-light); color: var(--nr-primary-dark); }

/* ---- Buttons ---- */
.btn-primary-nr { background: var(--nr-primary); border-color: var(--nr-primary); color: #fff; border-radius: var(--btn-radius); font-weight: 600; }
.btn-primary-nr:hover { background: var(--nr-primary-dark); border-color: var(--nr-primary-dark); color: #fff; }
.btn-outline-nr { border: 1px solid var(--nr-primary); color: var(--nr-primary); border-radius: var(--btn-radius); font-weight: 600; background: #fff; }
.btn-outline-nr:hover { background: var(--nr-primary-light); color: var(--nr-primary-dark); }

/* ---- Login page ---- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--body-bg); padding: 1rem; }
.login-card { width: 100%; max-width: 400px; padding: 2.25rem 2rem; }
.login-logo { text-align: center; margin-bottom: 1.5rem; font-weight: 800; font-size: 1.6rem; color: var(--nr-primary); }

/* ---- Tables ---- */
.table-nr thead th { font-size: .78rem; color: var(--text-secondary); font-weight: 700; border-bottom: 1px solid var(--border-color); }
.table-nr td { vertical-align: middle; font-size: .87rem; }
.table-nr tr { border-bottom: 1px solid var(--border-color); }

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    /* NOTE: the closed/open offset is driven by a CSS variable rather than two
       separate selectors (one for RTL, one for `html[dir="ltr"] .sidebar`).
       The old `html[dir="ltr"] .sidebar { transform:... }` selector had HIGHER
       specificity than `.sidebar.open`, so in LTR the hamburger button added
       the "open" class but the closed-state rule still won and the menu never
       visibly opened. Using a variable keeps every state on the single
       `.sidebar` / `.sidebar.open` selectors so `.open` always wins. */
    :root { --sidebar-closed-x: 100%; }
    html[dir="ltr"] { --sidebar-closed-x: -100%; }
    .sidebar { transform: translateX(var(--sidebar-closed-x)); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-inline-start: 0; margin-inline-end: 0; }
    .sidebar-toggle-btn { display: inline-flex; }
    .sidebar-close-btn { display: inline-flex; }
    .sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1025; }
    .sidebar-backdrop.show { display: block; }
}
