/* SmartLaw PSA - Dark Professional Theme */
:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-input: #0f172a;
  --border: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.3);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'IBM Plex Sans', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100dvh;
  overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Layout */
.app-layout {
  display: flex;
  min-height: 100dvh;
}

/* Sidebar - desktop */
.sidebar {
  width: 240px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-brand {
  padding: 20px;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}
.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: .9rem;
  font-weight: 500;
  transition: all .15s;
}
.nav-item:hover { background: rgba(59,130,246,.1); color: var(--text-primary); }
.nav-item.active { background: rgba(59,130,246,.15); color: var(--accent); }
.nav-item .material-icons-round { font-size: 20px; }
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.user-badge {
  display: block;
  padding: 6px 14px;
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Main content */
.main-content {
  flex: 1;
  margin-left: 240px;
  padding: 24px;
  padding-bottom: 24px;
  min-height: 100dvh;
}

/* Bottom nav - mobile */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 8px 0;
  flex: 1;
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 500;
  gap: 2px;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item .material-icons-round { font-size: 22px; }
.bottom-nav-item.active { color: var(--accent); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 1.5rem;
  font-weight: 700;
}
.page-subtitle {
  color: var(--text-secondary);
  font-size: .9rem;
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
}

/* Stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  font-weight: 600;
}
.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  margin-top: 4px;
}

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
th {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:hover td { background: rgba(59,130,246,.04); }
th.sortable a {
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
th.sortable a:hover { color: var(--accent); }
.sort-arrow { font-size: 14px !important; }

/* Badges / Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-on-site {
  background: rgba(245,158,11,.15);
  color: #f59e0b;
  border: 1px solid rgba(245,158,11,.3);
}
.badge-remote {
  background: rgba(59,130,246,.12);
  color: #60a5fa;
  border: 1px solid rgba(59,130,246,.25);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.btn .material-icons-round { font-size: 18px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-secondary { background: var(--bg-input); color: var(--text-primary); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #000; }
.btn-sm { padding: 6px 12px; font-size: .8rem; min-height: 36px; }
.btn-icon { padding: 8px; min-height: 36px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: .9rem;
  min-height: 44px;
  transition: border-color .15s;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
select.form-input { appearance: auto; }
textarea.form-input { min-height: 80px; resize: vertical; }
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 20px;
}
.filter-bar .form-input { width: auto; min-width: 140px; }
.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  min-height: 36px;
}
.filter-pill.active {
  background: rgba(59,130,246,.15);
  border-color: var(--accent);
  color: var(--accent);
}

/* Section for on-site items */
.on-site-section {
  background: rgba(245,158,11,.06);
  border: 1px solid rgba(245,158,11,.2);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}
.on-site-section .card-title {
  color: #f59e0b;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Task/ticket list items */
.item-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-title { font-weight: 500; flex: 1; min-width: 0; }
.item-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

/* Phase block */
.phase-block {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}
.phase-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}
.phase-header.completed { opacity: .6; }
.phase-body { padding: 0; }
.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.task-row:last-child { border-bottom: none; }
.task-row:hover { background: rgba(59,130,246,.04); }
.task-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-info { flex: 1; min-width: 0; }
.task-info a { color: var(--text-primary); }
.task-info a:hover { color: var(--accent); }
.task-meta { font-size: .8rem; color: var(--text-muted); }

/* Subtasks */
.subtask-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.subtask-item:last-child { border-bottom: none; }
.subtask-item.done { opacity: .5; text-decoration: line-through; }

/* Comments */
.comment {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: none; }
.comment-header {
  display: flex;
  justify-content: space-between;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.comment-body { font-size: .9rem; white-space: pre-wrap; }

/* Timer */
.timer-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(59,130,246,.08);
  border: 1px solid rgba(59,130,246,.2);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.timer-bar.running {
  background: rgba(16,185,129,.08);
  border-color: rgba(16,185,129,.3);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .85; }
}

/* Priority indicators */
.priority-urgent { color: var(--danger); }
.priority-high { color: var(--warning); }
.priority-medium { color: var(--accent); }
.priority-low { color: var(--text-muted); }

/* Login page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
}
.login-brand {
  text-align: center;
  margin-bottom: 30px;
}
.login-brand h1 {
  font-size: 1.5rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.login-error {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.3);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: .85rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .material-icons-round { font-size: 48px; margin-bottom: 12px; opacity: .4; }

/* Messages */
.messages { margin-bottom: 16px; }
.msg {
  padding: 10px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: .875rem;
}
.msg-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: var(--success); }
.msg-error { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.3); color: var(--danger); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content {
    margin-left: 0;
    padding: 16px;
    padding-bottom: 80px;
  }
  .bottom-nav { display: flex; }
  .page-title { font-size: 1.25rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.5rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .form-row { flex-direction: column; gap: 0; }
  .table-wrap { margin: 0 -16px; }
  table { font-size: .8rem; }
  th, td { padding: 10px; }
  .page-header { margin-bottom: 16px; }
  .card { padding: 16px; }
  .filter-bar { gap: 8px; }
  .filter-bar .form-input { min-width: 0; flex: 1; }
  .phase-header { padding: 12px 14px; }
  .task-row { padding: 10px 14px; }
  .on-site-section { padding: 14px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 1.3rem; }
  .btn { padding: 10px 14px; }
}

/* Print */
@media print {
  .sidebar, .bottom-nav { display: none; }
  .main-content { margin-left: 0; }
  body { background: #fff; color: #000; }
}
