/* Go Chat Bridge - Admin Console Stylesheet */

:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-subtle: #94a3b8;
  
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-light: #eff6ff;
  --color-primary-subtle: #dbeafe;
  
  --color-success: #16a34a;
  --color-success-bg: #f0fdf4;
  --color-success-border: #bbf7d0;
  
  --color-danger: #dc2626;
  --color-danger-hover: #b91c1c;
  --color-danger-bg: #fef2f2;
  --color-danger-border: #fecaca;
  
  --color-warning: #ea580c;
  --color-warning-bg: #fff7ed;
  --color-warning-border: #ffedd5;
  
  --color-sidebar: #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-sidebar-text: #cbd5e1;
  --color-sidebar-active: #ffffff;
  
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.04);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.08), 0 1px 2px -1px rgb(0 0 0 / 0.08);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.08);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  
  --sidebar-width: 260px;
}

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

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
}

/* Accessibility: Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: white;
  padding: 8px;
  z-index: 100;
  transition: top 0.2s;
  text-decoration: none;
  font-weight: 500;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus {
  top: 0;
  outline: 2px solid white;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Global Layout */
.container {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* Header & Footer */
.global-header {
  background-color: var(--color-sidebar);
  color: #f8fafc;
  padding: 1rem 0;
  border-bottom: 1px solid #1e293b;
}

.global-header-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.global-nav {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover, .nav-link:focus-visible {
  color: #ffffff;
  border-color: var(--color-primary);
}

.global-footer {
  text-align: center;
  padding: 3rem 1.5rem 2rem;
  color: var(--color-text-subtle);
  font-size: 0.8125rem;
  border-top: 1px solid var(--color-border);
  margin-top: 2rem;
}

/* Headings */
h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
  line-height: 1.2;
}

h2 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 1rem;
  letter-spacing: -0.01em;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  line-height: 1.5;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-sm);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background-color: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background-color: var(--color-bg);
  border-color: #cbd5e1;
}

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

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

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
}

.btn-text {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
}

.btn-text:hover {
  text-decoration: none;
  background-color: var(--color-primary-light);
}

.btn-text-danger {
  color: var(--color-danger);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  transition: background-color 0.15s;
}

.btn-text-danger:hover {
  text-decoration: none;
  background-color: var(--color-danger-bg);
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
}

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #1e293b;
}

.sidebar-header .brand {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-header .brand::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background-color: var(--color-primary);
  border-radius: 50%;
}

.sidebar-nav {
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav .nav-link {
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-md);
  border-bottom: none;
  transition: background-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-nav .nav-link:hover {
  background-color: var(--color-sidebar-hover);
  color: #ffffff;
  border-color: transparent;
}

.sidebar-nav .nav-link.active {
  background-color: var(--color-sidebar-hover);
  color: var(--color-sidebar-active);
  font-weight: 600;
}

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  padding: 2rem 2.5rem;
  max-width: 100%;
}

/* Page Headers */
.page-header {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

@media (min-width: 640px) {
  .page-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
}

.header-desc {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin-top: 0.25rem;
}

.page-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-decoration: none;
  margin-bottom: 0.5rem;
}

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

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.925rem;
  border: 1px solid transparent;
}

.alert-error {
  background-color: var(--color-danger-bg);
  border-color: var(--color-danger-border);
  color: var(--color-danger);
}

.alert-success {
  background-color: var(--color-success-bg);
  border-color: var(--color-success-border);
  color: var(--color-success);
}

/* Login Page Layout */
.login-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background-color: var(--color-bg);
  padding: 1.5rem;
}

.login-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 2.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-xl);
}

.login-kicker {
  text-transform: uppercase;
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--color-primary);
  margin-bottom: 0.625rem;
}

