/* ============================================================
   manageIT — Professional IT Management Theme
   ============================================================ */

/* ---------- Variables ---------- */
:root {
  --sidebar-width: 260px;
  --sidebar-bg: #0f172a;
  --sidebar-hover: rgba(99, 149, 237, 0.12);
  --sidebar-active: rgba(99, 149, 237, 0.2);
  --sidebar-accent: #6395ed;
  --topbar-bg: #ffffff;
  --body-bg: #f1f5f9;
  --card-border: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --input-border: #94a3b8;
  --input-focus: #6395ed;
  --table-header-bg: #f8fafc;
  --table-hover: #f1f5f9;
  --login-bg: #0f172a;
}

/* ---------- Global ---------- */
body {
  background: var(--body-bg);
  color: var(--text-primary);
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ---------- Form inputs — more visible ---------- */
.form-control, .form-select {
  border-color: var(--input-border);
  border-width: 1.5px;
  transition: border-color .2s, box-shadow .2s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 3px rgba(99, 149, 237, 0.15);
}
.form-control::placeholder { color: #94a3b8; }
.form-label { font-weight: 500; color: var(--text-primary); font-size: .875rem; }
.form-text { color: var(--text-secondary); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 1040;
  transition: transform 0.25s ease;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.06);
}

.sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.08) !important;
}

.sidebar .nav-link {
  color: rgba(255,255,255,0.65);
  font-size: .855rem;
  padding: .5rem .85rem;
  border-radius: .5rem;
  margin: 1px 0;
  transition: all .15s ease;
}
.sidebar .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 600;
}
.sidebar .nav-link i { opacity: .7; }
.sidebar .nav-link:hover i,
.sidebar .nav-link.active i { opacity: 1; }

.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left 0.25s ease;
}

/* ---------- Top bar ---------- */
.navbar {
  background: var(--topbar-bg) !important;
  border-bottom: 1px solid var(--card-border) !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

#topBarTitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ---------- Cards ---------- */
.card {
  border: 1px solid var(--card-border);
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow .2s;
}
.card:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.card-header {
  background: var(--table-header-bg);
  border-bottom: 1px solid var(--card-border);
  font-weight: 600;
  font-size: .9rem;
}

/* ---------- Tables ---------- */
.table {
  font-size: .875rem;
  color: var(--text-primary);
}
.table thead th {
  background: var(--table-header-bg);
  border-bottom: 2px solid var(--card-border);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-secondary);
  padding: .65rem .75rem;
}
.table tbody tr {
  transition: background .1s;
}
.table-hover tbody tr:hover {
  background: var(--table-hover);
}
.table td {
  padding: .6rem .75rem;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}

/* Sortable headers */
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { background-color: #e9ecef !important; }
th[data-sort]::after { content: ' \2195'; opacity: .3; font-size: .7em; }
th[data-sort].sort-asc::after { content: ' \2191'; opacity: .8; }
th[data-sort].sort-desc::after { content: ' \2193'; opacity: .8; }

/* Table filter */
.table-filter-input { border-color: var(--input-border); }
.table-filter-input:focus { box-shadow: 0 0 0 3px rgba(99, 149, 237, 0.15) !important; border-color: var(--input-focus); }
.table-filter-wrapper { position: relative; }

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: .5rem; font-size: .875rem; }
.btn-primary { background: #4f7df0; border-color: #4f7df0; }
.btn-primary:hover { background: #3d6ad8; border-color: #3d6ad8; }
.btn-outline-primary { border-color: #4f7df0; color: #4f7df0; }
.btn-outline-primary:hover { background: #4f7df0; border-color: #4f7df0; }
.btn-sm { font-size: .8rem; padding: .3rem .6rem; }
.btn-xs { font-size: .7rem; padding: .15rem .35rem; line-height: 1.3; }

/* ---------- Badges ---------- */
.badge { font-weight: 500; letter-spacing: .02em; }

/* ---------- Modals ---------- */
.modal-content {
  border: none;
  border-radius: .75rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}
.modal-header {
  cursor: move;
  border-bottom: 1px solid var(--card-border);
  padding: 1rem 1.25rem;
}
.modal-header .modal-title { font-weight: 600; font-size: 1rem; }
.modal-footer { border-top: 1px solid var(--card-border); }

/* ---------- Login ---------- */
#viewLogin {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%) !important;
}
#viewLogin .form-control {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
#viewLogin .form-control:focus {
  border-color: var(--sidebar-accent) !important;
  box-shadow: 0 0 0 3px rgba(99, 149, 237, 0.2) !important;
}
#viewLogin .input-group-text {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}
#viewLogin .btn-primary {
  background: var(--sidebar-accent);
  border-color: var(--sidebar-accent);
  font-weight: 600;
  padding: .6rem;
}
#viewLogin .btn-primary:hover {
  background: #527cd6;
  border-color: #527cd6;
}

/* ---------- Section headings ---------- */
.app-section h5 {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
}

/* ---------- Dashboard stat cards ---------- */
.stat-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: .75rem;
  font-size: 1.25rem;
}

/* ---------- Scrollbar (subtle) ---------- */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

/* ---------- Toast container ---------- */
.toast { border-radius: .5rem; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }

