/* ============================================================
   styles.css — Azure Role Permissions Comparator
   ============================================================ */

/* ── Design tokens ── */
:root {
  --azure:       #0078D4;
  --azure-dark:  #005A9E;
  --azure-light: #50B0F0;
  --entra:       #7C3AED;
  --entra-light: #A78BFA;

  --bg:       #0A0E17;
  --surface:  #111827;
  --surface2: #1A2235;
  --surface3: #243047;
  --border:   #2A3A55;

  --text:       #E8EEF8;
  --text-muted: #7A8CA8;
  --text-dim:   #4A5A72;

  --green:  #22C55E;
  --red:    #EF4444;
  --yellow: #F59E0B;

  --diff-row:        rgba(245, 158, 11, 0.08);
  --diff-row-border: rgba(245, 158, 11, 0.30);
}

/* ── Reset ── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Subtle grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(0, 120, 212, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 120, 212, 0.03) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
  z-index: 0;
}

.app { position: relative; z-index: 1; }


/* ── Header ── */
header {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  background: linear-gradient(180deg, rgba(0, 120, 212, 0.08) 0%, transparent 100%);
}

.azure-logo {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #0078D4, #50B0F0);
  clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
  flex-shrink: 0;
  animation: pulse 3s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50%       { filter: brightness(1.3) drop-shadow(0 0 8px rgba(0, 120, 212, 0.5)); }
}

header h1 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

header h1 span { color: var(--azure-light); }

/* Mode switcher toggle */
.mode-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 20px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
}

.mode-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  transition: all 0.18s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mode-btn:hover { color: var(--text); }

.mode-btn.active-sub {
  background: linear-gradient(135deg, #0055A4, #0078D4);
  color: #fff;
  box-shadow: 0 2px 10px rgba(0, 120, 212, 0.4);
}

.mode-btn.active-entra {
  background: linear-gradient(135deg, #5B21B6, #7C3AED);
  color: #fff;
  box-shadow: 0 2px 10px rgba(124, 58, 237, 0.4);
}

.mode-icon { font-size: 13px; }

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.scope-pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid;
  transition: all 0.25s;
}

.scope-pill.sub {
  border-color: rgba(0, 120, 212, 0.4);
  color: var(--azure-light);
  background: rgba(0, 120, 212, 0.08);
}

.scope-pill.entra {
  border-color: rgba(124, 58, 237, 0.4);
  color: var(--entra-light);
  background: rgba(124, 58, 237, 0.08);
}


/* ── Page layout ── */
.main {
  display: flex;
  height: calc(100vh - 62px);
}


/* ── Sidebar ── */
.sidebar {
  width: 292px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  overflow: hidden;
}

.sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.sidebar-header h2.sub-mode   { color: var(--azure-light); }
.sidebar-header h2.entra-mode { color: var(--entra-light); }

/* Search */
.search-box { position: relative; }

.search-box input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 10px 7px 28px;
  border-radius: 6px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.search-box input:focus       { border-color: var(--azure); }
.search-box input::placeholder { color: var(--text-dim); }

.search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 12px;
  pointer-events: none;
}

/* Role list */
.sidebar-scroll { overflow-y: auto; flex: 1; }
.sidebar-scroll::-webkit-scrollbar       { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.category-section { padding: 5px 0; }

.category-label {
  padding: 5px 16px;
  font-size: 9.5px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.role-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.12s;
  border-left: 2px solid transparent;
}

.role-item:hover              { background: var(--surface2); }
.role-item.selected-sub       { background: rgba(0, 120, 212, 0.11); border-left-color: var(--azure); }
.role-item.selected-entra     { background: rgba(124, 58, 237, 0.11); border-left-color: var(--entra); }

.role-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  transition: all 0.12s;
}

