/* ============================================================
   TechDesk — Main Stylesheet
   Bootstrap 5 + custom admin layout
   ============================================================ */

:root {
  --td-sidebar-width: 260px;
  --td-topbar-height: 56px;
  --td-sidebar-bg: #1a1d23;
  --td-sidebar-text: #c9d1d9;
  --td-sidebar-hover: rgba(255,255,255,.07);
  --td-sidebar-active: rgba(99,102,241,.25);
  --td-sidebar-accent: #6366f1;
  --td-brand-bg: #111317;
  --td-body-bg: #f5f6fa;
  --td-topbar-bg: #ffffff;
  --td-border: #e5e7eb;
  --td-card-shadow: 0 1px 4px rgba(0,0,0,.06);
  --td-radius: 8px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--td-body-bg); color: #1f2937; font-size: 14px; }

/* ---- Sidebar ---- */
.td-sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--td-sidebar-width);
  background: var(--td-sidebar-bg);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 100;
  transition: width .25s ease;
}
.td-brand {
  display: flex; align-items: center;
  padding: 0 20px; height: var(--td-topbar-height);
  background: var(--td-brand-bg);
  color: #fff; font-weight: 700; font-size: 16px;
  white-space: nowrap; overflow: hidden;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.td-brand i { font-size: 20px; color: var(--td-sidebar-accent); flex-shrink: 0; }

.td-nav { list-style: none; padding: 12px 0; margin: 0; flex: 1; }
.td-nav-section {
  padding: 14px 20px 4px;
  font-size: 10px; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: #6b7280;
}
.td-nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px; color: var(--td-sidebar-text);
  text-decoration: none; border-radius: 0;
  transition: background .15s, color .15s;
  font-size: 13.5px; white-space: nowrap; overflow: hidden;
}
.td-nav-link i { font-size: 16px; flex-shrink: 0; }
.td-nav-link:hover { background: var(--td-sidebar-hover); color: #fff; }
.td-nav-link.active { background: var(--td-sidebar-active); color: var(--td-sidebar-accent); font-weight: 500; }

.td-sidebar-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.td-user-link { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: 1; min-width: 0; }
.td-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--td-sidebar-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.td-user-name { color: #e5e7eb; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-user-role { color: #6b7280; font-size: 11px; text-transform: capitalize; }

/* ---- Main area ---- */
.td-main {
  margin-left: var(--td-sidebar-width);
  min-height: 100vh;
  display: flex; flex-direction: column;
  transition: margin-left .25s ease;
}

/* Sidebar collapsed */
.sidebar-collapsed .td-sidebar { width: 56px; }
.sidebar-collapsed .td-sidebar .td-nav-link span,
.sidebar-collapsed .td-sidebar .td-nav-section,
.sidebar-collapsed .td-sidebar .td-brand span,
.sidebar-collapsed .td-sidebar .td-user-info,
.sidebar-collapsed .td-sidebar .badge { display: none; }
.sidebar-collapsed .td-nav-link { justify-content: center; padding: 9px; }
.sidebar-collapsed .td-main { margin-left: 56px; }

/* ---- Topbar ---- */
.td-topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--td-topbar-height);
  background: var(--td-topbar-bg);
  border-bottom: 1px solid var(--td-border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 12px;
}
.td-search-wrap { position: relative; width: 320px; }
.td-search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0;
  background: #fff; border: 1px solid var(--td-border);
  border-radius: var(--td-radius); box-shadow: 0 4px 16px rgba(0,0,0,.1);
  z-index: 200; max-height: 360px; overflow-y: auto;
}
.td-search-item {
  display: flex; align-items: center; padding: 8px 12px;
  text-decoration: none; color: #1f2937;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.td-search-item:hover { background: #f9fafb; }

/* ---- Notifications ---- */
.td-notif-item { transition: background .15s; }
.td-notif-item:hover { background: #f9fafb; }
.td-notif-item.unread { background: #eff6ff; border-left: 3px solid #6366f1; }

/* ---- Content area ---- */
.td-content { padding: 24px; flex: 1; }
.td-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px;
}
.td-page-title { font-size: 22px; font-weight: 700; margin: 0; color: #111827; }

/* ---- KPI Cards ---- */
.td-kpi-card {
  background: #fff; border-radius: var(--td-radius);
  border: 1px solid var(--td-border);
  padding: 20px 24px;
  box-shadow: var(--td-card-shadow);
  display: flex; align-items: flex-start; gap: 16px;
}
.td-kpi-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.td-kpi-label { font-size: 12px; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.td-kpi-value { font-size: 28px; font-weight: 700; line-height: 1.1; color: #111827; }
.td-kpi-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }

/* ---- Tables ---- */
.td-table { background: #fff; border-radius: var(--td-radius); border: 1px solid var(--td-border); overflow: hidden; }
.td-table table { margin: 0; }
.td-table thead th { background: #f9fafb; border-bottom: 1px solid var(--td-border); font-size: 12px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; }
.td-table tbody td { padding: 12px 14px; vertical-align: middle; border-color: #f3f4f6; }
.td-table tbody tr:hover { background: #f9fafb; }
.td-table .ticket-subject { font-weight: 500; color: #1f2937; }
.td-table .ticket-number { font-family: monospace; font-size: 12px; color: #6b7280; }

/* ---- Cards ---- */
.td-card { background: #fff; border-radius: var(--td-radius); border: 1px solid var(--td-border); box-shadow: var(--td-card-shadow); }
.td-card-header { padding: 16px 20px; border-bottom: 1px solid var(--td-border); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.td-card-body { padding: 20px; }

/* ---- Ticket detail ---- */
.td-timeline { list-style: none; padding: 0; margin: 0; }
.td-timeline-item {
  display: flex; gap: 12px; padding: 16px 0;
  border-bottom: 1px solid #f3f4f6; position: relative;
}
.td-timeline-item:last-child { border-bottom: none; }
.td-timeline-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #e0e7ff; color: #4f46e5;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}
.td-timeline-avatar.internal { background: #fef3c7; color: #92400e; }
.td-timeline-avatar.system   { background: #f0fdf4; color: #166534; }
.td-note-body { white-space: pre-wrap; word-break: break-word; font-size: 13.5px; line-height: 1.6; }
.td-note-internal { border-left: 3px solid #f59e0b; background: #fffbeb; border-radius: 4px; padding: 10px 14px; }
.td-note-public   { border-left: 3px solid #6366f1; background: #f8f9ff; border-radius: 4px; padding: 10px 14px; }

/* ---- Priority colors ---- */
.td-priority-critical { background: #000 !important; }
.td-priority-urgent   { background: #dc3545 !important; }
.td-priority-high     { background: #fd7e14 !important; }
.td-priority-normal   { background: #0d6efd !important; }
.td-priority-low      { background: #6c757d !important; }

/* ---- Workload bar ---- */
.td-workload-bar { height: 6px; border-radius: 3px; background: #e5e7eb; overflow: hidden; }
.td-workload-fill { height: 100%; border-radius: 3px; background: #6366f1; transition: width .3s; }

/* ---- Filter bar ---- */
.td-filter-bar {
  background: #fff; border: 1px solid var(--td-border);
  border-radius: var(--td-radius); padding: 14px 16px;
  margin-bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
}

/* ---- Status workflow badges ---- */
.td-status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 4px; }

/* ---- Outage flag ---- */
.td-outage-banner {
  background: #1a0000; color: #ff4444;
  padding: 8px 16px; border-radius: 6px;
  font-weight: 700; font-size: 12px; letter-spacing: .06em;
  text-transform: uppercase; display: flex; align-items: center; gap: 6px;
}

/* ---- Login page ---- */
.td-login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: #1a1d23; }
.td-login-card { background: #fff; border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 8px 32px rgba(0,0,0,.25); }
.td-login-logo { text-align: center; margin-bottom: 28px; }
.td-login-logo i { font-size: 40px; color: #6366f1; }
.td-login-logo h1 { font-size: 22px; font-weight: 700; margin: 8px 0 0; }
.td-login-logo p { color: #6b7280; font-size: 13px; margin: 4px 0 0; }

/* ---- Mailbox inbox ---- */
.td-mail-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid #f3f4f6; cursor: pointer; text-decoration: none; color: inherit; transition: background .15s; }
.td-mail-row:hover { background: #f9fafb; }
.td-mail-row.unread .td-mail-subject { font-weight: 600; }
.td-mail-row.converted { opacity: .65; }
.td-mail-sender { font-size: 13px; font-weight: 500; min-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-mail-subject { flex: 1; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.td-mail-date { font-size: 11px; color: #9ca3af; white-space: nowrap; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .td-sidebar { transform: translateX(-100%); }
  .td-sidebar.open { transform: none; }
  .td-main { margin-left: 0; }
  .td-search-wrap { width: auto; flex: 1; }
  .td-kpi-value { font-size: 22px; }
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }

/* ---- Utility ---- */
.td-mono { font-family: 'Courier New', monospace; font-size: 12px; }
.td-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hover-shadow:hover { box-shadow: 0 4px 12px rgba(0,0,0,.08); }
