/* CSS Variables */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --secondary: #64748b;
  --secondary-hover: #475569;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --border-color: #334155;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
  --radius: 8px;
  --radius-lg: 12px;
}

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

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu,
    sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Utilities */
.hidden {
  /* biome-ignore lint/complexity/noImportantStyles: strictly required to override specificity */
  display: none !important;
}

.loading {
  color: var(--text-muted);
  text-align: center;
  padding: 2rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

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

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

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

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

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

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: 50%;
}

/* Forms */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.input-group {
  display: flex;
  gap: 0;
}

.input-group select {
  width: auto;
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
}

.input-group input {
  border-radius: 0 var(--radius) var(--radius) 0;
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: 400;
  color: var(--text-primary);
}

.checkbox-label input {
  width: auto;
  margin-top: 0.25rem;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* Login Screen */
.screen {
  min-height: 100vh;
}

.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.logo {
  text-align: center;
  margin-bottom: 2rem;
}

.logo h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.logo p {
  color: var(--text-secondary);
}

.login-hint {
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
}

.header h1 {
  font-size: 1.5rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-info {
  color: var(--text-secondary);
  font-size: 0.875rem;
}

/* Navigation */
.nav {
  display: flex;
  gap: 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 2rem;
}

.nav-btn {
  padding: 1rem 1.5rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nav-btn:hover {
  color: var(--text-primary);
}

.nav-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Content */
.main-content {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.tab-header h2 {
  font-size: 1.5rem;
}

/* Documents */
.documents-section {
  margin-bottom: 2rem;
}

.documents-section h3 {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.document-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: all 0.2s ease;
}

.document-card:hover {
  border-color: var(--primary);
}

.document-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.document-id {
  font-family: monospace;
  font-size: 0.875rem;
  color: var(--text-primary);
  word-break: break-all;
}

.document-type {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 9999px;
  color: var(--text-secondary);
}

.document-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.document-meta span {
  display: block;
  margin-bottom: 0.25rem;
}

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

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-muted);
}

/* Tokens */
.tokens-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.token-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.token-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.token-name {
  font-weight: 600;
}

.token-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 1.5rem;
  margin-bottom: 0.75rem;
}

.token-scopes {
  display: flex;
  gap: 0.5rem;
}

.scope-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 9999px;
  color: var(--text-secondary);
}

/* Account */
.account-info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.info-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.info-card h3 {
  font-size: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.info-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-color);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: var(--text-secondary);
}

.info-value {
  font-weight: 500;
}

.quota-bar {
  margin-top: 0.5rem;
}

.quota-bar-track {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.quota-bar-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}

.quota-bar-fill.warning {
  background: var(--warning);
}

.quota-bar-fill.danger {
  background: var(--danger);
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-content.modal-small {
  max-width: 380px;
}

.modal-content.modal-large {
  max-width: 640px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
  font-size: 1.125rem;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-content form,
.modal-content > div:not(.modal-header) {
  padding: 1.5rem;
}

/* ACL Editor */
.acl-doc-info {
  padding: 1rem 1.5rem;
  background: var(--bg-tertiary);
  font-family: monospace;
  font-size: 0.875rem;
}

.acl-entries {
  padding: 1rem 1.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.acl-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
  margin-bottom: 0.5rem;
}

.acl-entry-info {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.acl-principal {
  font-family: monospace;
  font-size: 0.875rem;
}

.acl-permission {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  background: var(--bg-secondary);
}

.acl-permission.read {
  color: var(--success);
}

.acl-permission.write {
  color: var(--warning);
}

.acl-add-entry {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
}

.acl-add-entry h4 {
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}

.acl-add-form {
  display: flex;
  gap: 0.5rem;
}

.acl-add-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

.acl-add-form select {
  padding: 0.5rem 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* Token Display */
.token-created-content {
  padding: 0 1.5rem 1.5rem;
}

.token-created-content .warning {
  color: var(--warning);
  font-weight: 500;
  margin-bottom: 1rem;
}

.token-display {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--bg-tertiary);
  border-radius: var(--radius);
}

.token-display code {
  flex: 1;
  word-break: break-all;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 1rem 1.5rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
}

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

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

.toast.info {
  border-left: 4px solid var(--primary);
}

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

/* Responsive */
@media (max-width: 768px) {
  .header {
    padding: 1rem;
  }

  .nav {
    padding: 0 1rem;
    overflow-x: auto;
  }

  .main-content {
    padding: 1rem;
  }

  .documents-grid {
    grid-template-columns: 1fr;
  }

  .account-info {
    grid-template-columns: 1fr;
  }

  .tab-header {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }
}
