/* CSS Custom Properties (Variables) */
:root {
  --bg: #1e1e1f;              /* Main background - dark gray */
  --sidebar-bg: #2a2a2e;      /* Sidebar background - slightly lighter gray */
  --text: #eee;               /* Primary text color - light gray */
  --border: #444;             /* Border color - medium gray */
  --button: #3a3a3f;          /* Button background - dark gray */
  --button-hover: #4a4a4f;    /* Button hover state - lighter gray */
  --brand: #1D5952;           /* Brand/accent color - teal green */
}

/* Base Styles */
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar Component */
.sidebar {
  width: 200px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: width 0.3s ease;
  position: relative;
}

.sidebar.collapsed {
  width: 60px;
}

.brand {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  order: 0;
}

.brand img {
  width: 24px;
  height: 24px;
  filter: invert(1);
}

.brand span {
  font-size: 16px;
  font-weight: bold;
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .brand span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-nav {
  padding: 20px 0;
  order: 1;
}

.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-nav li {
  margin: 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* Active nav item */
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--brand);
  padding-left: 17px; /* 20px - 3px to keep alignment */
  font-weight: 600;
}

.sidebar-nav img {
  width: 20px;
  height: 20px;
  filter: invert(1);
}

.sidebar-nav span {
  transition: opacity 0.3s ease;
}

.sidebar.collapsed .sidebar-nav span {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

/* User Section */
.sidebar-user {
  padding: 15px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  order: 5;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.user-avatar img {
  width: 18px;
  height: 18px;
  filter: invert(1);
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: #aaa;
  text-transform: capitalize;
}

.btn-logout {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.btn-logout:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-logout img {
  width: 16px;
  height: 16px;
  filter: invert(1);
}

/* Collapsed sidebar user section */
.sidebar.collapsed .sidebar-user {
  padding: 15px 10px;
  justify-content: center;
}

.sidebar.collapsed .user-info {
  display: none;
}

.sidebar.collapsed .btn-logout {
  width: 40px;
  height: 40px;
}


.collapse-btn {
  position: absolute;
  bottom: 20px;
  right: -15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--button);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 1000;
  order: 4;
}

.collapse-btn:hover {
  background: var(--button-hover);
}

.collapse-arrow {
  width: 16px;
  height: 16px;
  filter: invert(1);
  transition: transform 0.3s ease;
}

.sidebar.collapsed .collapse-arrow {
  transform: rotate(180deg);
}

/* Main Content Area */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar Component - Only for slideshow controls */
.topbar {
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  padding: 15px 20px;
  display: flex;
  align-items: center;
  gap: 15px;
}

/* Map Container */
#map {
  flex: 1;
  background: var(--bg);
}

/* Sidebar Control Section */
.sidebar-control {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
  order: 2;
}

.sidebar-control .control-group {
  margin-bottom: 20px;
}

.sidebar-control label {
  display: block;
  margin-bottom: 8px;
  font-weight: bold;
  color: var(--text);
  font-size: 13px;
}

.sidebar-control select,
.sidebar-control input[type="text"],
.sidebar-control input[type="color"] {
  width: 100%;
  padding: 6px 10px;
  margin-bottom: 10px;
  margin-right: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  box-sizing: border-box;
}

.sidebar-control select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 6px center;
  background-repeat: no-repeat;
  background-size: 14px;
  padding-right: 28px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  /* Safari-specific fixes */
  -webkit-border-radius: 6px;
  -webkit-box-shadow: none;
  /* Ensure consistent height across browsers */
  height: 32px;
  line-height: 20px;
  /* Fix Safari text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.sidebar-control button {
  width: 100%;
  padding: 6px 12px;
  background: var(--button);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s;
  margin-right: 0;
  margin-bottom: 7px; /* 10px * 0.7 */
  box-sizing: border-box;
}

.sidebar-control button:hover {
  background: var(--button-hover);
}

.sidebar-control a {
  background: var(--brand);
  color: white;
  padding: 8px 12px;
  text-decoration: none;
  border-radius: 6px;
  display: inline-block;
  transition: background 0.2s;
  font-size: 13px;
}

.sidebar-control a:hover {
  background: #2a6b63;
}

/* Button Styles */
.btn-primary {
  background: var(--brand);
  color: white;
  border: none;
}

.btn-primary:hover {
  background: #2a6b63;
}

.btn-secondary {
  background: var(--button);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-success {
  background: #22c55e;
  color: white;
  border: none;
}

.btn-success:hover {
  background: #16a34a;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--sidebar-bg);
  margin: 5% auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.3rem;
}

.close {
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.2s;
}

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

.modal-body {
  padding: 25px;
}

.modal-body .form-group {
  margin-bottom: 20px;
}

.modal-body label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text);
}

.modal-body select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
  /* Safari-specific fixes */
  -webkit-border-radius: 8px;
  -webkit-box-shadow: none;
  /* Ensure consistent height across browsers */
  height: 44px;
  line-height: 20px;
  /* Fix Safari text rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.modal-body select:focus {
  outline: none;
  border-color: var(--brand);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 20px 25px;
  border-top: 1px solid var(--border);
}

.modal-footer button {
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.2s;
}

/* Project List */
.project-list {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
}

