/* ========================================
   Trusty Access Vault - App Styles
   Design tokens from landing page
   ======================================== */
:root {
  --ink: #0a0e17;
  --paper: #f8f7f4;
  --accent: #1a6b4a;
  --accent-light: #e8f5ee;
  --accent-hover: #155a3d;
  --warm: #c4956a;
  --warm-light: #fdf3eb;
  --muted: #6b7280;
  --border: #e5e3de;
  --red: #c44b4b;
  --red-light: #fde8e8;
  --orange: #d4873e;
  --orange-light: #fdf3eb;
  --green: #1a6b4a;
  --green-light: #e8f5ee;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(10,14,23,0.04);
  --shadow-md: 0 4px 16px rgba(10,14,23,0.06);
  --shadow-lg: 0 12px 40px rgba(10,14,23,0.08);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

h1, h2, h3, h4 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.15;
}

/* ========================================
   AUTH PAGES
   ======================================== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.auth-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 3rem;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 2rem;
}

.auth-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.auth-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.auth-card .subtitle {
  color: var(--muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--ink);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: white;
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--paper);
  border-color: var(--muted);
}

.btn-danger {
  background: var(--red);
  color: white;
}

.btn-danger:hover {
  background: #a83c3c;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
  background: var(--paper);
  color: var(--ink);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.auth-footer {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* ========================================
   APP LAYOUT
   ======================================== */
.app-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--white);
  border-right: 1px solid var(--border);
  padding: 1.5rem 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.25rem;
  margin-bottom: 0.5rem;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
}

.sidebar-logo .logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.85rem;
}

.sidebar-company {
  padding: 0 1.25rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  border-left: 3px solid transparent;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--paper);
  color: var(--ink);
}

.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.nav-item .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.sidebar-user .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
}

.sidebar-user .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user .user-name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user .user-role {
  font-size: 0.75rem;
  color: var(--muted);
}

.main-content {
  padding: 2rem;
  overflow-y: auto;
  max-height: 100vh;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
}

.page-header .actions {
  display: flex;
  gap: 0.75rem;
}

/* ========================================
   STATS CARDS
   ======================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
}

.stat-card .stat-detail {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

.stat-card.stat-green .stat-value { color: var(--green); }
.stat-card.stat-orange .stat-value { color: var(--orange); }
.stat-card.stat-red .stat-value { color: var(--red); }

/* ========================================
   SECURITY SCORE
   ======================================== */
.security-score {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.score-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: white;
}

.score-green { background: var(--green); }
.score-orange { background: var(--orange); }
.score-red { background: var(--red); }

/* ========================================
   DATA TABLE
   ======================================== */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
}

.card-body {
  padding: 1.5rem;
}

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

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}

.data-table td {
  padding: 0.85rem 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: var(--paper);
}

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 500;
}

.badge-green { background: var(--green-light); color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-muted { background: var(--paper); color: var(--muted); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* ========================================
   MODAL
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,14,23,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 2rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(10,14,23,0.15);
  transform: translateY(10px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--paper);
  color: var(--muted);
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--border);
  color: var(--ink);
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ========================================
   CREDENTIAL ROW
   ======================================== */
.cred-name {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.cred-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.cred-info .name {
  font-weight: 500;
}

.cred-info .url {
  font-size: 0.78rem;
  color: var(--muted);
}

.password-field {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.password-dots {
  letter-spacing: 2px;
  color: var(--muted);
}

.btn-reveal {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
}

.btn-reveal:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cred-actions {
  display: flex;
  gap: 0.25rem;
}

/* ========================================
   TEAM MEMBER ROW
   ======================================== */
.member-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.member-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.member-avatar.revoked {
  background: var(--red-light);
  color: var(--red);
}

.member-details .name {
  font-weight: 500;
}

.member-details .email {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ========================================
   GROUP CARD
   ======================================== */
.groups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.group-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}

.group-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.group-card h4 {
  font-size: 1.05rem;
  margin-bottom: 0.25rem;
}

.group-card .desc {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 1rem;
}

.group-stat {
  display: flex;
  gap: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.group-stat span {
  font-size: 0.82rem;
  color: var(--muted);
}

.group-stat strong {
  color: var(--ink);
}

/* ========================================
   AUDIT LOG
   ======================================== */
.audit-item {
  display: flex;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
}

.audit-item:last-child {
  border-bottom: none;
}

.audit-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 0.5rem;
  flex-shrink: 0;
}

.audit-content {
  flex: 1;
}

.audit-content .action {
  font-weight: 500;
  font-size: 0.9rem;
}

.audit-content .meta {
  font-size: 0.78rem;
  color: var(--muted);
}

/* ========================================
   OFFBOARD CONFIRMATION
   ======================================== */
.offboard-warning {
  background: var(--red-light);
  border: 1px solid var(--red);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.offboard-warning h4 {
  color: var(--red);
  margin-bottom: 0.5rem;
}

.offboard-warning p {
  font-size: 0.9rem;
  color: var(--red);
}

.offboard-result {
  background: var(--green-light);
  border: 1px solid var(--green);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.offboard-result h4 {
  color: var(--green);
  margin-bottom: 0.5rem;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.15rem;
  color: var(--ink);
  margin-bottom: 0.5rem;
}

.empty-state p {
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ========================================
   TOAST NOTIFICATION
   ======================================== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--ink);
  color: white;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast.toast-success { background: var(--green); }
.toast.toast-error { background: var(--red); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ========================================
   LOADING
   ======================================== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--muted);
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================
   CHECKBOX GROUP
   ======================================== */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.checkbox-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ========================================
   INVITE RESULT
   ======================================== */
.invite-link-box {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
}

.invite-link-box input {
  flex: 1;
  border: none;
  background: none;
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--ink);
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    display: none;
  }

  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    gap: 0;
    z-index: 100;
    justify-content: space-around;
  }

  .mobile-nav .nav-item {
    flex-direction: column;
    padding: 0.5rem;
    font-size: 0.7rem;
    border-left: none;
    border-bottom: 2px solid transparent;
    gap: 0.25rem;
  }

  .mobile-nav .nav-item.active {
    border-bottom-color: var(--accent);
    background: transparent;
  }

  .main-content {
    padding-bottom: 5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .groups-grid {
    grid-template-columns: 1fr;
  }
}