/* ---------- Nav tabs (modal) ---------- */
.nav-tabs .nav-link {
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  padding: .5rem 1rem;
}
.nav-tabs .nav-link:hover { color: var(--text-primary); border-bottom-color: #cbd5e1; }
.nav-tabs .nav-link.active { color: #4f7df0; border-bottom-color: #4f7df0; font-weight: 600; }

/* ---------- Alert improvements ---------- */
.alert { border-radius: .5rem; font-size: .875rem; }

/* ---------- Responsive ---------- */

/* Tables — responsive helpers */
.table-responsive { overflow: visible !important; }
.table { width: 100%; table-layout: auto; }
.table td, .table th { vertical-align: middle; word-break: break-word; }
.col-hide-sm { /* hidden < 768 */ }
.col-hide-md { /* hidden < 992 */ }

/* Action buttons — always compact */
.table .text-end .btn-sm { padding: .2rem .35rem; font-size: .75rem; }

@media (max-width: 767.98px) {
  .col-hide-sm { display: none !important; }
}
@media (max-width: 991.98px) {
  .col-hide-md { display: none !important; }
}

/* Tablet: sidebar hidden */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
}

/* Mobile */
@media (max-width: 767.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }

  /* Spacing */
  .px-4 { padding-left: .75rem !important; padding-right: .75rem !important; }
  .py-3 { padding-top: .75rem !important; padding-bottom: .75rem !important; }

  /* Top bar */
  #topBarTitle { font-size: .9rem; }
  #topBarClient { font-size: .68rem; }
  .navbar { padding: .4rem .75rem !important; }

  /* Tables — compact */
  .table { font-size: .8rem; }
  .table thead th { font-size: .7rem; padding: .4rem; }
  .table td { padding: .4rem; }
  .table td:first-child { max-width: 140px; word-break: break-word; }

  /* Action buttons — icon only, no text */
  .table .text-end .btn-sm { padding: .15rem .3rem; font-size: .7rem; }

  /* Badges smaller */
  .badge { font-size: .68rem; padding: 2px 6px; }

  /* Cards */
  .card-body { padding: .75rem !important; }

  /* Role cards */
  .role-header { padding: .5rem .65rem; flex-wrap: wrap; gap: .4rem; }
  .role-body { padding: 0 .65rem .5rem; }
  .perm-badge { font-size: .65rem; padding: 2px 6px; }

  /* Modals fullscreen on mobile */
  .modal-dialog { margin: .25rem; max-width: calc(100% - .5rem); }
  .modal-body { padding: .75rem; }

  /* Section headers stack */
  .app-section .d-flex.justify-content-between {
    flex-direction: column; gap: .5rem; align-items: flex-start !important;
  }

  /* Language buttons */
  .btn-group .lang-btn { font-size: .58rem; padding: 2px 6px; }

  /* Perm legend wrap */
  .perm-legend { gap: .25rem; }
  .perm-legend .perm-badge { font-size: .6rem; padding: 1px 4px; }
}

/* ---------- Permission badges (color by action type) ---------- */
.perm-badge { font-size: .72rem; font-weight: 500; padding: 3px 8px; border-radius: 4px; letter-spacing: .02em; display: inline-block; }
.perm-read { background: #d1fae5; color: #065f46; }
.perm-create { background: #c6f6d5; color: #22543d; }
.perm-update { background: #dbeafe; color: #1e40af; }
.perm-manage { background: #bfdbfe; color: #1e3a8a; }
.perm-write { background: #fef3c7; color: #92400e; }
.perm-delete { background: #fecaca; color: #991b1b; }
.perm-full { background: #e9d5ff; color: #6b21a8; }
.perm-assign { background: #fce7f3; color: #9d174d; }
.perm-other { background: #e5e7eb; color: #374151; }

/* ---------- Role cards (collapsible perms) ---------- */
.role-card { border: 1px solid #e3e8f0; border-radius: 8px; transition: box-shadow .15s; background: #fff; }
.role-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.role-header { padding: .65rem .9rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; border-radius: 8px; }
.role-header:hover { background: #f8f9fa; }
.role-body { padding: 0 .9rem .75rem; }
.module-group { margin-bottom: .5rem; }
.module-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; color: #6c757d; letter-spacing: .04em; margin-bottom: .25rem; }
.chevron-perm { transition: transform .2s; }
.chevron-perm.collapsed { transform: rotate(-90deg); }

/* ---------- Language toggle buttons ---------- */
.lang-btn {
  font-size: .62rem; font-weight: 600; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 4px;
  background: #f1f3f5; color: #868e96;
  border: 1px solid #dee2e6;
  transition: all .12s; line-height: 1.4;
}
.lang-btn:hover { background: #e9ecef; color: #495057; }
.lang-btn.active-lang {
  background: #2563eb; color: #fff; border-color: #2563eb;
}
.btn-group .lang-btn:first-child { border-radius: 4px 0 0 4px; }
.btn-group .lang-btn:last-child { border-radius: 0 4px 4px 0; }

/* ---------- Perm legend ---------- */
.perm-legend { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.perm-legend .small { font-size: .75rem; }

/* ---------- Pastel badge system (global) ---------- */
.badge-pastel-blue { background: #dbeafe; color: #1e40af; }
.badge-pastel-green { background: #d1fae5; color: #065f46; }
.badge-pastel-red { background: #fecaca; color: #991b1b; }
.badge-pastel-yellow { background: #fef3c7; color: #92400e; }
.badge-pastel-purple { background: #e9d5ff; color: #6b21a8; }
.badge-pastel-pink { background: #fce7f3; color: #9d174d; }
.badge-pastel-cyan { background: #cffafe; color: #155e75; }
.badge-pastel-gray { background: #e5e7eb; color: #374151; }
.badge-pastel-orange { background: #fed7aa; color: #9a3412; }
.badge-pastel-teal { background: #ccfbf1; color: #134e4a; }
