/* ==========================================================================
   Doa Ibu Journal — iOS Native Master Suite v17.03
   Apple Human Interface Guidelines (HIG) Design Architecture
   Dark Graphite Surfaces, Champagne Gold Accents, Inset Grouped Hierarchy,
   Session Radar, and Personal Trading Insight Engine.
   ========================================================================== */

:root {
  --ios-spring: cubic-bezier(0.2, 0.9, 0.3, 1.2);
  --ios-smooth: cubic-bezier(0.32, 0.72, 0, 1);
  --ios-blur: 28px;
  --ios-glass-bg: rgba(18, 19, 22, 0.76);
  --ios-glass-border: rgba(255, 255, 255, 0.12);
  --ios-glass-sheen: inset 0 0.5px 0 0 rgba(255, 255, 255, 0.32), inset 0 -0.5px 0 0 rgba(255, 255, 255, 0.08);
  --ios-gold: #C8A96A;
  --ios-gold-glow: rgba(200, 169, 106, 0.24);
  --ios-card-radius: 24px;
}

body.light {
  --ios-glass-bg: rgba(255, 255, 255, 0.76);
  --ios-glass-border: rgba(0, 0, 0, 0.08);
  --ios-glass-sheen: inset 0 0.5px 0 0 #ffffff, inset 0 -0.5px 0 0 rgba(0, 0, 0, 0.04);
  --ios-gold: #9E7D3B;
  --ios-gold-glow: rgba(158, 125, 59, 0.18);
}

/* --------------------------------------------------------------------------
   1. iOS Large Title & Sticky Frosted Navigation
   -------------------------------------------------------------------------- */
.ios-large-header {
  padding: 16px 4px 8px 4px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ios-large-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ios-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.ios-large-title {
  font-size: clamp(26px, 6vw, 34px);
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1.15;
  color: rgba(255, 255, 255, 0.98);
  margin: 0;
}

body.light .ios-large-title {
  color: #111113;
}

/* Header transition on scroll */
header.ios-scrolled {
  background: var(--ios-glass-bg) !important;
  backdrop-filter: blur(var(--ios-blur)) saturate(180%) !important;
  -webkit-backdrop-filter: blur(var(--ios-blur)) saturate(180%) !important;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.35), var(--ios-glass-sheen) !important;
  border-bottom: 0.5px solid var(--ios-glass-border);
}

/* --------------------------------------------------------------------------
   2. iOS Inset Grouped Cards & Cells
   -------------------------------------------------------------------------- */
.ios-card {
  background: var(--ios-glass-bg);
  backdrop-filter: blur(var(--ios-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--ios-blur)) saturate(160%);
  border: 1px solid var(--ios-glass-border);
  box-shadow: var(--ios-glass-sheen), 0 10px 30px -10px rgba(0, 0, 0, 0.45);
  border-radius: var(--ios-card-radius);
  position: relative;
  overflow: hidden;
  transition: transform 0.24s var(--ios-smooth), box-shadow 0.24s var(--ios-smooth), border-color 0.24s ease;
}

.ios-card:hover {
  border-color: rgba(200, 169, 106, 0.32);
}

.ios-card-header {
  padding: 16px 20px 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.06);
}

body.light .ios-card-header {
  border-bottom-color: rgba(0, 0, 0, 0.05);
}

.ios-card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: rgba(255, 255, 255, 0.92);
  display: flex;
  align-items: center;
  gap: 8px;
}

body.light .ios-card-title {
  color: #1a1a1e;
}

/* --------------------------------------------------------------------------
   3. Market Session Radar & Volatility Widget
   -------------------------------------------------------------------------- */
.ios-session-radar {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015) 50%, rgba(10, 10, 12, 0.6));
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--ios-glass-border);
  box-shadow: var(--ios-glass-sheen), 0 12px 32px -12px rgba(0, 0, 0, 0.5);
  border-radius: 22px;
  padding: 16px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.ios-radar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.ios-radar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ios-radar-pulse {
  position: relative;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #2dd4bf;
  box-shadow: 0 0 10px #2dd4bf;
}

.ios-radar-pulse::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: #2dd4bf;
  opacity: 0.4;
  animation: iosPulse 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes iosPulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  70% { transform: scale(2.4); opacity: 0; }
  100% { transform: scale(2.4); opacity: 0; }
}

.ios-radar-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
}

body.light .ios-radar-title {
  color: #111113;
}

