/* ==================== */
/* Weedon Law - Admin Portal CSS */
/* ==================== */

:root {
  --teal: #0e7c7b;
  --teal-dark: #0a5e5d;
  --teal-light: #f0f9f9;
  --navy: #1a2332;
  --navy-dark: #111827;
  --red: #dc2626;
  --green: #16a34a;
  --amber: #d97706;
  --blue: #2563eb;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--gray-800);
  line-height: 1.6;
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

/* ==================== */
/* Admin header */
/* ==================== */
.admin-header {
  background: var(--navy);
  color: white;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-logo { height: 32px; filter: brightness(10); }

.header-titles { display: flex; flex-direction: column; line-height: 1.2; }
.header-firm { font-weight: 700; font-size: 15px; }
.header-subtitle { font-size: 12px; opacity: 0.7; }

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

/* User menu */
.user-menu { position: relative; }

.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--teal);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}

.user-avatar:hover { opacity: 0.9; }

.user-dropdown {
  position: absolute;
  top: 44px;
  right: 0;
  width: 240px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  display: none;
  z-index: 200;
}

.user-dropdown.show { display: block; }

.dropdown-header {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dropdown-header strong { color: var(--gray-800); font-size: 14px; }
.dropdown-email { font-size: 12px; color: var(--gray-500); }

.dropdown-divider { height: 1px; background: var(--gray-200); }

.dropdown-item {
  display: block;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--gray-600);
  text-decoration: none;
  transition: background 0.1s;
}

.dropdown-item:hover { background: var(--gray-50); }

.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.role-super_admin { background: #fef3c7; color: #92400e; }
.role-staff { background: #eff6ff; color: #1e40af; }

/* ==================== */
/* Admin main */
/* ==================== */
.admin-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

/* ==================== */
/* Dashboard */
/* ==================== */
.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.dashboard-header h2 { font-size: 24px; font-weight: 700; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-number { font-size: 32px; font-weight: 700; color: var(--teal); }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; }

/* Filters */
.filters {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-pills { display: flex; gap: 8px; }

.pill {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  background: var(--gray-100);
  color: var(--gray-600);
  transition: all 0.15s;
}

.pill:hover { background: var(--gray-200); }
.pill.active { background: var(--teal); color: white; }

.search-form { display: flex; gap: 8px; }

.search-input {
  padding: 8px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  width: 280px;
  outline: none;
}

.search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.1);
}

/* Links table */
.links-table-wrapper {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.links-table thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.links-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

.link-row { cursor: pointer; transition: background 0.1s; }
.link-row:hover { background: var(--gray-50); }

.link-client { font-weight: 600; color: var(--gray-800); }
.link-file { font-size: 13px; color: var(--gray-500); }
.link-email { color: var(--gray-600); }
.link-date { color: var(--gray-500); font-size: 13px; }

.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--gray-400);
  font-size: 14px;
}

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
}

.status-active { background: #dcfce7; color: #166534; }
.status-used { background: #dbeafe; color: #1e40af; }
.status-expired { background: #fef3c7; color: #92400e; }
.status-revoked { background: #fef2f2; color: #991b1b; }

/* Sync icons */
.sync-cell { text-align: center; }

.sync-icon { font-size: 16px; }
.sync-verified { color: var(--green); }
.sync-none { color: var(--gray-300); }

.sync-status { font-size: 13px; }
.sync-ok { color: var(--green); }
.sync-pending { color: var(--amber); }
.sync-error { color: var(--red); }
.sync-note { font-size: 11px; color: var(--gray-400); display: block; }

/* ==================== */
/* Buttons */
/* ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  line-height: 1.2;
}

.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: var(--teal-dark); }
.btn-primary:disabled { background: var(--gray-300); cursor: not-allowed; }

.btn-outline {
  background: white;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-outline:hover { background: var(--gray-50); }

.btn-danger-outline {
  background: white;
  color: var(--red);
  border: 1px solid var(--red);
}

.btn-danger-outline:hover { background: #fef2f2; }

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

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-xs { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* ==================== */
/* Login page */
/* ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--navy);
}

.login-container { width: 100%; max-width: 400px; }

.login-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { height: 56px; margin-bottom: 12px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--navy); }
.login-subtitle { font-size: 14px; color: var(--gray-500); margin-top: 4px; }

.error-box {
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: var(--red);
  font-size: 14px;
  margin-bottom: 20px;
}

.btn-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-sso:hover { background: var(--gray-50); border-color: var(--gray-400); }

.ms-icon { flex-shrink: 0; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0;
  color: var(--gray-400);
  font-size: 13px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

.login-form .form-group { margin-bottom: 16px; }

.login-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
}

.login-form input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.1);
}

/* ==================== */
/* Create Link page */
/* ==================== */
.create-link-page { max-width: 640px; }

.page-header {
  margin-bottom: 24px;
}

.back-link {
  font-size: 14px;
  color: var(--gray-500);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 8px;
}

.back-link:hover { color: var(--teal); }

.page-header h2 { font-size: 24px; font-weight: 700; }

.create-link-form-wrapper {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 32px;
}

.create-link-form .form-group { margin-bottom: 20px; }

.create-link-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.required { color: var(--red); }

.create-link-form input[type="text"],
.create-link-form input[type="email"],
.create-link-form select,
.create-link-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  outline: none;
}

.create-link-form input:focus,
.create-link-form select:focus,
.create-link-form textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(14, 124, 123, 0.1);
}

.create-link-form textarea { resize: vertical; }

/* Folder picker */
.folder-picker-area { margin-top: 4px; }

.selected-folder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--teal-light);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  margin-top: 8px;
  font-size: 14px;
  color: var(--gray-700);
}

