/*
  Apple-inspired UI layer for Sistem Irigasi.
  This file is intentionally additive: it does not rename IDs/classes used by existing JavaScript.
*/
:root {
  --apple-bg: #f5f7fb;
  --apple-bg-2: #eef5ff;
  --apple-surface: rgba(255, 255, 255, 0.82);
  --apple-surface-strong: rgba(255, 255, 255, 0.94);
  --apple-line: rgba(15, 23, 42, 0.095);
  --apple-line-strong: rgba(15, 23, 42, 0.14);
  --apple-text: #0f172a;
  --apple-muted: #667085;
  --apple-blue: #0a84ff;
  --apple-cyan: #32d4e8;
  --apple-green: #34c759;
  --apple-orange: #ff9f0a;
  --apple-red: #ff453a;
  --apple-violet: #6e5cff;
  --apple-radius-sm: 12px;
  --apple-radius: 18px;
  --apple-radius-lg: 24px;
  --apple-radius-xl: 32px;
  --apple-shadow-sm: 0 10px 26px rgba(15, 23, 42, 0.06);
  --apple-shadow: 0 22px 54px rgba(15, 23, 42, 0.10);
  --apple-shadow-glow: 0 18px 40px rgba(10, 132, 255, 0.18);
  --apple-font: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Arial, sans-serif;
}

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: geometricPrecision;
}

body,
.v12-body,
.public-report-page {
  font-family: var(--apple-font) !important;
  color: var(--apple-text) !important;
  background:
    radial-gradient(circle at 0% 0%, rgba(10, 132, 255, 0.13), transparent 30%),
    radial-gradient(circle at 100% 10%, rgba(50, 212, 232, 0.16), transparent 28%),
    linear-gradient(180deg, #fbfdff 0%, var(--apple-bg) 42%, #edf4ff 100%) !important;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(120deg, rgba(255,255,255,.55), transparent 28%, rgba(255,255,255,.28) 72%, transparent),
    radial-gradient(circle at 50% -10%, rgba(255,255,255,.9), transparent 35%);
  z-index: -1;
}

a {
  color: var(--apple-blue);
}

h1, h2, h3, h4 {
  letter-spacing: -0.035em;
}

small, .subtitle, .v12-muted, .muted, .title p, .login-brand p, .public-simple-hero p {
  color: var(--apple-muted) !important;
}

.card,
.panel,
.stat-card,
.legend-box,
.v12-card,
.login-container,
.login-brand,
.public-report-card,
.toolbar,
.topbar,
.edit-container,
#map,
.map-container,
.info-panel,
.modal-content,
.tab-content,
.content-card,
.summary-card,
.report-card,
.table-container,
.sidebar,
.v12-sidebar,
.v12-topbar,
.public-report-topbar {
  background: var(--apple-surface) !important;
  border: 1px solid var(--apple-line) !important;
  border-radius: var(--apple-radius-lg) !important;
  box-shadow: var(--apple-shadow-sm) !important;
  backdrop-filter: blur(24px) saturate(1.35);
  -webkit-backdrop-filter: blur(24px) saturate(1.35);
}

.v12-card,
.panel,
.card,
.stat-card,
.public-report-card,
.login-container {
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease, background .22s ease;
}

.v12-card:hover,
.panel:hover,
.card:hover,
.stat-card:hover,
.public-report-card:hover,
.login-container:hover {
  transform: translateY(-2px);
  box-shadow: var(--apple-shadow) !important;
  border-color: rgba(10, 132, 255, 0.18) !important;
}

button,
.btn,
.v12-btn,
input[type="submit"],
.login-container button,
.public-hero-actions a,
.public-report-inline-tools a,
.public-report-inline-tools button {
  font-family: var(--apple-font) !important;
  border-radius: 999px !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em;
  border: 1px solid rgba(255,255,255,.5) !important;
  box-shadow: 0 12px 28px rgba(10, 132, 255, 0.18) !important;
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease, background .18s ease;
}

button:hover,
.btn:hover,
.v12-btn:hover,
input[type="submit"]:hover,
.login-container button:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
}

