/* ============================================================
   styles.css — Gruhapravesam
   Design system, layout, components, responsive behavior.
   ============================================================ */

@import url('https://cdn.jsdelivr.net/npm/@tabler/icons-webfont@latest/tabler-icons.min.css');

:root {
  --ios-bg:         #FAFAF8;
  --ios-surface:    #FFFFFF;
  --ios-surface2:   #F5F4F0;
  --ios-blue:       #B8860B;
  --ios-green:      #2E9E5B;
  --ios-red:        #E03E30;
  --ios-orange:     #E07820;
  --ios-yellow:     #D4A017;
  --ios-purple:     #8B5CF6;
  --ios-teal:       #0E9EA0;
  --ios-gray:       #8E8E93;
  --ios-gray2:      #AEAEB2;
  --ios-gray3:      #C7C7CC;
  --ios-gray4:      #E0DDD6;
  --ios-gray5:      #F0EDE6;
  --ios-gray6:      #FAFAF8;
  --ios-label:      #1A1A1A;
  --ios-label2:     #3C3C43;
  --ios-label3:     rgba(60,60,50,0.55);
  --ios-label4:     rgba(60,60,50,0.15);
  --ios-separator:  rgba(60,60,50,0.15);
  --ios-kolam:      #C9880A;
  --ios-maroon:     #1A1A1A;
  --ios-gold:       #C9880A;
  --ios-gold-light: #F5E6C0;
  --radius-sm:      8px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-xl:      20px;
  --font:           -apple-system, 'SF Pro Display', 'SF Pro Text', BlinkMacSystemFont, sans-serif;
  --focus-ring:      0 0 0 3px rgba(200,136,10,0.35);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ios-bg:        #000000;
    --ios-surface:   #1C1C1E;
    --ios-surface2:  #2C2C2E;
    --ios-label:     #FFFFFF;
    --ios-label2:    rgba(235,235,245,0.6);
    --ios-label3:    rgba(235,235,245,0.3);
    --ios-separator: rgba(84,84,88,0.65);
    --ios-gray5:     #1C1C1E;
    --ios-gray6:     #000000;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  font-family: var(--font);
  background: var(--ios-bg);
  color: var(--ios-label);
  min-height: 100vh;
  padding-bottom: 24px;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 6px;
}

.gp-navbar {
  background: rgba(242,242,247,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid var(--ios-separator);
  position: sticky; top: 0; z-index: 100;
  padding: 12px 16px 10px 64px;
  display: flex; align-items: flex-end; justify-content: space-between;
}
.gp-navbar-title { font-size: 34px; font-weight: 700; letter-spacing: -0.5px; color: var(--ios-label); line-height: 1; }
.gp-navbar-sub { font-size: 13px; color: var(--ios-label3); margin-top: 2px; }
.gp-navbar-action {
  background: var(--ios-blue); color: #fff; border: none; border-radius: 20px;
  padding: 7px 16px; font-size: 15px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 4px; font-family: var(--font); min-height: 36px;
}

.gp-hamburger-btn {
  position: fixed; top: 14px; left: 14px; z-index: 110;
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(26,26,26,0.85);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: none; display: flex; align-items: center; justify-content: center;
  color: #fff; cursor: pointer; min-height: 0; padding: 0;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.gp-hamburger-btn i { font-size: 20px; }
.gp-hamburger-btn:active { transform: scale(0.92); }

.gp-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 119;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.gp-drawer-overlay.open { opacity: 1; pointer-events: auto; }

.gp-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: 78%; max-width: 300px; z-index: 120;
  background: var(--ios-bg);
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.32,0.72,0,1);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0);
}
.gp-drawer.open { transform: translateX(0); }

.gp-drawer-header {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 16px 16px; border-bottom: 1px solid var(--ios-separator);
}
.gp-drawer-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.gp-drawer-title { flex: 1; font-family: Georgia, serif; font-size: 14px; letter-spacing: 1.5px; color: var(--ios-label); }
.gp-drawer-close {
  width: 32px; height: 32px; border-radius: 50%; border: none; background: var(--ios-gray5);
  display: flex; align-items: center; justify-content: center; cursor: pointer; min-height: 0; padding: 0;
  color: var(--ios-label3);
}
.gp-drawer-close i { font-size: 16px; }

