/* ============================================================
   CS Portal — Custom Theme
   Bootstrap 5.3.2 companion stylesheet
   Brand: ITM (Innovative Technology Management)
   Fonts:  Inter (primary) · Roboto (secondary)
   ============================================================ */

/* ----------------------------------------------------------
   Design tokens
   ---------------------------------------------------------- */
:root {
  /* Brand colours — ITM */
  --cs-primary:        #0096D6;   /* ITM Blue */
  --cs-primary-dark:   #007AB3;
  --cs-success:        #A0C334;   /* ITM Green */
  --cs-neutral-gray:   #757575;
  --cs-dark-text:      #212121;
  --cs-warning:        #ffc107;
  --cs-danger:         #dc3545;
  --cs-info:           #0dcaf0;
  --cs-orange:         #fd7e14;

  /* Bootstrap CSS variable overrides */
  --bs-primary:             #0096D6;
  --bs-primary-rgb:         0, 150, 214;
  --bs-success:             #A0C334;
  --bs-success-rgb:         160, 195, 52;
  --bs-body-color:          #212121;
  --bs-body-font-family:    'Inter', system-ui, -apple-system, sans-serif;
  --bs-link-color:          #0096D6;
  --bs-link-hover-color:    #007AB3;

  /* Sidebar */
  --sidebar-width:           260px;
  --sidebar-rep-bg:          #1a2332;
  --sidebar-admin-bg:        #1e2a3b;
  --sidebar-link-color:      #8a9bb5;
  --sidebar-section-color:   #556070;
  --sidebar-hover-bg:        rgba(255, 255, 255, 0.10);
  --sidebar-active-bg:       rgba(255, 255, 255, 0.14);
  --sidebar-border:          rgba(255, 255, 255, 0.08);
  --sidebar-transition:      transform 0.25s ease;

  /* Page backgrounds */
  --bg-public:  #f8f9fa;
  --bg-portal:  #f4f6f9;
  --bg-admin:   #f0f2f5;

  /* Shadows */
  --shadow-card:   0 1px 8px rgba(0, 0, 0, 0.07);
  --shadow-topbar: 0 1px 6px rgba(0, 0, 0, 0.06);
}

/* ----------------------------------------------------------
   Bootstrap component colour overrides
   (utility classes pick up --bs-* above; buttons need local vars)
   ---------------------------------------------------------- */
.btn-primary {
  --bs-btn-bg:                 #0096D6;
  --bs-btn-border-color:       #0096D6;
  --bs-btn-hover-bg:           #007AB3;
  --bs-btn-hover-border-color: #007AB3;
  --bs-btn-active-bg:          #007AB3;
  --bs-btn-active-border-color:#007AB3;
}

.btn-outline-primary {
  --bs-btn-color:              #0096D6;
  --bs-btn-border-color:       #0096D6;
  --bs-btn-hover-bg:           #0096D6;
  --bs-btn-hover-border-color: #0096D6;
  --bs-btn-active-bg:          #0096D6;
  --bs-btn-active-border-color:#0096D6;
}

/* ----------------------------------------------------------
   Global base
   ---------------------------------------------------------- */
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #212121;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6,
.sidebar-brand,
.topbar {
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
}

/* ----------------------------------------------------------
   Shared card
   ---------------------------------------------------------- */
.card {
  border: none;
  box-shadow: var(--shadow-card);
  border-radius: 10px;
}

/* ----------------------------------------------------------
   PUBLIC LAYOUT
   ---------------------------------------------------------- */
body.layout-public {
  position: relative;
  background-color: var(--bg-public);
}

body.layout-public::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url('../images/background.png');
  background-size: cover;
  background-position: center top;
  opacity: 0.14;
  -webkit-mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
  mask-image: linear-gradient(to right, transparent, black 15%, black 85%, transparent);
  pointer-events: none;
  z-index: 0;
}

/* Keep page content above the background layer */
body.layout-public > nav,
body.layout-public > main,
body.layout-public > footer {
  position: relative;
  z-index: 1;
}

.navbar-brand {
  font-weight: 700;
}

.hero-section {
  background: linear-gradient(135deg, var(--cs-primary) 0%, var(--cs-primary-dark) 100%);
  color: #fff;
  padding: 3rem 0;
}

.ticket-status-badge {
  font-size: 0.85em;
}

footer.site-footer {
  background: #212529;
  color: #adb5bd;
  padding: 2rem 0;
  margin-top: 4rem;
}

/* ----------------------------------------------------------
   PORTAL LAYOUT  (rep + admin share the sidebar skeleton)
   ---------------------------------------------------------- */
body.layout-portal {
  background-color: var(--bg-portal);
}

body.layout-admin {
  background-color: var(--bg-admin);
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1040;
  overflow-y: auto;
  overflow-x: hidden;
  transition: var(--sidebar-transition);
  display: flex;
  flex-direction: column;
}