.login-card h1 {
  font-size: 1.625rem;
  margin-bottom: 0.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-desc {
  color: var(--color-text-muted);
  font-size: 0.9375rem;
  margin-bottom: 2rem;
  line-height: 1.5;
}

/* Cards & Grid */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.grid {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
  .grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Detail Page Header */
.detail-header {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

@media (min-width: 640px) {
  .detail-header {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-end;
  }
}

.detail-subtitle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.detail-divider {
  color: var(--color-border);
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
}

/* Detail Table */
.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table th, .detail-table td {
  padding: 0.75rem 0;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

.detail-table tr:last-child th, .detail-table tr:last-child td {
  border-bottom: none;
}

.detail-table th {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.875rem;
  width: 140px;
}

.credential-masked code {
  background-color: var(--color-bg);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  word-break: break-all;
}

/* Health check indicator */
.health-status-block {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 1.1rem;
}

.status-indicator-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot-healthy { background-color: var(--color-success); }
.dot-unhealthy { background-color: var(--color-danger); }
.dot-unknown { background-color: var(--color-text-muted); }

.text-healthy { color: var(--color-success); }
.text-unhealthy { color: var(--color-danger); }
.text-unknown { color: var(--color-text-muted); }

/* Tables (List view) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background-color: var(--color-surface);
  box-shadow: var(--shadow-xs);
}

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

.table th, .table td {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
}

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

.table th {
  background-color: #f8fafc;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
}

.table tbody tr {
  transition: background-color 0.12s ease;
}

.table tbody tr:hover {
  background-color: #f8fafc;
}

.name-link {
  color: var(--color-text);
  text-decoration: none;
  font-weight: 600;
}

.name-link:hover {
  color: var(--color-primary);
  text-decoration: none;
}

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

.inline-form {
  display: inline-block;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1875rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: capitalize;
  line-height: 1.4;
}

.badge-status {
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
}

.badge-healthy {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-unhealthy {
  background-color: var(--color-danger-bg);
  color: var(--color-danger);
  border: 1px solid var(--color-danger-border);
}

.badge-unknown {
  background-color: #f1f5f9;
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge-type {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid var(--color-border);
}

.badge-type-mock {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-type-telegram {
  background-color: #f0f9ff;
  color: #0284c7;
  border: 1px solid #bae6fd;
}

.badge-type-waha {
  background-color: #f5f3ff;
  color: #6d28d9;
  border: 1px solid #ddd6fe;
}

.badge-public {
  background-color: var(--color-success-bg);
  color: var(--color-success);
  border: 1px solid var(--color-success-border);
}

.badge-private {
  background-color: var(--color-warning-bg);
  color: var(--color-warning);
  border: 1px solid var(--color-warning-border);
}

.cell-hint {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.cell-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Forms */
.form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-standard {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow-sm);
}

.form-section {
  border: none;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-section legend {
  font-weight: 700;
  font-size: 1.1rem;
  color: #0f172a;
  margin-bottom: 0.5rem;
  padding: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.625rem 0.875rem;
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: #94a3b8;
}

.mono-input {
  font-family: var(--font-mono) !important;
  font-size: 0.85rem !important;
  line-height: 1.4 !important;
}

.input-disabled {
  background-color: #f1f5f9 !important;
  color: var(--color-text-muted) !important;
  cursor: not-allowed;
}

.help-text {
  font-size: 0.825rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.help-text.block {
  display: block;
  margin-top: 0.25rem;
}

.section-desc {
  margin-bottom: 0.5rem;
}

.text-masked code {
  color: var(--color-warning);
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
  padding: 0.1rem 0.3rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
}

/* Radio Cards */
.radio-card-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 640px) {
  .radio-card-group {
    flex-direction: row;
  }
}

.radio-card {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}

.radio-card:hover {
  background-color: var(--color-bg);
  border-color: #cbd5e1;
}

.radio-card input[type="radio"] {
  margin-top: 0.25rem;
}

.radio-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.radio-card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
}

.radio-card-desc {
  font-size: 0.825rem;
  color: var(--color-text-muted);
}

/* Form Actions */
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Access Control Specifics */
.access-add-form {
  display: flex;
  gap: 0.5rem;
  margin: 1rem 0 1.5rem;
}

.access-add-form input {
  padding: 0.5rem 0.75rem;
  font-family: inherit;
  font-size: 0.9rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.access-add-form input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.flex-1 {
  flex: 1;
}

.access-list {
  list-style: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background-color: var(--color-surface);
}

.access-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-border);
}

.access-list li:last-child {
  border-bottom: none;
}

.sender-id code {
  background-color: var(--color-bg);
  padding: 0.2rem 0.4rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.empty-list-notice {
  text-align: center;
  padding: 2rem;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Empty States */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.empty-icon {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.empty-state h2 {
  font-size: 1.35rem;
  margin-bottom: 0.5rem;
}

.empty-state p {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
}

/* Text formatting helpers */
.text-uppercase {
  text-transform: uppercase;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    position: relative;
    top: auto;
    left: auto;
    bottom: auto;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    padding: 0.5rem;
  }

  .sidebar-nav .nav-link {
    flex: 1;
    min-width: 120px;
    justify-content: center;
  }

  .main-content {
    margin-left: 0;
    padding: 1.5rem 1rem;
  }

  .app-wrapper {
    flex-direction: column;
  }

  .global-footer {
    padding: 2rem 1rem 1.5rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .detail-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .table th, .table td {
    padding: 0.75rem 0.875rem;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 1.5rem;
  }

  .actions {
    flex-direction: column;
    gap: 0.25rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .btn {
    width: 100%;
  }
}