.gp-drawer-items { flex: 1; overflow-y: auto; padding: 8px 0; }
.gp-drawer-item {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 14px 20px; border: none; background: transparent;
  font-family: var(--font); font-size: 15px; font-weight: 500;
  color: var(--ios-label2); cursor: pointer; text-align: left; min-height: 0;
}
.gp-drawer-item i { font-size: 19px; width: 22px; color: var(--ios-label3); }
.gp-drawer-item.active { background: rgba(201,136,10,0.1); color: #C9880A; }
.gp-drawer-item.active i { color: #C9880A; }
.gp-drawer-item:active { background: var(--ios-gray5); }

.gp-section { margin: 16px 16px 0; }
.gp-section-header { font-size: 13px; font-weight: 400; color: var(--ios-label3); text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 8px; padding-left: 4px; }
.gp-section-footer { font-size: 13px; color: var(--ios-label3); padding: 8px 4px 0; line-height: 1.5; }

.gp-list { background: var(--ios-surface); border-radius: var(--radius-lg); overflow: hidden; }
.gp-row {
  display: flex; align-items: center; padding: 12px 16px; gap: 12px;
  border-bottom: 0.5px solid var(--ios-separator); background: var(--ios-surface);
  cursor: pointer; transition: background 0.1s; text-decoration: none; color: var(--ios-label);
  min-height: 48px;
}
.gp-row:last-child { border-bottom: none; }
.gp-row:active { background: var(--ios-gray5); }
.gp-row-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; color: #fff; }
.gp-row-content { flex: 1; min-width: 0; }
.gp-row-title { font-size: 17px; color: var(--ios-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gp-row-sub { font-size: 13px; color: var(--ios-label3); margin-top: 1px; }
.gp-row-right { display: flex; align-items: center; gap: 4px; color: var(--ios-label3); font-size: 15px; }
.gp-chevron { color: var(--ios-gray3); font-size: 14px; }

.gp-card { background: var(--ios-surface); border-radius: var(--radius-lg); padding: 16px; margin: 0 16px; }
.gp-card + .gp-card { margin-top: 10px; }

.gp-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px; }
.gp-stat { background: var(--ios-surface); border-radius: var(--radius-lg); padding: 14px 16px; }
.gp-stat-label { font-size: 12px; color: var(--ios-label3); font-weight: 500; margin-bottom: 4px; }
.gp-stat-value { font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: var(--ios-label); }
.gp-stat-value.blue   { color: var(--ios-blue); }
.gp-stat-value.green  { color: var(--ios-green); }
.gp-stat-value.red    { color: var(--ios-red); }
.gp-stat-value.orange { color: var(--ios-orange); }

.gp-progress { margin-top: 8px; }
.gp-progress-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--ios-label3); margin-bottom: 4px; }
.gp-progress-track { background: var(--ios-gray5); border-radius: 4px; height: 6px; overflow: hidden; }
.gp-progress-fill { height: 100%; border-radius: 4px; transition: width 0.4s; background: var(--ios-blue); }
.gp-progress-fill.green  { background: var(--ios-green); }
.gp-progress-fill.orange { background: var(--ios-orange); }
.gp-progress-fill.red    { background: var(--ios-red); }
.gp-progress-fill.purple { background: var(--ios-purple); }

.gp-tag { display: inline-flex; align-items: center; font-size: 12px; font-weight: 500; padding: 3px 8px; border-radius: 6px; }
.gp-tag.blue   { background: rgba(0,122,255,0.12);  color: var(--ios-blue); }
.gp-tag.green  { background: rgba(52,199,89,0.12);  color: var(--ios-green); }
.gp-tag.red    { background: rgba(255,59,48,0.12);  color: var(--ios-red); }
.gp-tag.orange { background: rgba(255,149,0,0.12);  color: var(--ios-orange); }
.gp-tag.gray   { background: var(--ios-gray5);      color: var(--ios-gray); }
.gp-tag.purple { background: rgba(175,82,222,0.12); color: var(--ios-purple); }

.gp-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; min-height: 48px; border: none; border-radius: var(--radius-md);
  font-family: var(--font); font-size: 17px; font-weight: 600; cursor: pointer; transition: opacity 0.1s;
}
.gp-btn:active { opacity: 0.7; }
.gp-btn.primary { background: var(--ios-blue); color: #fff; }
.gp-btn.danger  { background: var(--ios-red);  color: #fff; }
.gp-btn.ghost   { background: var(--ios-gray5); color: var(--ios-label); }
.gp-btn.green   { background: var(--ios-green); color: #fff; }

.gp-input-group + .gp-input-group .gp-input-row { border-top: 0.5px solid var(--ios-separator); }
.gp-input-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--ios-surface); min-height: 48px; }
.gp-input-label { font-size: 17px; color: var(--ios-label); min-width: 100px; flex-shrink: 0; }
.gp-input { flex: 1; border: none; background: transparent; font-family: var(--font); font-size: 17px; color: var(--ios-label); text-align: right; outline: none; }
.gp-input::placeholder { color: var(--ios-gray3); }
.gp-select { flex: 1; border: none; background: transparent; font-family: var(--font); font-size: 17px; color: var(--ios-blue); text-align: right; outline: none; -webkit-appearance: none; cursor: pointer; min-height: 24px; }
.gp-form-error { color: var(--ios-red); font-size: 13px; padding: 6px 16px 0; }

.gp-sheet-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 500; align-items: flex-end; }
.gp-sheet-overlay.open { display: flex; }
.gp-sheet { background: var(--ios-surface); border-radius: 14px 14px 0 0; width: 100%; max-height: 92vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 20px); }
.gp-sheet-handle { width: 36px; height: 5px; border-radius: 3px; background: var(--ios-gray4); margin: 10px auto 0; }
.gp-sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 8px; }
.gp-sheet-title { font-size: 17px; font-weight: 600; }
.gp-sheet-cancel { background: none; border: none; color: var(--ios-blue); font-family: var(--font); font-size: 17px; cursor: pointer; padding: 8px; }
.gp-sheet-done   { background: none; border: none; color: var(--ios-blue); font-family: var(--font); font-size: 17px; font-weight: 600; cursor: pointer; padding: 8px; }

