/* Variables for consistent theming */
:root {
  --primary-color: #0d6efd;
  --primary-hover: #0b5ed7;
  --bg-color: #f4f7f6;
  --panel-bg: #ffffff;
  --text-color: #333;
  --border-color: #dee2e6;
  --shadow: 0 4px 6px rgba(0,0,0,0.05);
}

/* General Body */
body {
  margin: 0;
  font-family: 'Roboto', sans-serif;
  background-color: var(--bg-color);
  background-image: linear-gradient(rgba(244, 247, 246, 0.85), rgba(244, 247, 246, 0.85)), url('../background.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-color);
  line-height: 1.6;
}

/* Header */
header {
  background: var(--primary-color);
  color: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  cursor: pointer;
}

header h2 {
  margin: 0;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* Panels */
.panel {
  background: var(--panel-bg);
  padding: 25px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-width: 700px;
  margin: 30px auto; /* Center panels on page */
  box-sizing: border-box;
}

/* Override for the floating map panel to prevent centering */
#measure .panel {
  margin: 0;
  max-width: none;
  width: auto;
  box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

/* Hide elements */
.hidden {
  display: none !important;
}

/* Buttons */
button {
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 5px;
  padding: 12px 20px;
  margin: 8px 0;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
  width: 100%;
}

button:hover {
  background-color: var(--primary-hover);
}

button:active {
  transform: translateY(1px);
}

/* Inputs, selects, textareas */
input, select, textarea {
  width: 100%;
  padding: 12px;
  margin-bottom: 15px;
  border: 1px solid var(--border-color);
  border-radius: 5px;
  box-sizing: border-box;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
}

/* Map container */
#map {
  width: 100%;
  height: 100%;
}

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

td, th {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

th {
  background-color: #f8f9fa;
  font-weight: 600;
  color: #495057;
}

/* Logo image */
.logo {
  max-height: 60px;
  width: auto;
}

/* Invoice header */
.invoice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
  border-bottom: 2px solid var(--primary-color);
  padding-bottom: 15px;
}

/* Admin panel styling */
.admin {
  border-top: 4px solid var(--primary-color);
}

#map.offscreen {
  position: absolute;
  left: -9999px;
  top: 0;
  width: 100%;
  height: 400px;
  opacity: 1;
}

/* Loading Overlay */
#loadingOverlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(255, 255, 255, 0.8);
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner {
  border: 8px solid #f3f3f3;
  border-top: 8px solid var(--primary-color);
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
