/* ============================================================
   Nixon Law PLLC — Dashboard Styles
   ============================================================ */

/* —— Reset & Base —— */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  /* Brand palette */
  --brand-900: #0f1f3d;
  --brand-800: #162847;
  --brand-700: #1e3a5f;
  --brand-600: #1a4a7a;
  --brand-500: #1d5fa8;
  --brand-400: #3b82c4;
  --brand-300: #7ab3de;
  --brand-100: #dbeafe;
  --brand-50:  #eff6ff;

  /* Neutrals */
  --gray-950: #0a0a0a;
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;
  --white:    #ffffff;

  /* Semantic */
  --success:  #16a34a;
  --success-bg: #dcfce7;
  --warning:  #d97706;
  --warning-bg: #fef3c7;
  --danger:   #dc2626;
  --danger-bg: #fee2e2;
  --info:     #0284c7;
  --info-bg:  #e0f2fe;

  /* Layout */
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --tab-bar-height: 52px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12), 0 4px 10px rgba(0,0,0,.08);

  /* Typography */
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* —— App Shell —— */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--brand-900);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.logo-icon {
  font-size: 22px;
  line-height: 1;
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: .3px;
}

.logo-sub {
  color: var(--brand-300);
}

.sidebar-nav {
  flex: 1;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: var(--white);
}

.nav-item.active {
  background: rgba(255,255,255,.12);
  color: var(--white);
}

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

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--brand-500);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
}

.user-role {
  font-size: 11px;
  color: rgba(255,255,255,.5);
}

/* ============================================================
   MAIN WRAPPER
   ============================================================ */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* —— Top Bar —— */
.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
  z-index: 10;
}

.topbar-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--gray-900);
}

.topbar-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}

.btn-icon:hover {
  background: var(--gray-200);
}

/* ============================================================
   TAB BAR
   ============================================================ */
.tab-bar {
  height: var(--tab-bar-height);
  flex-shrink: 0;
  background: var(--white);
  border-bottom: 2px solid var(--gray-200);
  display: flex;
  align-items: flex-end;
  padding: 0 24px;
  gap: 4px;
  z-index: 9;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-500);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;   /* overlap the tab-bar border */
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  transition: color .15s, background .15s, border-color .15s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--brand-600);
  background: var(--brand-50);
}

.tab-btn.active {
  color: var(--brand-600);
  border-bottom-color: var(--brand-500);
  font-weight: 600;
}

.tab-icon {
  font-size: 15px;
}

/* ============================================================
   TAB PANELS
   ============================================================ */
.tab-panels {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-panel {
  display: none;
  height: 100%;
  overflow-y: auto;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* ============================================================
   CHAT TAB
   ============================================================ */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px;
  overflow: hidden;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

/* Chat header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
}

.chat-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 1px;
}

/* Chat messages */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.message {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  max-width: 80%;
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message.assistant {
  align-self: flex-start;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.message.assistant .message-avatar {
  background: linear-gradient(135deg, var(--brand-600), var(--brand-400));
  color: var(--white);
}

.message.user .message-avatar {
  background: var(--gray-700);
  color: var(--white);
}

.message-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

.message.assistant .message-bubble {
  background: var(--gray-100);
  color: var(--gray-900);
  border-top-left-radius: 4px;
}

.message.user .message-bubble {
  background: var(--brand-600);
  color: var(--white);
  border-top-right-radius: 4px;
}

.message-bubble p {
  margin-bottom: 6px;
}

.message-bubble p:last-of-type {
  margin-bottom: 4px;
}

.message-time {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  opacity: .6;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 0;
}

.typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gray-400);
  animation: typing-bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: .2s; }
.typing-dot:nth-child(3) { animation-delay: .4s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%            { transform: translateY(-6px); }
}

/* Chat input */
.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
  flex-shrink: 0;
}

.chat-input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  transition: border-color .2s, box-shadow .2s;
}

.chat-input-wrapper:focus-within {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(29,95,168,.12);
}

.chat-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font);
  font-size: 14px;
  color: var(--gray-900);
  resize: none;
  max-height: 140px;
  line-height: 1.5;
}

.chat-input::placeholder {
  color: var(--gray-400);
}

.send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--brand-600);
  color: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}

.send-btn:hover {
  background: var(--brand-700);
}

.send-btn:active {
  transform: scale(.95);
}

.send-btn:disabled {
  background: var(--gray-300);
  cursor: not-allowed;
  transform: none;
}

.chat-disclaimer {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 8px;
  text-align: center;
}

/* Secondary button */
.btn-secondary {
  padding: 7px 14px;
  border: 1.5px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-600);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}

.btn-secondary:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
  color: var(--gray-800);
}

/* ============================================================
   MATTERS TAB
   ============================================================ */
.matters-content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow: hidden;
}

.matters-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.matters-toolbar-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.matters-heading {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.matters-count {
  font-size: 13px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 2px 10px;
  border-radius: 20px;
  font-weight: 500;
}

.matters-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  transition: border-color .2s, box-shadow .2s;
}

.search-box:focus-within {
  border-color: var(--brand-400);
  box-shadow: 0 0 0 3px rgba(29,95,168,.10);
}

.search-icon {
  font-size: 14px;
  color: var(--gray-400);
}

.search-input {
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 13.5px;
  color: var(--gray-800);
  background: transparent;
  width: 200px;
}

.search-input::placeholder {
  color: var(--gray-400);
}

.btn-primary {
  padding: 8px 16px;
  background: var(--brand-600);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--brand-700);
}

/* Table */
.table-wrapper {
  flex: 1;
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: auto;
}

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

.matters-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.matters-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.matters-table th {
  background: var(--gray-50);
  padding: 12px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .6px;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

.matters-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.matters-table tbody tr {
  transition: background .12s;
}

.matters-table tbody tr:hover {
  background: var(--brand-50);
}

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

.matter-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

.matter-id {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.client-cell {
  display: flex;
  align-items: center;
  gap: 9px;
}

.client-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand-100);
  color: var(--brand-700);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-active {
  background: var(--success-bg);
  color: var(--success);
}

.status-review {
  background: var(--info-bg);
  color: var(--info);
}

.status-pending {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-closed {
  background: var(--gray-100);
  color: var(--gray-500);
}

.activity-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
}

.activity-desc {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 2px;
}

.btn-row {
  padding: 5px 12px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  color: var(--brand-600);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.btn-row:hover {
  background: var(--brand-50);
  border-color: var(--brand-300);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }

  .main-content,
  .matters-content {
    padding: 16px;
  }

  .tab-bar {
    padding: 0 16px;
  }

  .topbar {
    padding: 0 16px;
  }

  .message {
    max-width: 95%;
  }

  .matters-toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-input {
    width: 140px;
  }
}