.subfolder-preview {
  margin-top: 8px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius);
}

.subfolder-label { font-size: 12px; color: var(--gray-500); display: block; }
.subfolder-name { font-size: 14px; font-weight: 600; color: var(--green); display: block; margin: 4px 0; }
.subfolder-note { font-size: 12px; color: var(--gray-400); display: block; }

.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-200);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: white;
  padding: 14px 24px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1000;
  font-size: 14px;
  font-weight: 500;
}

.toast-icon { color: var(--green); font-size: 18px; }

/* ==================== */
/* Matter detail page */
/* ==================== */
.matter-detail { max-width: 900px; }

.page-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header-right h2 { font-size: 22px; }

.file-number-badge {
  padding: 4px 10px;
  background: var(--gray-100);
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-600);
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.link-id-display {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

.link-id-display code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 3px;
}

/* Detail cards */
.detail-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.detail-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
}

.detail-label { font-size: 12px; color: var(--gray-500); text-transform: uppercase; font-weight: 600; margin-bottom: 4px; }
.detail-value { font-size: 14px; font-weight: 600; }

/* Sections */
.detail-section {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.detail-section h3 { font-size: 16px; margin-bottom: 16px; color: var(--gray-800); }

.folder-path {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-600);
}

/* File table */
.file-table-wrapper { overflow-x: auto; }

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

.file-table th {
  padding: 8px 12px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
}

.file-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
}

.file-name { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--gray-500); font-size: 13px; }

.file-type-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.file-type-pdf { background: #fef2f2; color: #dc2626; }
.file-type-docx { background: #eff6ff; color: #2563eb; }
.file-type-xlsx { background: #f0fdf4; color: #16a34a; }
.file-type-jpg, .file-type-jpeg { background: #fffbeb; color: #d97706; }
.file-type-png { background: #faf5ff; color: #7c3aed; }
.file-type-tif, .file-type-tiff { background: #ecfeff; color: #0891b2; }

/* Client message */
.client-message-box, .internal-notes-box {
  padding: 14px;
  background: var(--gray-50);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--gray-700);
  white-space: pre-wrap;
}

.internal-notes-box { border-left: 3px solid var(--amber); }

/* Activity timeline */
.activity-timeline { position: relative; }

.timeline-item {
  display: flex;
  gap: 16px;
  padding-bottom: 20px;
  position: relative;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 20px;
  bottom: 0;
  width: 2px;
  background: var(--gray-200);
}

.timeline-item:last-child::before { display: none; }

.timeline-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 2px;
}

.timeline-files_uploaded .timeline-dot { background: var(--green); }
.timeline-otp_verified .timeline-dot { background: var(--blue); }
.timeline-otp_requested .timeline-dot { background: var(--blue); }
.timeline-otp_failed .timeline-dot { background: var(--red); }
.timeline-link_clicked .timeline-dot { background: var(--amber); }
.timeline-link_created .timeline-dot { background: #7c3aed; }
.timeline-link_revoked .timeline-dot { background: var(--red); }
.timeline-matter_viewed .timeline-dot { background: var(--gray-400); }
.timeline-matter_deleted .timeline-dot { background: var(--red); }
.timeline-file_deleted .timeline-dot { background: var(--red); }

.timeline-content { flex: 1; min-width: 0; }

.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.timeline-event { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.timeline-time { font-size: 12px; color: var(--gray-400); white-space: nowrap; }
.timeline-desc { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

.timeline-details {
  margin-top: 8px;
  font-size: 13px;
}

.timeline-details summary {
  cursor: pointer;
  color: var(--gray-400);
  font-size: 12px;
}

.timeline-details summary:hover { color: var(--teal); }

.detail-grid {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.detail-item {
  display: flex;
  gap: 8px;
}

.detail-key {
  font-size: 12px;
  color: var(--gray-400);
  min-width: 100px;
  flex-shrink: 0;
}

.detail-val {
  font-size: 12px;
  color: var(--gray-600);
  word-break: break-all;
}

.detail-val code, code.detail-val {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--gray-100);
  padding: 1px 4px;
  border-radius: 3px;
}

.detail-val pre {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 11px;
  background: var(--gray-100);
  padding: 8px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Action bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 24px;
  border-top: 1px solid var(--gray-200);
  margin-top: 16px;
}

.action-bar-left { display: flex; gap: 12px; }
.action-bar-right { display: flex; gap: 12px; }

/* Forbidden page */
.forbidden-page {
  text-align: center;
  padding: 60px 20px;
}

.forbidden-page h2 { font-size: 24px; margin-bottom: 12px; color: var(--gray-700); }
.forbidden-page p { color: var(--gray-500); margin-bottom: 24px; }

/* ==================== */
/* Responsive */
/* ==================== */
@media (max-width: 768px) {
  .admin-main { padding: 16px; }
  .stats-row { grid-template-columns: 1fr; }
  .filters { flex-direction: column; align-items: stretch; }
  .search-form { width: 100%; }
  .search-input { width: 100%; }
  .detail-cards { grid-template-columns: repeat(2, 1fr); }
  .page-header-right { flex-direction: column; align-items: flex-start; }
}
