:root {
  --primary-color: #003DA5;
  --secondary-color: #0066CC;
  --success-color: #28a745;
  --danger-color: #dc3545;
  --light-bg: #f8f9fa;
  --border-color: #dee2e6;
  --text-color: #212529;
  --text-muted: #6c757d;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.15);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--light-bg);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* Header */
.site-header {
  background: white;
  border-bottom: 3px solid var(--primary-color);
  box-shadow: var(--shadow);
  padding: 1.5rem 0;
  margin-bottom: 2rem;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.org-logo {
  height: 64px;
  width: auto;
}

.header-text h1 {
  font-size: 1.75rem;
  color: var(--primary-color);
  margin-bottom: 0.25rem;
}

.org-description {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Query Section */
.query-section {
  background: white;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.query-section h2 {
  margin-bottom: 1.5rem;
  color: var(--primary-color);
}

.query-selector {
  margin-bottom: 1.5rem;
}

.query-selector label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.query-dropdown,
.format-dropdown {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.query-dropdown:focus,
.format-dropdown:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(0, 61, 165, 0.1);
}

.query-details {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
}

.query-info h3 {
  margin-bottom: 0.5rem;
}

.query-description {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.sparql-preview {
  margin: 1rem 0;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.sparql-preview summary {
  padding: 0.75rem 1rem;
  background: var(--light-bg);
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}

.sparql-preview summary:hover {
  background: #e9ecef;
}

.sparql-code {
  padding: 1rem;
  background: #f8f9fa;
  overflow-x: auto;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.export-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--secondary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-export {
  background: var(--secondary-color);
  color: white;
  padding: 0.6rem 1.2rem;
  font-size: 0.9rem;
}

.btn-export:hover:not(:disabled) {
  background: var(--primary-color);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #218838;
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

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

.btn-icon {
  font-size: 1.1rem;
}

/* Results Section */
.results-section {
  background: white;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.results-header h2 {
  color: var(--primary-color);
}

.results-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-count {
  font-weight: 500;
}

/* Table Styles */
.results-table {
  width: 100%;
  border-collapse: collapse;
  overflow-x: auto;
  display: block;
}

.results-table table {
  width: 100%;
  min-width: 600px;
}

.results-table th,
.results-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.results-table th {
  background: var(--light-bg);
  font-weight: 600;
  color: var(--primary-color);
  position: sticky;
  top: 0;
}

.results-table tbody tr:hover {
  background: #f8f9fa;
}

.results-table a {
  color: var(--primary-color);
  text-decoration: none;
}

.results-table a:hover {
  text-decoration: underline;
}

/* JSON/RDF Preview */
.rdf-preview {
  background: #f8f9fa;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
}

.rdf-preview pre {
  margin: 0;
  font-family: "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Error Section */
.error-section {
  background: white;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.error-box {
  border-left: 4px solid var(--danger-color);
  padding: 1rem;
  background: #fff5f5;
}

.error-box h3 {
  color: var(--danger-color);
  margin-bottom: 0.5rem;
}

.error-box details {
  margin-top: 1rem;
}

.error-box summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--text-muted);
}

#error-details {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.85rem;
  overflow-x: auto;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  color: white;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.loading-overlay p {
  margin-top: 1rem;
  font-size: 1.1rem;
}

/* Footer */
.site-footer {
  background: white;
  border-top: 1px solid var(--border-color);
  padding: 2rem 0;
  margin-top: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-footer a {
  color: var(--primary-color);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
}

.footer-links {
  margin-top: 0.5rem;
}

.separator {
  margin: 0 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .download-group {
    width: 100%;
  }
  
  .results-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