button:active,
.btn:active,
.v12-btn:active,
input[type="submit"]:active {
  transform: translateY(0) scale(.99);
}

.btn,
.v12-btn.primary,
.login-container button,
button.primary,
.btn-primary {
  background: linear-gradient(135deg, #007aff, #32d4e8) !important;
  color: #fff !important;
}

.btn.secondary,
.v12-btn:not(.primary):not(.success),
button.secondary,
.btn-secondary {
  background: rgba(255,255,255,.72) !important;
  color: var(--apple-text) !important;
  border: 1px solid var(--apple-line) !important;
  box-shadow: var(--apple-shadow-sm) !important;
}

.btn.success,
.v12-btn.success,
button.success {
  background: linear-gradient(135deg, #2ccf6f, #32d4e8) !important;
}

.btn.warning,
button.warning {
  background: linear-gradient(135deg, #ff9f0a, #ffd166) !important;
  color: #3b2a00 !important;
}

.btn.danger,
button.danger {
  background: linear-gradient(135deg, #ff453a, #ff7b72) !important;
}

input,
select,
textarea,
.select,
.v12-form input,
.v12-form select,
.v12-form textarea,
.input-wrap,
.field-label + .input-wrap {
  font-family: var(--apple-font) !important;
  border-radius: 16px !important;
  border: 1px solid var(--apple-line) !important;
  background: rgba(255,255,255,.78) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7), 0 8px 20px rgba(15,23,42,.035) !important;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(10,132,255,.55) !important;
  box-shadow: 0 0 0 4px rgba(10,132,255,.12), 0 10px 24px rgba(15,23,42,.045) !important;
  outline: none !important;
}

table,
.v12-table,
.report-table {
  border-collapse: separate !important;
  border-spacing: 0 8px !important;
  width: 100%;
}

th {
  color: var(--apple-muted) !important;
  font-size: 12px !important;
  text-transform: uppercase;
  letter-spacing: .04em;
  border: 0 !important;
  background: transparent !important;
}

td {
  background: rgba(255,255,255,.7) !important;
  border-top: 1px solid var(--apple-line) !important;
  border-bottom: 1px solid var(--apple-line) !important;
}

td:first-child {
  border-left: 1px solid var(--apple-line) !important;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;
}

td:last-child {
  border-right: 1px solid var(--apple-line) !important;
  border-top-right-radius: 14px;
  border-bottom-right-radius: 14px;
}

.badge,
.status,
.pill,
.badge-live,
.public-report-badge,
.v12-badge,
[class*="badge"],
[class*="status"] {
  border-radius: 999px !important;
  font-weight: 800 !important;
  letter-spacing: -0.01em;
}

.v12-shell {
  gap: 18px !important;
  padding: 16px !important;
}

.v12-main {
  padding: 14px 18px 28px !important;
}

.v12-sidebar {
  position: sticky;
  top: 16px;
  height: calc(100vh - 32px);
  padding: 18px !important;
  overflow: auto;
}

.v12-brand {
  gap: 12px !important;
  padding: 10px 10px 18px !important;
  border-bottom: 1px solid var(--apple-line);
  margin-bottom: 10px;
}

.v12-logo,
.brand-badge,
.login-icon {
  background: linear-gradient(145deg, #007aff, #32d4e8) !important;
  color: #fff !important;
  box-shadow: var(--apple-shadow-glow) !important;
  border-radius: 18px !important;
}

.v12-nav {
  gap: 6px !important;
}

.v12-nav a {
  border-radius: 16px !important;
  color: #344054 !important;
  font-weight: 700 !important;
  border: 1px solid transparent;
}

.v12-nav a:hover {
  background: rgba(10,132,255,.08) !important;
  border-color: rgba(10,132,255,.12);
  color: #0b63ce !important;
}

.v12-nav a.active,
.v12-nav a[aria-current="page"] {
  color: #005bd3 !important;
  background: linear-gradient(135deg, rgba(10,132,255,.16), rgba(50,212,232,.13)) !important;
  border: 1px solid rgba(10,132,255,.22) !important;
  box-shadow: 0 10px 22px rgba(10,132,255,.10);
}

.v12-topbar {
  margin-bottom: 18px !important;
}

.v12-title h1 {
  font-size: clamp(26px, 3vw, 42px) !important;
  line-height: 1.05 !important;
}

.v12-grid {
  gap: 16px !important;
}

.v12-card h2 {
  font-size: 18px !important;
}

#dashboardGrid .v12-card strong,
.stat-card strong,
.metric-value,
.kpi-value {
  letter-spacing: -0.055em;
}

.leaflet-container,
#map,
#damageMap,
.map-view,
.map-card {
  border-radius: var(--apple-radius-lg) !important;
  overflow: hidden !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6), var(--apple-shadow-sm) !important;
}

.leaflet-control,
.leaflet-bar a {
  border-radius: 12px !important;
  border: 1px solid var(--apple-line) !important;
  box-shadow: var(--apple-shadow-sm) !important;
}

.leaflet-popup-content-wrapper {
  border-radius: 18px !important;
  box-shadow: var(--apple-shadow) !important;
  border: 1px solid var(--apple-line);
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
}

.login-shell {
  width: min(1080px, 100%);
  gap: 22px !important;
}

.login-brand h1 {
  font-size: clamp(34px, 5vw, 64px) !important;
  line-height: 0.98 !important;
  letter-spacing: -0.065em;
}

.login-container {
  background: rgba(255,255,255,.88) !important;
}

.public-report-shell,
.public-wizard-shell,
.edit-container,
.wrap,
.shell {
  width: min(1500px, calc(100% - 28px));
  margin-inline: auto;
}

.apple-system-menu {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  font-family: var(--apple-font);
}

.apple-system-menu__button {
  min-width: 168px;
  padding: 12px 16px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255,255,255,.55) !important;
  background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(240,248,255,.78)) !important;
  color: var(--apple-text) !important;
  backdrop-filter: blur(26px) saturate(1.4);
  -webkit-backdrop-filter: blur(26px) saturate(1.4);
  box-shadow: var(--apple-shadow) !important;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
}

.apple-system-menu__panel {
  width: min(360px, calc(100vw - 36px));
  max-height: min(560px, calc(100vh - 110px));
  overflow: auto;
  border-radius: 24px;
  background: rgba(255,255,255,.88);
  border: 1px solid var(--apple-line);
  box-shadow: 0 28px 80px rgba(15,23,42,.18);
  padding: 10px;
  backdrop-filter: blur(30px) saturate(1.45);
  -webkit-backdrop-filter: blur(30px) saturate(1.45);
  transform-origin: bottom right;
  animation: appleMenuIn .16s ease both;
}

.apple-system-menu__panel[hidden] {
  display: none;
}

.apple-system-menu__title {
  padding: 10px 12px 8px;
  color: var(--apple-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.apple-system-menu__link {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  text-decoration: none;
  color: var(--apple-text);
  padding: 10px;
  border-radius: 16px;
  border: 1px solid transparent;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.apple-system-menu__link:hover,
.apple-system-menu__link.is-current {
  background: rgba(10,132,255,.09);
  border-color: rgba(10,132,255,.15);
  transform: translateY(-1px);
}

.apple-system-menu__icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(10,132,255,.16), rgba(50,212,232,.16));
  color: #096ad8;
}

.apple-system-menu__link strong {
  font-size: 14px;
  letter-spacing: -.02em;
}

.apple-system-menu__link small {
  display: block;
  font-size: 11px;
  margin-top: 2px;
  color: var(--apple-muted);
  line-height: 1.25;
}

@keyframes appleMenuIn {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 980px) {
  .v12-shell {
    display: block !important;
  }
  .v12-sidebar {
    position: static;
    height: auto;
    margin-bottom: 14px;
  }
  .v12-nav {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
  .apple-system-menu {
    right: 12px;
    bottom: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}