/* Copyright (c) Microsoft Corporation.
 Licensed under the MIT License. */

:root {
  --primary-color: #2563eb;
  --secondary-color: #64748b;
  --success-color: #059669;
  --danger-color: #dc2626;
  --warning-color: #d97706;
  --info-color: #0891b2;
  --light-color: #f8fafc;
  --dark-color: #1e293b;
  --border-color: #e2e8f0;
  --sidebar-width: 280px;
  --topnav-height: 64px;
}

* {
  box-sizing: border-box;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--dark-color);
  background-color: var(--light-color);
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* Application Shell Layout */
.app-shell {
  display: grid;
  grid-template-areas:
    "topnav topnav"
    "sidebar main";
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topnav-height) 1fr;
  min-height: 100vh;
}

/* Top Navigation */
.top-navigation {
  grid-area: topnav;
  background: white;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  padding: 0 2rem;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.top-navigation .brand {
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--primary-color);
  margin-right: 2rem;
}

.top-navigation .search-container {
  flex: 1;
  max-width: 500px;
  margin-right: 2rem;
}

.top-navigation .search-input {
  width: 100%;
  padding: 0.5rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: var(--light-color);
  transition: all 0.2s ease;
}

.top-navigation .search-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
  background: white;
}

.top-navigation .controls {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.view-mode-toggle {
  display: flex;
  background: var(--light-color);
  border-radius: 0.5rem;
  padding: 0.25rem;
  border: 1px solid var(--border-color);
}

.view-mode-toggle button {
  padding: 0.5rem 0.75rem;
  border: none;
  background: transparent;
  color: var(--secondary-color);
  border-radius: 0.25rem;
  cursor: pointer;
  font-size: 0.875rem;
  transition: all 0.2s ease;
}

.view-mode-toggle button.active {
  background: white;
  color: var(--primary-color);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.view-mode-toggle button:hover:not(.active) {
  background: rgba(37, 99, 235, 0.1);
  color: var(--primary-color);
}

/* Sidebar */
.sidebar {
  grid-area: sidebar;
  background: white;
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  overflow-y: auto;
  height: calc(100vh - var(--topnav-height));
}

.sidebar h6 {
  font-weight: 600;
  color: var(--dark-color);
  margin-bottom: 1rem;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

/* Filter Section */
.filter-section {
  margin-bottom: 2rem;
}

.filter-group {
  margin-bottom: 1rem;
}

.filter-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--secondary-color);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background: white;
  color: var(--dark-color);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-filters-btn {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background: white;
  color: var(--secondary-color);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.clear-filters-btn:hover {
  background: var(--light-color);
  border-color: var(--secondary-color);
}

/* Main Content Area */
.main-content {
  grid-area: main;
  padding: 2rem;
  overflow-y: auto;
  height: calc(100vh - var(--topnav-height));
  background: var(--light-color);
}

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

.content-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--dark-color);
  margin: 0;
}

.content-subtitle {
  color: var(--secondary-color);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Annotations Grid Layout */
.annotations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Annotation Cards */
.annotation-card {
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 0.75rem;
  padding: 1.5rem;
  transition: all 0.2s ease;
  position: relative;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  cursor: pointer;
}

.annotation-card:hover {
  border-color: var(--primary-color);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
  transform: translateY(-2px);
}

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

.annotation-type {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary-color);
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  text-transform: capitalize;
}

.annotation-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.annotation-date {
  color: var(--secondary-color);
  font-size: 0.75rem;
}

.annotation-controls {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
}

.annotation-controls button {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  background: white;
  color: var(--secondary-color);
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 0.875rem;
}

.annotation-controls button:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
  background: rgba(37, 99, 235, 0.05);
}

.annotation-content {
  margin-top: 1rem;
}

.preview-blockquote {
  margin-bottom: 1rem;
}

.preview-blockquote blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 1rem;
  margin: 0.5rem 0;
  font-style: italic;
  color: var(--secondary-color);
  background: var(--light-color);
  padding: 0.75rem 1rem;
  border-radius: 0 0.375rem 0.375rem 0;
}

.preview-screenshot {
  margin-bottom: 1rem;
}

.preview-screenshot img {
  max-width: 100%;
  height: auto;
  border-radius: 0.375rem;
  border: 1px solid var(--border-color);
  max-height: 200px;
  object-fit: cover;
}

.preview-content {
  color: var(--dark-color);
  line-height: 1.6;
}

.preview-content h1,
.preview-content h2,
.preview-content h3 {
  margin: 0.5rem 0;
  color: var(--dark-color);
}

.preview-content h1 {
  font-size: 1.25rem;
}
.preview-content h2 {
  font-size: 1.125rem;
}
.preview-content h3 {
  font-size: 1rem;
}

.preview-content strong {
  font-weight: 600;
}

.preview-content em {
  font-style: italic;
}

.preview-content code {
  background: var(--light-color);
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: "Courier New", monospace;
  font-size: 0.875em;
}

.preview-content ul {
  margin: 0.5rem 0;
  padding-left: 1.5rem;
}

.preview-content li {
  margin-bottom: 0.25rem;
}

/* Badges */
.badge {
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1;
}

.badge-document {
  background: #dbeafe;
  color: #1e40af;
}

.badge-page {
  background: #f0f9ff;
  color: #0369a1;
}

.badge-type {
  background: #f0fdf4;
  color: #166534;
}

.badge-type.note {
  background: #fef3c7;
  color: #92400e;
}

.badge-type.question {
  background: #fce7f3;
  color: #be185d;
}

.badge-type.highlight {
  background: #fef2f2;
  color: #dc2626;
}

/* Loading & Empty States */
.loading-state,
.empty-state,
.error-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--secondary-color);
}

.loading-state i,
.empty-state i,
.error-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
  display: block;
  color: var(--border-color);
}

.loading-state h6,
.empty-state h6,
.error-state h6 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--dark-color);
}

.loading-state .spinner {
  width: 3rem;
  height: 3rem;
  border: 3px solid var(--border-color);
  border-top: 3px solid var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Responsive Design */
@media (max-width: 1200px) {
  .annotations-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
  }
}

@media (max-width: 992px) {
  .app-shell {
    grid-template-areas:
      "topnav"
      "main";
    grid-template-columns: 1fr;
    grid-template-rows: var(--topnav-height) 1fr;
  }

  .sidebar {
    display: none;
  }

  .main-content {
    padding: 1rem;
  }

  .top-navigation {
    padding: 0 1rem;
  }

  .top-navigation .search-container {
    max-width: 300px;
    margin-right: 1rem;
  }

  .annotations-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

@media (max-width: 768px) {
  .top-navigation .brand {
    display: none;
  }

  .top-navigation .search-container {
    max-width: 200px;
  }

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

  .annotation-card {
    padding: 1rem;
  }

  .annotation-card-header {
    flex-direction: column;
    gap: 1rem;
  }

  .annotation-controls {
    align-self: flex-start;
  }
}

/* Utility Classes */
.text-primary {
  color: var(--primary-color) !important;
}
.text-secondary {
  color: var(--secondary-color) !important;
}
.text-success {
  color: var(--success-color) !important;
}
.text-danger {
  color: var(--danger-color) !important;
}

.d-none {
  display: none !important;
}
.d-block {
  display: block !important;
}
.d-flex {
  display: flex !important;
}

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

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