.project-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s;
}

.project-item:last-child {
  border-bottom: none;
}

.project-item:hover {
  background: var(--button-hover);
}

.project-item.selected {
  background: var(--brand);
  color: white;
}

.project-item .project-name {
  font-weight: 500;
  margin-bottom: 4px;
}

.project-item .project-details {
  font-size: 12px;
  color: #aaa;
}

.project-item.selected .project-details {
  color: rgba(255, 255, 255, 0.8);
}

/* Message Styles */
.message {
  padding: 10px 15px;
  border-radius: 6px;
  margin-top: 10px;
  font-size: 14px;
  display: none;
}

.message.success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.message.error {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.message.warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.message.show {
  display: block;
}

/* Project Info */
#project-info h4 {
  margin: 0 0 10px 0;
  color: var(--text);
  font-size: 1.1rem;
}

#project-details {
  font-size: 13px;
  color: #aaa;
  line-height: 1.4;
}

/* Floating Labels Panel */
.labels-panel {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 218px; /* 280px * 0.78 */
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 9px; /* 12px * 0.78 */
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.15); /* 4px * 0.78 */
  z-index: 1000;
  max-height: 55vh; /* 70vh * 0.78 */
  overflow: hidden;
}

.labels-panel-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 12px 16px; /* 15px * 0.78, 20px * 0.78 */
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  border-radius: 9px 9px 0 0; /* 12px * 0.78 */
}

.labels-panel-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 1.29rem; /* 0.86rem * 1.5 */
  font-weight: 600;
}


.labels-panel-content {
  padding: 16px; /* 20px * 0.78 */
  max-height: calc(55vh - 62px); /* (70vh * 0.78) - (80px * 0.78) */
  overflow-y: auto;
}

/* Labels List */
#labels-list {
  display: flex;
  flex-direction: column;
  gap: 8px; /* 10px * 0.78 */
}

.label-button {
  display: flex;
  align-items: center;
  gap: 8px; /* 10px * 0.78 */
  padding: 9px 12px; /* 12px * 0.78, 16px * 0.78 */
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px; /* 8px * 0.78 */
  font-size: 16px; /* 11px * 1.5 (rounded) */
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

.label-button:hover {
  background: var(--button-hover);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); /* 2px * 0.78, 8px * 0.78 */
}

.label-button.selected {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
  box-shadow: 0 2px 6px rgba(29, 89, 82, 0.3); /* 2px * 0.78, 8px * 0.78 */
}

.label-color {
  width: 12px; /* 16px * 0.78 */
  height: 12px; /* 16px * 0.78 */
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2); /* 2px * 0.78 */
  flex-shrink: 0;
}

.label-button.selected .label-color {
  border-color: rgba(255, 255, 255, 0.5);
}

.label-name {
  flex: 1;
  text-align: left;
}

.label-count {
  background: var(--border);
  color: var(--text);
  font-size: 15px; /* 10px * 1.5 */
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 1.2;
}

.label-button.selected .label-count {
  background: rgba(255, 255, 255, 0.2);
  color: white;
}

/* Control section remains visible when sidebar is collapsed */

/* Class List */
#class-list {
  margin-top: 15px;
}

.class-button {
  display: inline-block;
  padding: 6px 12px;
  margin: 4px 4px 4px 0;
  border-radius: 24px;
  cursor: pointer;
  color: white;
  font-size: 13px;
  border: none;
  transition: all 0.2s;
}

.class-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Safari-specific fixes for select elements */
@supports (-webkit-appearance: none) {
  .sidebar-control select,
  .modal-body select {
    /* Remove Safari's default styling */
    -webkit-appearance: none;
    -webkit-border-radius: inherit;
    -webkit-box-shadow: none;
    /* Fix Safari's default padding - preserve our custom padding */
    -webkit-padding-start: 12px;
    -webkit-padding-end: 28px;
  }
}

/* Additional cross-browser select normalization */
.sidebar-control select,
.modal-body select {
  /* Remove default styling */
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  /* Ensure consistent box model */
  box-sizing: border-box;
  /* Fix text selection */
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  /* Ensure padding is preserved */
  padding-left: 12px !important;
  padding-right: 28px !important;
}

/* Modal select specific padding */
.modal-body select {
  padding-left: 16px !important;
  padding-right: 40px !important;
}

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar {
    width: 60px;
  }
  
  .sidebar.collapsed {
    width: 60px;
  }
  
  .sidebar-control {
    padding: 15px;
  }
  
  .sidebar-control .control-group {
    margin-bottom: 15px;
  }
  
  .labels-panel {
    width: 195px; /* 250px * 0.78 */
    top: 10px;
    right: 10px;
    max-height: 47vh; /* 60vh * 0.78 */
  }
  
  .labels-panel-content {
    padding: 12px; /* 15px * 0.78 */
    max-height: calc(47vh - 55px); /* (60vh * 0.78) - (70px * 0.78) */
  }
  
  .label-button {
    padding: 8px 9px; /* 10px * 0.78, 12px * 0.78 */
    font-size: 15px; /* 10px * 1.5 */
  }
}