.role-item.selected-sub   .role-check { background: var(--azure); border-color: var(--azure); color: #fff; }
.role-item.selected-entra .role-check { background: var(--entra); border-color: var(--entra); color: #fff; }

.role-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  transition: color 0.12s;
  line-height: 1.35;
  flex: 1;
}

.role-item:hover        .role-name,
.role-item.selected-sub   .role-name,
.role-item.selected-entra .role-name { color: var(--text); }

.role-badge {
  font-size: 8.5px;
  padding: 2px 5px;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  flex-shrink: 0;
}

.badge-std                  { background: rgba(0,   120, 212, 0.18); color: var(--azure-light); }
.badge-priv, .badge-ga-priv { background: rgba(239,  68,  68, 0.14); color: #FCA5A5; }
.badge-ga                   { background: rgba(124,  58, 237, 0.20); color: var(--entra-light); }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.selected-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
}

.selected-count span { font-weight: 600; }
.cnt-sub             { color: var(--azure-light); }
.cnt-entra           { color: var(--entra-light); }

.clear-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: none;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s;
}

.clear-btn:hover { color: var(--red); border-color: var(--red); }


/* ── Table area ── */
.table-area {
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.table-area::-webkit-scrollbar        { width: 6px; height: 6px; }
.table-area::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }


/* ── Table controls bar ── */
.table-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.legend { display: flex; align-items: center; gap: 12px; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--text-muted);
}

.legend-dot {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
}

.legend-dot.grant { background: rgba(34,  197,  94, 0.20); color: var(--green); }
.legend-dot.deny  { background: rgba(239,  68,  68, 0.12); color: var(--red); }
.legend-dot.diff  { background: var(--diff-row); border: 1px solid var(--diff-row-border); color: var(--yellow); }

.filter-toggle { margin-left: auto; display: flex; gap: 4px; }

.filter-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  padding: 5px 11px;
  border-radius: 5px;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  transition: all 0.15s;
}

.filter-btn:hover   { color: var(--text); }
.filter-btn.fa-sub  { background: rgba(0,   120, 212, 0.14); border-color: var(--azure); color: var(--azure-light); }
.filter-btn.fa-entra{ background: rgba(124,  58, 237, 0.14); border-color: var(--entra); color: var(--entra-light); }


/* ── Empty state ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 360px;
  gap: 14px;
}

.empty-icon {
  width: 56px;
  height: 56px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--text-dim);
}

.empty-state h3 {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 13px;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  max-width: 280px;
  line-height: 1.6;
}


/* ── Summary cards ── */
.summary-bar {
  display: flex;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 15px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.summary-val {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 20px;
  font-weight: 600;
}

.sv-blue   { color: var(--azure-light); }
.sv-violet { color: var(--entra-light); }
.sv-yellow { color: var(--yellow); }

.summary-label {
  font-size: 10px;
  color: var(--text-dim);
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}


/* ── Comparison table ── */
.compare-table-wrapper {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  min-width: max-content;
}

table { border-collapse: collapse; width: 100%; }

/* Sticky column header row */
thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0;
  z-index: 10;
}

/* Sticky permission-name column */
thead th:first-child {
  position: sticky;
  left: 0;
  z-index: 20;
  background: var(--surface);
}

.th-inner {
  padding: 11px 15px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-right: 1px solid var(--border);
  min-width: 160px;
}

thead th:last-child .th-inner { border-right: none; }

.th-role-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.th-sub   { color: var(--azure-light); }
.th-entra { color: var(--entra-light); }

.th-perm-col .th-role-name {
  color: var(--text-muted);
  font-size: 10.5px;
}

.th-role-cat {
  font-size: 9.5px;
  color: var(--text-dim);
  font-family: 'IBM Plex Mono', monospace;
}

.remove-role-btn {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.13);
  border: none;
  color: #FCA5A5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  transition: all 0.15s;
  margin-top: 3px;
}

.remove-role-btn:hover { background: rgba(239, 68, 68, 0.28); }

