/* Accessible, High-Contrast Light Mode Styling for divelog-editor */
/* Sharp Corners & Dark Navy Slate Drop Shadows Theme */

:root {
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --border-color: #102090;
  --text-color: #111827;
  --text-muted: #4b5563;
  --primary-color: #0052cc;
  --primary-hover: #003d99;
  --success-color: #0f213d;
  --success-hover: #0a172c;
  --focus-ring: #0052cc;
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --shadow-sm: 3px 3px 2px rgba(18, 38, 80, 0.35);
  --shadow-md: 5px 5px 3px rgba(18, 38, 80, 0.45);
  --shadow-lg: 8px 8px 4px rgba(18, 38, 80, 0.55);
}

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

/* Skip Navigation Link for Keyboard & Screen Reader Users */
.skip-link {
  position: absolute;
  top: -100px;
  left: 10px;
  background: var(--primary-color);
  color: #ffffff;
  padding: 10px 16px;
  z-index: 1000;
  text-decoration: none;
  font-weight: 600;
  border-radius: 0;
  box-shadow: var(--shadow-lg);
  transition: top 0.2s ease;
}

.skip-link:focus {
  top: 10px;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.6;
  padding: 20px;
}

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

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

.brand-title {
  display: flex;
  align-items: center;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: var(--text-color);
  border-radius: 0;
  padding: 4px;
  transition: color 0.15s ease;
}

.brand-link:hover h1 {
  color: var(--primary-color);
}

.app-logo {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  display: block;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.15;
  color: var(--text-color);
}

.header-controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.unit-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  /* Accessible minimum touch target size */
  padding: 8px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: 0;
  background-color: var(--card-bg);
  color: var(--text-color);
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.btn:hover {
  background-color: #e2e8f0;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn:active {
  box-shadow: 1px 1px 1px rgba(18, 38, 80, 0.35);
  transform: translateY(0);
}

.btn-primary {
  background-color: var(--primary-color);
  color: #ffffff;
  border-color: var(--primary-color);
}

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

.btn-success {
  background-color: var(--success-color);
  color: #ffffff;
  border-color: var(--success-color);
}

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

/* Prominent Focus Indicators for High Accessibility */
:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus-ring) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 2px #ffffff !important;
}

.app-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-controls {
    width: 100%;
    justify-content: flex-start;
  }
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 0;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-grid-full {
  grid-column: span 2;
}

@media (max-width: 600px) {
  body {
    padding: 12px;
  }

  .header-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .unit-selector {
    width: 100%;
    justify-content: space-between;
  }

  .unit-selector select {
    flex-grow: 1;
  }

  .header-controls .btn,
  .header-controls .file-input-wrapper,
  .header-controls .file-input-wrapper .btn {
    width: 100%;
  }

  .app-logo {
    width: 72px;
    height: 72px;
  }

  .card {
    padding: 16px;
  }

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

  .form-grid-full {
    grid-column: span 1;
  }

  .xml-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .xml-header div {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .xml-header .btn {
    width: 100%;
  }

  .details-content {
    padding: 12px;
  }
}

/* Landscape phones: cap XML preview height to avoid dominating the short viewport */
@media (max-height: 500px) and (orientation: landscape) {
  pre {
    max-height: 300px;
  }
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  /* Prevents grid child overflow on iOS Safari */
}

label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-color);
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  min-height: 44px;
  /* Accessible touch target height */
  padding: 8px 12px;
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0;
  font-family: inherit;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  color: var(--text-color);
  background-color: #ffffff;
  box-shadow: 3px 3px 2px rgba(18, 38, 80, 0.3);
}

select {
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23102090' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px 16px;
  padding-right: 32px;
}

input[type="datetime-local"] {
  -webkit-appearance: none;
  appearance: none;
}

/* Fix iOS Safari datetime-local intrinsic sizing & alignment */
input[type="datetime-local"]::-webkit-date-and-time-value {
  text-align: left;
  min-height: 1.5em;
  margin: 0;
}

textarea {
  min-height: 90px;
}

details {
  margin-top: 18px;
  border: 1px solid var(--border-color);
  border-radius: 0;
  background-color: var(--bg-color);
  box-shadow: 4px 4px 2px rgba(18, 38, 80, 0.35);
}

summary {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}

summary:hover {
  background-color: #e2e8f0;
}

details[open] summary {
  border-bottom: 1px solid var(--border-color);
}

.details-content {
  padding: 18px;
  background-color: var(--card-bg);
}

.xml-preview-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.xml-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 10px;
}

pre {
  background-color: #0f213d;
  color: #f8fafc;
  padding: 18px;
  border-radius: 0;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 650px;
  overflow-y: auto;
  border: 1px solid #1e3a5f;
  box-shadow: var(--shadow-lg);
}

pre:focus-visible {
  outline: 3px solid #60a5fa !important;
}

.xml-element {
  color: #bfdbfe;
  /* Ultra-light ice blue for maximum contrast & accessibility */
  font-weight: 600;
}

.xml-attr {
  color: #cbd5e1;
  /* Light grey for attribute names */
  font-weight: 500;
}

.xml-bracket {
  color: #94a3b8;
  /* Muted grey for brackets < > / */
}

.file-input-wrapper {
  display: inline-block;
}

.file-input-wrapper input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.unit-tag {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.status-msg {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--success-color);
  margin-left: 10px;
  display: none;
}

/* Graceful Notice for Non-JavaScript Browsers */
.noscript-warning {
  background-color: #fff3cd;
  color: #725100;
  border: 1px solid #ffeeba;
  border-radius: 0;
  padding: 16px;
  margin-bottom: 20px;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.5;
  box-shadow: var(--shadow-sm);
}