.ios-radar-countdown {
  font-size: 12px;
  font-weight: 600;
  color: var(--ios-gold);
  background: rgba(200, 169, 106, 0.12);
  border: 0.5px solid rgba(200, 169, 106, 0.28);
  padding: 3px 10px;
  border-radius: 999px;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* 4 Trading session timeline track */
.ios-sessions-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.ios-session-pill {
  padding: 8px 6px;
  border-radius: 12px;
  text-align: center;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  transition: all 0.2s var(--ios-smooth);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

body.light .ios-session-pill {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

.ios-session-pill.active {
  background: linear-gradient(135deg, rgba(200, 169, 106, 0.18), rgba(200, 169, 106, 0.06));
  border-color: rgba(200, 169, 106, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 4px 12px -2px rgba(200, 169, 106, 0.25);
}

.ios-session-name {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
}

.ios-session-pill.active .ios-session-name {
  color: #f6e3b4;
}

body.light .ios-session-pill.active .ios-session-name {
  color: #7e5f17;
}

.ios-session-time {
  font-size: 9.5px;
  color: rgba(255, 255, 255, 0.45);
  font-variant-numeric: tabular-nums lining-nums;
}

body.light .ios-session-time {
  color: rgba(0, 0, 0, 0.45);
}

/* --------------------------------------------------------------------------
   4. Personal Trading Insight Card
   -------------------------------------------------------------------------- */
.ios-insight-card {
  padding: 20px 22px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ios-insight-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.ios-insight-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ios-insight-icon {
  font-size: 20px;
  line-height: 1;
}

.ios-insight-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: rgba(255, 255, 255, 0.96);
  margin: 0;
}

body.light .ios-insight-title {
  color: #111113;
}

.ios-insight-subtitle {
  font-size: 12px;
  color: rgba(235, 235, 245, 0.6);
  margin: 2px 0 0 0;
}

body.light .ios-insight-subtitle {
  color: rgba(0, 0, 0, 0.55);
}

.ios-insight-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 11px;
  border-radius: 999px;
  background: rgba(200, 169, 106, 0.12);
  border: 1px solid rgba(200, 169, 106, 0.28);
  color: var(--ios-gold);
  font-variant-numeric: tabular-nums lining-nums;
}

.ios-insight-badge.empty {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.6);
}

/* iOS Segmented Tabs */
.ios-insight-tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid rgba(255, 255, 255, 0.07);
  padding: 3px;
  border-radius: 14px;
  gap: 4px;
}

body.light .ios-insight-tabs {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.06);
}

.ios-insight-tab {
  flex: 1;
  padding: 7px 12px;
  border-radius: 11px;
  font-size: 12.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.65);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ios-smooth);
  user-select: none;
  text-align: center;
  touch-action: manipulation;
}

body.light .ios-insight-tab {
  color: rgba(0, 0, 0, 0.6);
}

.ios-insight-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.35);
}

body.light .ios-insight-tab.active {
  background: #ffffff;
  color: #111113;
  box-shadow: 0 2px 8px -2px rgba(0, 0, 0, 0.15);
}

/* Insight 4-Grid */
.ios-insight-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 768px) {
  .ios-insight-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.ios-insight-tile {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s ease, border-color 0.2s ease;
}

body.light .ios-insight-tile {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.05);
}

.ios-insight-tile:hover {
  border-color: rgba(200, 169, 106, 0.25);
}

.ios-tile-label {
  font-size: 11.5px;
  font-weight: 600;
  color: rgba(235, 235, 245, 0.6);
}

body.light .ios-tile-label {
  color: rgba(0, 0, 0, 0.55);
}

.ios-tile-val {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: rgba(255, 255, 255, 0.95);
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

body.light .ios-tile-val {
  color: #111113;
}

.ios-tile-sub {
  font-size: 11px;
  color: var(--ios-gold);
  font-variant-numeric: tabular-nums lining-nums;
}

.ios-insight-footer-note {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(200, 169, 106, 0.08);
  border: 1px solid rgba(200, 169, 106, 0.18);
  font-size: 12px;
  line-height: 1.4;
  color: #e4c785;
}

body.light .ios-insight-footer-note {
  color: #7e5f17;
  background: rgba(158, 125, 59, 0.08);
  border-color: rgba(158, 125, 59, 0.2);
}

/* Insight List View (Sessions & Days) */
.ios-insight-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ios-insight-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  gap: 12px;
}

body.light .ios-insight-row {
  background: rgba(0, 0, 0, 0.025);
  border-color: rgba(0, 0, 0, 0.05);
}

.ios-row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 110px;
}

.ios-row-name {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.95);
  display: flex;
  align-items: center;
  gap: 6px;
}

body.light .ios-row-name {
  color: #111113;
}

