:root {
  --primary-blue: #007bff;
  --light-blue: #e3f2fd;
  --bg-light: #f8fbff;
  --white: #ffffff;
  --text-dark: #1a1a1a;
  --text-muted: #6c757d;
  --border-light: #e9ecef;
  --radius: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, var(--bg-light) 0%, #f0f8ff 100%);
  color: var(--text-dark);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

.analyze-btn {
  background: var(--primary-blue);
  color: var(--white);
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.analyze-btn:hover {
  background: #0056b3;
}

/* Main Container */
.main {
  width: 100%;
  margin: 40px 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 32px;
  max-width: none;
}

/* Image Card - upload area */
.image-area {
  background: var(--white);
  border: 2px dashed var(--border-light);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  transition: all 0.3s ease;
  position: relative;
  cursor: pointer;
}

.image-area:hover {
  border-color: var(--primary-blue);
}

.image-area.dragover {
  border-color: var(--primary-blue);
  background-color: var(--light-blue);
}

.image-placeholder {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 24px;
}

.logo-placeholder {
  max-width: 180px;
  margin-bottom: 16px;
  opacity: 0.7;
}

.upload-text {
  color: var(--text-muted);
  font-size: 18px;
  font-weight: 500;
  margin-top: 12px;
}

.image-toolbar {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.toolbar-btn {
  width: 40px;
  height: 40px;
  border: none;
  background: var(--light-blue);
  border-radius: var(--radius-sm);
  color: var(--primary-blue);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn:hover:not(:disabled) {
  background: var(--primary-blue);
  color: var(--white);
}

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

/* Hide arrow UI */
.image-nav {
  display: none !important;
}

/* Larger side-by-side images */
.image-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(520px, 1fr));
  gap: 24px;
  width: 100%;
  justify-content: center;
  align-items: start;
}
.pane {
  position: relative;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.pane-title {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 8px;
  align-self: flex-start;
}
.pane img,
.pane canvas {
  width: 100%;
  max-width: clamp(520px, 48vw, 880px);
  height: auto;
  border-radius: var(--radius-sm);
  background: #f8f9fb;
}

/* Dropdown Panel */
.dropdown-panel {
  background: var(--white);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  overflow: hidden;
  margin-top: 24px;
}

.panel-header {
  background: var(--light-blue);
  padding: 16px 20px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  color: var(--text-dark);
  transition: background 0.2s ease;
}

.panel-header:hover {
  background: #d1e9fc;
}

.panel-header::after {
  content: '▼';
  transition: transform 0.2s ease;
}

.panel-header.open::after {
  transform: rotate(180deg);
}

.panel-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--white);
  padding: 0 20px;
}

.panel-content.open {
  max-height: 40vh;
  overflow-y: auto;
  padding: 16px 20px;
}

/* Custom Scrollbar for panel */
.panel-content.open::-webkit-scrollbar {
  width: 8px;
}
.panel-content.open::-webkit-scrollbar-track {
  background: var(--light-blue);
  border-radius: var(--radius-sm);
}
.panel-content.open::-webkit-scrollbar-thumb {
  background-color: var(--primary-blue);
  border-radius: var(--radius-sm);
}

.error-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.error-percent {
  color: var(--primary-blue);
  font-weight: 600;
}

.damage-list {
  margin: 6px 0 14px 0;
  padding-left: 18px;
  color: var(--text-dark);
}
.damage-list li {
  margin: 2px 0;
}

/* Make damage rows clickable and highlightable */
.clickable {
  cursor: pointer;
  border-radius: 8px;
  transition: background 0.15s ease;
  padding: 8px 12px;
  margin: 0 -12px; /* Counteract padding to fill width */
}
.clickable:hover {
  background: rgba(0, 123, 255, 0.05);
}
.selected {
  background: var(--light-blue) !important;
  font-weight: 600;
}

/* Sidebar Cards */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.sidebar .analyze-btn {
  width: 100%;
}

.side-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  border: 1px solid var(--border-light);
  transition: all 0.3s ease;
}


.side-card h3 {
  margin: 0 0 8px;
  color: var(--text-dark);
  font-size: 20px;
  font-weight: 600;
}

.side-card .value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-blue);
  margin: 0;
}

.side-card .note {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 12px;
}

/* View toggles: classes applied to .image-area */
.image-area.show-original-only .annotated-pane {
  display: none;
}
.image-area.show-annotated-only .original-pane {
  display: none;
}

/* Responsive */
@media (max-width: 1200px) {
  .image-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 992px) {
  .main {
    display: flex;
    flex-direction: column;
  }

  /*
    By setting display: contents, the <section> and <aside> elements'
    boxes are removed from the layout, and their children are "promoted"
    to be direct flex-items of the .main container. This allows us to
    reorder them freely.
  */
  .main > section,
  .main > aside {
    display: contents;
  }

  /* Set the mobile order of the promoted elements */
  .image-area { order: 1; }
  .analyze-btn { order: 2; }
  .dropdown-panel { order: 3; margin-top: 0; }
  .sidebar .side-card { order: 4; }

  /* Style the reordered elements */
  .analyze-btn {
    margin-top: 0px;
    margin-bottom: 24px;
    align-self: center;
  }

  .sidebar {
    gap: 16px;
    display: flex;
    flex-direction: column;
  }

  .side-card {
    width: 100%;
  }
}

@media (max-width: 768px) {
  .main {
    margin: 24px 0;
    padding: 0 16px;
  }

  .sidebar {
    flex-direction: column;
  }

  .analyze-btn {
    width: 100%;
  }

  .image-area {
    padding: 24px;
    min-height: 300px;
  }
}