/**
 * BriefFlow Admin Styles
 * Professional dashboard UI
 */

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --accent: #10b981;
  --accent-light: #34d399;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --warning: #f59e0b;
  --complete: #059669;
  --complete-light: #d1fae5;
  --bg: #f1f5f9;
  --bg-white: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* App Layout */
.app {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 24px;
  color: var(--primary-light);
}

.logo-text {
  font-size: 18px;
  font-weight: 700;
  color: white;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all 0.2s;
  margin-bottom: 4px;
}

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

.nav-item.active {
  background: var(--primary);
  color: white;
}

.nav-icon {
  font-size: 18px;
}

.nav-label {
  font-weight: 500;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.ccm-badge {
  font-size: 12px;
  color: var(--sidebar-text);
}

/* Main Content */
.main {
  flex: 1;
  margin-left: 240px;
  padding: 32px;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.header-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

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

.back-link:hover {
  text-decoration: underline;
}

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

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

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

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

.btn-secondary:hover {
  background: var(--bg);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--primary);
}

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

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

.btn-danger:hover {
  background: var(--danger-dark);
}

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

.btn-complete:hover {
  background: #047857;
}

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.stat-card {
  background: var(--bg-white);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.stat-label {
  font-size: 14px;
  color: var(--text-muted);
}

/* Table */
.table-container {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

.table th,
.table td {
  padding: 16px 20px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background: var(--bg);
}

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

.client-name {
  font-weight: 600;
  color: var(--text);
}

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-not_started {
  background: var(--bg);
  color: var(--text-muted);
}

.status-in_progress {
  background: #dbeafe;
  color: #1d4ed8;
}

.status-complete {
  background: #d1fae5;
  color: #059669;
}

.status-revoked {
  background: #fee2e2;
  color: #dc2626;
}

/* Progress bar in table */
.progress-bar-container {
  width: 100px;
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  color: var(--text-muted);
  font-size: 13px;
}

.date-text {
  color: var(--text-light);
  font-size: 13px;
}

/* Table Actions */
.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
}

.action-btn-view {
  background: var(--bg);
  color: var(--text);
}

.action-btn-view:hover {
  background: var(--border);
}

.action-btn-copy {
  background: #dbeafe;
  color: #1d4ed8;
}

.action-btn-copy:hover {
  background: #bfdbfe;
}

.action-btn-preview {
  background: #f3e8ff;
  color: #7c3aed;
}

.action-btn-preview:hover {
  background: #e9d5ff;
}

.action-btn-complete {
  background: var(--complete-light);
  color: var(--complete);
}

.action-btn-complete:hover {
  background: #a7f3d0;
}

.action-btn-revoke {
  background: #fee2e2;
  color: #dc2626;
}

.action-btn-revoke:hover {
  background: #fecaca;
}

/* Loading */
.loading-row td {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
  margin-right: 12px;
  vertical-align: middle;
}

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

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px;
  color: var(--text-muted);
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  display: inline-block;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 64px 32px;
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 18px;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* Form */
.form-container {
  max-width: 640px;
}

.form {
  background: var(--bg-white);
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
}

.form-input,
.form-textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

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

.form-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
}

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

/* Success State */
.success-state {
  background: var(--bg-white);
  padding: 48px 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

.success-icon {
  width: 64px;
  height: 64px;
  background: var(--accent);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin-bottom: 24px;
}

.success-state h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.success-subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.link-box {
  display: flex;
  gap: 8px;
  max-width: 500px;
  margin: 0 auto 32px;
}

.link-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: monospace;
  background: var(--bg);
}

.success-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* View Page */
.view-content {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Tabs */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.tab {
  padding: 16px 24px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

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

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--bg-white);
}

.tab-content {
  display: none;
  padding: 24px;
}

.tab-content.active {
  display: block;
}

/* Conversation */
.conversation {
  max-height: 600px;
  overflow-y: auto;
}

.message {
  margin-bottom: 16px;
  padding: 16px;
  border-radius: var(--radius);
}

.message-assistant {
  background: var(--bg);
  margin-right: 48px;
}

.message-user {
  background: #ede9fe;
  margin-left: 48px;
}

.message-system {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #fef3c7;
  border-radius: 20px;
  font-size: 13px;
  color: #92400e;
  margin: 16px auto;
  width: fit-content;
}

.message-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.message-role {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}

.message-time {
  font-size: 12px;
  color: var(--text-light);
}

.message-content {
  color: var(--text);
  line-height: 1.6;
}

.message-screenshot {
  margin-bottom: 12px;
}

.message-screenshot img {
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  cursor: pointer;
}

.empty-conversation {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
}

/* Captured Data */
.captured-data-container {
  padding: 8px;
}

.captured-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.captured-header h3 {
  font-size: 16px;
  color: var(--text);
}

.json-display {
  background: var(--sidebar-bg);
  color: #a5f3fc;
  padding: 20px;
  border-radius: var(--radius);
  font-family: 'Fira Code', 'Monaco', monospace;
  font-size: 13px;
  overflow-x: auto;
  white-space: pre-wrap;
}

/* Requirements */
.requirements-container h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 12px;
  margin-top: 24px;
}

.requirements-container h3:first-child {
  margin-top: 0;
}

.requirements-display {
  background: var(--bg);
  padding: 20px;
  border-radius: var(--radius);
  white-space: pre-wrap;
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
}

.starting-url {
  color: var(--primary);
  font-family: monospace;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  padding: 32px;
  border-radius: var(--radius-lg);
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  font-size: 18px;
  margin-bottom: 12px;
}

.modal-content p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1001;
}

.toast {
  background: var(--sidebar-bg);
  color: white;
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-top: 8px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideIn 0.3s ease-out;
}

.toast-success {
  border-left: 4px solid var(--accent);
}

.toast-error {
  border-left: 4px solid var(--danger);
}

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

/* Responsive */
@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }
  
  .main {
    margin-left: 200px;
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main {
    margin-left: 0;
  }
  
  .stats {
    grid-template-columns: 1fr;
  }
  
  .header {
    flex-direction: column;
    gap: 16px;
  }
  
  .header-actions {
    width: 100%;
  }
  
  .header-actions .btn {
    flex: 1;
  }
}