.gp-search-wrap { position: relative; margin: 8px 16px; }
.gp-search { padding: 9px 12px 9px 36px; background: var(--ios-gray5); border: none; border-radius: var(--radius-sm); font-family: var(--font); font-size: 17px; color: var(--ios-label); width: 100%; outline: none; min-height: 40px; }
.gp-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--ios-gray); font-size: 16px; pointer-events: none; }

.gp-upload { border: 1.5px dashed var(--ios-gray4); border-radius: var(--radius-md); padding: 20px; text-align: center; cursor: pointer; background: var(--ios-gray6); margin: 8px 16px; }
.gp-upload i { font-size: 28px; color: var(--ios-blue); margin-bottom: 6px; display: block; }
.gp-upload-label { font-size: 15px; color: var(--ios-blue); font-weight: 500; }
.gp-upload-sub { font-size: 13px; color: var(--ios-label3); margin-top: 2px; }

.gp-empty { text-align: center; padding: 60px 32px; color: var(--ios-label3); }
.gp-empty i { font-size: 48px; margin-bottom: 12px; display: block; opacity: 0.4; }
.gp-empty-title { font-size: 20px; font-weight: 600; color: var(--ios-label2); margin-bottom: 8px; }
.gp-empty-sub { font-size: 15px; line-height: 1.5; }

