:root {
  --background: #ffffff;
  --foreground: #475569;
  --card: #ffffff;
  --card-foreground: #475569;
  --popover: #f1f5f9;
  --popover-foreground: #374151;
  --primary: #059669;
  --primary-foreground: #ffffff;
  --secondary: #10b981;
  --secondary-foreground: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #475569;
  --accent: #10b981;
  --accent-foreground: #ffffff;
  --destructive: #dc2626;
  --destructive-foreground: #ffffff;
  --border: #e2e8f0;
  --input: #f1f5f9;
  --ring: rgba(5, 150, 105, 0.5);
  --radius: 0.5rem;
  --sidebar: #ffffff;
  --sidebar-foreground: #475569;
  --sidebar-primary: #059669;
  --sidebar-primary-foreground: #ffffff;
  --sidebar-accent: #10b981;
  --sidebar-accent-foreground: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-ring: rgba(5, 150, 105, 0.5);
}

.dark {
  --background: #0f172a;
  --foreground: #e2e8f0;
  --card: #1e293b;
  --card-foreground: #e2e8f0;
  --popover: #1e293b;
  --popover-foreground: #e2e8f0;
  --primary: #10b981;
  --primary-foreground: #ffffff;
  --secondary: #059669;
  --secondary-foreground: #ffffff;
  --muted: #334155;
  --muted-foreground: #94a3b8;
  --accent: #10b981;
  --accent-foreground: #ffffff;
  --destructive: #ef4444;
  --destructive-foreground: #ffffff;
  --border: #334155;
  --input: #1e293b;
  --ring: rgba(16, 185, 129, 0.5);
}

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

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--background);
  color: var(--foreground);
  line-height: 1.6;
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Geist Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 600;
  line-height: 1.2;
}

/* Authentication Styles */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: linear-gradient(135deg, var(--muted) 0%, var(--background) 100%);
}

.auth-card {
  background: var(--card);
  border-radius: calc(var(--radius) * 2);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
}

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

.auth-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.auth-title {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--card-foreground);
  margin-bottom: 0.5rem;
}

.auth-subtitle {
  color: var(--muted-foreground);
  font-size: 0.875rem;
}

.auth-form {
  margin-bottom: 1.5rem;
}

.form-step {
  animation: fadeIn 0.3s ease-in-out;
}

.step-description {
  color: var(--muted-foreground);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.form-label {
  display: block;
  font-weight: 500;
  color: var(--card-foreground);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--foreground);
  font-size: 1rem;
  font-family: "Geist Sans", monospace;
  text-align: center;
  letter-spacing: 0.1em;
  transition: all 0.2s ease-in-out;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-input::placeholder {
  color: var(--muted-foreground);
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

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

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  flex: 1;
}

.btn-primary:hover:not(:disabled) {
  background: #047857;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
}

.btn-secondary:hover:not(:disabled) {
  background: #059669;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
}

.btn-spinner {
  display: none;
}

.btn.loading .btn-text {
  opacity: 0;
}

.btn.loading .btn-spinner {
  display: block;
}

.code-timer {
  margin-top: 1rem;
  text-align: center;
}

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

.auth-alerts {
  min-height: 1.5rem;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  animation: slideIn 0.3s ease-out;
}

.alert-error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--destructive);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

.alert-success {
  background: rgba(5, 150, 105, 0.1);
  color: var(--primary);
  border: 1px solid rgba(5, 150, 105, 0.2);
}

.alert-info {
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

/* Database Explorer Styles */
.database-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.database-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 0;
}

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

.database-title {
  font-size: 1.5rem;
  color: var(--card-foreground);
}

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

.session-info {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.database-main {
  flex: 1;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1rem;
  width: 100%;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
}

.breadcrumb-item {
  color: var(--muted-foreground);
  cursor: pointer;
  transition: color 0.2s ease-in-out;
}

.breadcrumb-item:hover {
  color: var(--primary);
}

.breadcrumb-item.active {
  color: var(--card-foreground);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--muted-foreground);
}

#admin-dashboard {
  margin-bottom: 2rem;
}

.admin-nav {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.nav-tab {
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: 0.875rem;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease-in-out;
}

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

.nav-tab:hover:not(.active) {
  color: var(--card-foreground);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease-in-out;
}

.user-details {
  padding: 1rem;
  background: var(--muted);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}

.admin-section {
  margin-bottom: 2rem;
  padding: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.admin-section h3 {
  font-size: 1.125rem;
  margin-bottom: 1rem;
}

.admin-form .form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.database-content {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.database-list {
  padding: 1.5rem;
}

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

.list-header h2 {
  font-size: 1.25rem;
  color: var(--card-foreground);
  margin: 0;
}

.list-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  background: var(--card);
}

.list-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(5, 150, 105, 0.1);
  transform: translateY(-1px);
}

.item-icon {
  font-size: 1.5rem;
  margin-right: 1rem;
  opacity: 0.7;
}

.item-content {
  flex: 1;
}

.item-name {
  font-weight: 500;
  color: var(--card-foreground);
  margin-bottom: 0.25rem;
}

.item-meta {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.item-arrow {
  font-size: 1.25rem;
  color: var(--muted-foreground);
  margin-left: 1rem;
}

.document-item {
  cursor: default;
}

.document-item:hover {
  transform: none;
}

.item-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: 1rem;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: calc(var(--radius) * 0.75);
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-size: 0.875rem;
}

.btn-icon:hover {
  background: var(--primary);
  color: var(--primary-foreground);
  transform: scale(1.1);
}

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

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

.empty-state p {
  margin-bottom: 1.5rem;
  font-size: 1.125rem;
}

.pagination {
  text-align: center;
  padding: 1.5rem;
  border-top: 1px solid var(--border);
}

/* Modal Styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--card);
  border-radius: calc(var(--radius) * 1.5);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
}

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

.modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--card-foreground);
  margin: 0;
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.2s ease-in-out;
}

.modal-close:hover {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.modal-body {
  padding: 1.5rem;
  max-height: calc(90vh - 120px);
  overflow-y: auto;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--input);
  color: var(--foreground);
  font-family: "Geist Sans", monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  resize: vertical;
  transition: all 0.2s ease-in-out;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.form-help {
  font-size: 0.8125rem;
  color: var(--muted-foreground);
  margin-top: 0.5rem;
}

/* Document Viewer Styles */
.document-viewer {
  max-width: 100%;
}

.document-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.document-header h3 {
  font-size: 1.125rem;
  color: var(--card-foreground);
  margin-bottom: 0.5rem;
}

.document-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8125rem;
  color: var(--muted-foreground);
}

.document-content {
  margin-bottom: 1.5rem;
}

.json-display {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  font-family: "Geist Sans", monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--card-foreground);
}

/* Confirm Dialog Styles */
.confirm-dialog {
  text-align: center;
}

.confirm-message {
  margin-bottom: 1.5rem;
  color: var(--card-foreground);
  line-height: 1.6;
}

.btn-destructive {
  background: var(--destructive);
  color: var(--destructive-foreground);
}

.btn-destructive:hover:not(:disabled) {
  background: #b91c1c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Responsive Design */
@media (max-width: 640px) {
  .auth-card {
    padding: 2rem 1.5rem;
  }

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

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

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .modal-content {
    margin: 0.5rem;
    max-width: calc(100vw - 1rem);
  }

  .modal-header,
  .modal-body {
    padding: 1rem;
  }

  .list-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .item-actions {
    margin-left: 0;
    width: 100%;
    justify-content: center;
  }

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