/* Group header rows */
.group-header td {
  background: var(--surface2);
  padding: 6px 15px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

/* Data rows */
tbody tr.data-row { transition: background 0.1s; }

tbody tr.data-row:hover td                { background: var(--surface2) !important; }
tbody tr.data-row:hover td.perm-name-cell { background: var(--surface3) !important; }

tbody tr.data-row.diff-row td                { background: var(--diff-row); }
tbody tr.data-row.diff-row td.perm-name-cell { background: rgba(245, 158, 11, 0.10); border-left: 2px solid var(--yellow); }

tbody tr.data-row.diff-row:hover td                { background: rgba(245, 158, 11, 0.12) !important; }
tbody tr.data-row.diff-row:hover td.perm-name-cell { background: rgba(245, 158, 11, 0.15) !important; }

td { border-bottom: 1px solid rgba(42, 58, 85, 0.5); vertical-align: middle; }

/* Sticky permission name cell */
td.perm-name-cell {
  position: sticky;
  left: 0;
  background: var(--surface);
  padding: 8px 15px;
  min-width: 270px;
  max-width: 340px;
  border-right: 1px solid var(--border);
  z-index: 5;
}

.perm-name {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-word;
  line-height: 1.4;
}

.perm-desc {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
  line-height: 1.4;
}

.diff-indicator {
  display: inline-flex;
  align-items: center;
  font-size: 9px;
  font-family: 'IBM Plex Mono', monospace;
  color: var(--yellow);
  background: rgba(245, 158, 11, 0.14);
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 6px;
  vertical-align: middle;
}

/* Permission value cells */
td.perm-value-cell {
  padding: 8px 15px;
  text-align: center;
  border-right: 1px solid rgba(42, 58, 85, 0.4);
  min-width: 150px;
}

td.perm-value-cell:last-child { border-right: none; }

.check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 25px;
  height: 25px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

.check-icon.has { background: rgba(34,  197, 94, 0.15); color: var(--green); }
.check-icon.no  { background: rgba(239,  68, 68, 0.09); color: var(--red); opacity: 0.5; }


/* ============================================================
   MOBILE & RESPONSIVE
   ============================================================ */

/* ── Sidebar toggle button (mobile only, hidden on desktop) ── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.sidebar-toggle:hover { color: var(--text); border-color: var(--azure); }

/* Overlay behind open sidebar on mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 40;
}

.sidebar-overlay.active { display: block; }

/* ── Tablet (≤ 900px) ── */
@media (max-width: 900px) {

  /* Compact header — stack title below controls */
  header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }

  header h1 {
    font-size: 13px;
    white-space: normal;
    order: 2;
    flex: 1 1 100%;   /* push to its own line */
  }

  .azure-logo { order: 1; }

  .mode-switcher {
    order: 3;
    margin-left: 0;
    flex: 1 1 auto;
  }

  .header-right {
    order: 1;
    margin-left: auto;
  }

  /* Show sidebar toggle */
  .sidebar-toggle {
    display: flex;
    order: 0;
  }

  /* Sidebar becomes an off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 280px;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Table area fills full width */
  .main {
    height: calc(100vh - 90px); /* taller header */
  }

  .table-area {
    padding: 12px;
    width: 100%;
  }
}

/* ── Mobile (≤ 600px) ── */
@media (max-width: 600px) {

  header {
    padding: 10px 12px;
    gap: 8px;
  }

  /* Hide title text on very small screens to save space */
  header h1 {
    display: none;
  }

  /* Hide scope pill — redundant on mobile */
  .scope-pill {
    display: none;
  }

  /* Mode buttons — icon only on very small screens */
  .mode-btn {
    padding: 6px 10px;
    font-size: 10px;
  }

  .main {
    height: calc(100vh - 58px);
  }

  .table-area {
    padding: 10px 8px;
  }

  /* Summary cards — 2-up grid instead of single row */
  .summary-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .summary-card {
    padding: 8px 12px;
  }

  .summary-val {
    font-size: 18px;
  }

  /* Controls bar — stack vertically */
  .table-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .filter-toggle {
    margin-left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .filter-btn {
    text-align: center;
    padding: 7px 4px;
    font-size: 10px;
  }

  /* Larger touch targets for role items */
  .role-item {
    padding: 12px 16px;
    min-height: 44px;
  }

  /* Larger remove button touch target */
  .remove-role-btn {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }

  /* Fix iOS safari input zoom — font-size must be >= 16px */
  .search-box input {
    font-size: 16px;
  }

  /* Tighten permission name column on small screens */
  td.perm-name-cell {
    min-width: 160px;
    max-width: 200px;
  }

  .perm-name { font-size: 10px; }
  .perm-desc { font-size: 9px; }

  td.perm-value-cell {
    min-width: 80px;
    padding: 8px 8px;
  }
}