.gp-loading { display: flex; align-items: center; justify-content: center; padding: 48px 20px; }
.gp-spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--ios-gray5); border-top-color: var(--ios-blue); animation: gp-spin 0.8s linear infinite; }
@keyframes gp-spin { to { transform: rotate(360deg); } }
.gp-btn.loading { opacity: 0.6; pointer-events: none; position: relative; color: transparent; }
.gp-btn.loading::after {
  content: ''; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff; animation: gp-spin 0.7s linear infinite;
}

.gp-ac-wrap { position: relative; }
.gp-ac-list { position: absolute; top: 100%; left: 0; right: 0; background: var(--ios-surface); border-radius: 0 0 var(--radius-md) var(--radius-md); box-shadow: 0 8px 24px rgba(0,0,0,0.15); z-index: 600; max-height: 200px; overflow-y: auto; }
.gp-ac-item { padding: 12px 16px; border-bottom: 0.5px solid var(--ios-separator); cursor: pointer; display: flex; justify-content: space-between; align-items: center; min-height: 44px; }
.gp-ac-item:last-child { border-bottom: none; }
.gp-ac-item:active { background: var(--ios-gray5); }
.gp-ac-name { font-size: 15px; color: var(--ios-label); }
.gp-ac-sub  { font-size: 12px; color: var(--ios-label3); }

.gp-toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%) translateY(8px);
  padding: 10px 20px; border-radius: 20px; font-size: 14px; font-weight: 500;
  z-index: 9999; opacity: 0; transition: opacity 0.2s, transform 0.2s;
  pointer-events: none; max-width: 85%; text-align: center; background: #1C1C1E; color: #fff;
}
.gp-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.gp-toast.success { background: var(--ios-green); }
.gp-toast.warning { background: var(--ios-orange); }
.gp-toast.warning-strong { background: var(--ios-red); }
.gp-toast.error   { background: var(--ios-red); }

.gp-help-btn {
  position: fixed; top: 14px; right: 16px; z-index: 90;
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(120,120,128,0.16); border: none; color: var(--ios-label2);
  font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.gp-help-body { padding: 4px 20px 20px; }
.gp-help-section { margin-bottom: 20px; }
.gp-help-section h4 { font-size: 15px; font-weight: 600; margin-bottom: 6px; color: var(--ios-label); }
.gp-help-section p { font-size: 14px; line-height: 1.6; color: var(--ios-label2); }

.gp-assistant-btn {
  position: fixed; right: 16px; bottom: 96px; z-index: 90;
  background: var(--ios-blue); color: #fff; border: none; border-radius: 24px;
  padding: 12px 18px; font-family: var(--font); font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,122,255,0.35);
}
.gp-assistant-btn i { font-size: 18px; }
.gp-assistant-body { padding: 8px 16px 12px; max-height: 50vh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.gp-assistant-msg { max-width: 85%; padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.5; }
.gp-assistant-msg.assistant { background: var(--ios-gray5); color: var(--ios-label); align-self: flex-start; border-bottom-left-radius: 4px; }
.gp-assistant-msg.user { background: var(--ios-blue); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.gp-assistant-input-row { display: flex; gap: 8px; padding: 8px 16px 16px; align-items: center; }
.gp-assistant-input { flex: 1; border: 1px solid var(--ios-gray4); border-radius: 22px; padding: 10px 16px; font-family: var(--font); font-size: 15px; color: var(--ios-label); outline: none; background: var(--ios-surface); min-height: 44px; }
.gp-assistant-send { width: 40px; height: 40px; border-radius: 50%; background: var(--ios-blue); border: none; color: #fff; font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.gp-spacer { height: 16px; }
.gp-spacer-sm { height: 8px; }

@media (min-width: 600px) {
  body { max-width: 600px; margin: 0 auto; }
  .gp-stat-grid { gap: 12px; }
}

/* Mandatory field marker — auto-applies to any label preceding a required input/select */
.gp-input-row:has(input[aria-required="true"]) > .gp-input-label::after,
.gp-input-row:has(select[aria-required="true"]) > .gp-input-label::after {
  content: " *";
  color: var(--ios-red);
  font-weight: 700;
}