.sidebar-rep   { background: var(--sidebar-rep-bg); }
.sidebar-admin { background: var(--sidebar-admin-bg); }

.sidebar-brand {
  padding: 1.25rem 1.25rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-section-color);
  padding: 0.8rem 1.2rem 0.3rem;
}

.sidebar .nav-link {
  color: var(--sidebar-link-color);
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  margin: 2px 8px;
  transition: background 0.18s ease, color 0.18s ease;
  display: flex;
  align-items: center;
}

.sidebar .nav-link i {
  width: 20px;
  text-align: center;
  margin-right: 8px;
  flex-shrink: 0;
}

.sidebar .nav-link:hover {
  color: #fff;
  background: var(--sidebar-hover-bg);
}

.sidebar .nav-link.active {
  color: #fff;
  background: var(--sidebar-active-bg);
}

/* ---- Backdrop (mobile overlay) ---- */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1039;
  transition: opacity 0.25s ease;
}

.sidebar-backdrop.show {
  display: block;
}

/* ---- Main content area ---- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: 1.5rem;
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

/* ---- Topbar ---- */
.topbar {
  background: #fff;
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 8px;
  box-shadow: var(--shadow-topbar);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.topbar-left h5 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

/* ---- Hamburger toggle (hidden on desktop) ---- */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.25rem 0.4rem;
  font-size: 1.3rem;
  line-height: 1;
  color: #495057;
  cursor: pointer;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: #f0f2f4;
}

/* ---- Stat cards ---- */
.stat-card {
  border-left: 4px solid transparent;
}

.stat-card-open      { border-left-color: var(--cs-primary); }
.stat-card-progress  { border-left-color: var(--cs-warning); }
.stat-card-resolved  { border-left-color: var(--cs-success); }
.stat-card-escalated { border-left-color: var(--cs-danger); }

/* ---- Status badges ---- */
.badge-OPEN        { background-color: var(--cs-primary)  !important; color: #fff; }
.badge-IN_PROGRESS { background-color: var(--cs-warning)  !important; color: #212121; }
.badge-ESCALATED   { background-color: var(--cs-danger)   !important; color: #fff; }
.badge-RESOLVED    { background-color: var(--cs-success)  !important; color: #212121; }
.badge-CLOSED      { background-color: #6c757d            !important; color: #fff; }

/* ---- Message bubbles ---- */
.message-bubble {
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.message-customer  { background: #e3f4fb; border-left: 3px solid var(--cs-primary); }
.message-rep       { background: #f5f9e8; border-left: 3px solid var(--cs-success); }
.message-technical { background: #fff3cd; border-left: 3px solid var(--cs-orange); }
.message-system    { background: #f8f9fa; border-left: 3px solid #adb5bd; font-style: italic; font-size: 0.9rem; }
.message-internal  { background: #fffbe6; border: 1px dashed var(--cs-warning); }

/* ---- Table headers ---- */
.table th {
  background: #f8f9fa;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---- Admin badge ---- */
.admin-badge {
  background: var(--cs-danger);
}

/* ----------------------------------------------------------
   RESPONSIVE — mobile sidebar (< 992 px)
   ---------------------------------------------------------- */
@media (max-width: 991.98px) {

  /* Show the hamburger */
  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* Sidebar slides in from left */
  .sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.28);
  }

  /* Main content occupies full width */
  .main-content {
    margin-left: 0 !important;
  }
}

/* Extra-small screens (< 576 px) */
@media (max-width: 575.98px) {

  .main-content {
    padding: 0.9rem 0.75rem;
  }

  .topbar {
    padding: 0.6rem 0.75rem;
    flex-wrap: wrap;
  }

  .topbar-right .text-muted.small {
    display: none; /* hide date on very small screens to save space */
  }

  .hero-section {
    padding: 2rem 0;
  }
}

/* ----------------------------------------------------------
   DARK MODE — Bootstrap 5.3 data-bs-theme="dark" overrides
   Bootstrap handles cards, tables, alerts, forms automatically.
   Only custom components need explicit dark styles here.
   ---------------------------------------------------------- */
[data-bs-theme="dark"] body.layout-public  { background-color: #0f1117; }
[data-bs-theme="dark"] body.layout-portal  { background-color: #0f1117; }
[data-bs-theme="dark"] body.layout-admin   { background-color: #111318; }

[data-bs-theme="dark"] .topbar {
  background: #1c1e2a;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

[data-bs-theme="dark"] .sidebar-toggle       { color: #adb5bd; }
[data-bs-theme="dark"] .sidebar-toggle:hover { background: rgba(255, 255, 255, 0.10); }

[data-bs-theme="dark"] .message-customer  { background: #1a2e3a; }
[data-bs-theme="dark"] .message-rep       { background: #1a2e22; }
[data-bs-theme="dark"] .message-technical { background: #2e2a1a; }
[data-bs-theme="dark"] .message-system    { background: #1e1e2a; }
[data-bs-theme="dark"] .message-internal  { background: #2a2a1a; }