.ios-pill-best {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(45, 212, 191, 0.16);
  color: #2dd4bf;
  border: 0.5px solid rgba(45, 212, 191, 0.35);
}

.ios-row-meta {
  font-size: 11px;
  color: rgba(235, 235, 245, 0.55);
  font-variant-numeric: tabular-nums lining-nums;
}

body.light .ios-row-meta {
  color: rgba(0, 0, 0, 0.5);
}

.ios-row-bar-wrap {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

body.light .ios-row-bar-wrap {
  background: rgba(0, 0, 0, 0.08);
}

.ios-row-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--ios-gold), #2dd4bf);
  transition: width 0.4s var(--ios-smooth);
}

.ios-row-right {
  font-size: 13px;
  font-weight: 700;
  min-width: 75px;
  text-align: right;
  font-variant-numeric: tabular-nums lining-nums;
}

.ios-row-right.pos { color: #2dd4bf; }
.ios-row-right.neg { color: #ff7a68; }

/* Insight Empty Body */
.ios-insight-empty-body {
  padding: 14px 4px 6px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ios-insight-empty-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgba(235, 235, 245, 0.65);
  margin: 0;
}

body.light .ios-insight-empty-text {
  color: rgba(0, 0, 0, 0.6);
}

.ios-insight-empty-btn {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: linear-gradient(135deg, #e6c565, #c8a96a);
  color: #17120a;
  font-size: 13px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 14px -3px rgba(200, 169, 106, 0.45);
  transition: transform 0.18s var(--ios-spring), filter 0.18s ease;
  touch-action: manipulation;
}

.ios-insight-empty-btn:active {
  transform: scale(0.96);
}

/* --------------------------------------------------------------------------
   5. High-End Journaling Form Upgrades
   -------------------------------------------------------------------------- */
/* Live R:R Pill */
.ios-rr-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, rgba(200, 169, 106, 0.14), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(200, 169, 106, 0.35);
  border-radius: 14px;
  padding: 8px 14px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  animation: iosPop 0.22s var(--ios-spring);
}

@keyframes iosPop {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.ios-rr-label {
  color: #e4c785;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ios-rr-val {
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 700;
  color: #ffffff;
}

body.light .ios-rr-val {
  color: #111113;
}

/* Fast Setup Tags Quick-Picker */
.ios-quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.ios-tag-pill {
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all 0.16s var(--ios-smooth);
  user-select: none;
  touch-action: manipulation;
}

body.light .ios-tag-pill {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: rgba(0, 0, 0, 0.75);
}

.ios-tag-pill:active {
  transform: scale(0.93);
}

.ios-tag-pill.selected {
  background: linear-gradient(135deg, rgba(200, 169, 106, 0.24), rgba(200, 169, 106, 0.12));
  border-color: rgba(200, 169, 106, 0.6);
  color: #f6e3b4;
  box-shadow: 0 2px 8px -2px rgba(200, 169, 106, 0.3);
}

body.light .ios-tag-pill.selected {
  color: #7e5f17;
}

/* Clipboard Paste Droptarget */
.ios-paste-banner {
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(200, 169, 106, 0.08));
  border: 1px dashed rgba(45, 212, 191, 0.4);
  border-radius: 14px;
  padding: 10px 14px;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: #a7f3d0;
  transition: all 0.2s ease;
}

.ios-paste-banner.drag-over {
  border-color: #2dd4bf;
  background: rgba(45, 212, 191, 0.2);
  transform: scale(1.01);
}

/* Double-submission Spinner */
#btn-save.is-submitting {
  opacity: 0.75;
  pointer-events: none;
  position: relative;
  cursor: not-allowed;
}

#btn-save.is-submitting::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-left: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: iosSpin 0.7s linear infinite;
  vertical-align: middle;
}

@keyframes iosSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   6. Tactile Touch & Haptic Press States
   -------------------------------------------------------------------------- */
.ios-tap-spring {
  transition: transform 0.18s var(--ios-spring), box-shadow 0.18s ease;
}

.ios-tap-spring:active {
  transform: scale(0.955);
}

/* Tabular Numerals Enforcement */
.tnum, [data-money], .v5-t-pl, .de-fig, .ed-fig, .hm-pl {
  font-variant-numeric: tabular-nums lining-nums !important;
  font-feature-settings: "tnum" 1, "lnum" 1 !important;
}

/* Safe Area Insets for Modern iPhone Notches & Dynamic Island */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ios-radar-pulse::after { animation: none !important; }
  .ios-card, .ios-tag-pill, .ios-insight-empty-btn, .ios-session-pill { transition: none !important; }
}
