/*
 * 6th Position — Base CSS Design System
 *
 * Copy the :root block and any component classes you need into a new project.
 * This is the canonical reference — update it here when the design evolves.
 */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  /* Brand green */
  --green:        #3CB55E;
  --green-dark:   #2A8A47;
  --green-light:  #EBF7EF;
  --green-mid:    #C8EDD5;
  --green-border: #A8D9BA;

  /* Neutrals */
  --bg:       #F4F6F5;   /* page background */
  --surface:  #FFFFFF;   /* card / panel */
  --border:   #E0E5E2;
  --text:     #1A1A1A;
  --text-2:   #6B7280;   /* muted / secondary */

  /* Semantic */
  --danger:       #DC2626;
  --danger-light: #FEE2E2;
  --warn:         #D97706;
  --warn-light:   #FEF3C7;

  /* Sizing */
  --radius:    8px;
  --radius-sm: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow:    0 2px 8px rgba(0,0,0,0.10);

  /* Layout */
  --header-h:  52px;
}

/* ── Reset + Base ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ────────────────────────────────────────────────────────────── */
/*
  Standard pattern: white bar with logo, app name, optional nav links.
  Logo is a <img> or <div class="logo-mark"> with the 6P circle logo.
*/
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* On iOS (6p-tools app webview, viewport-fit=cover) the page renders up under the
     status bar / dynamic island — reserve its height with the safe-area inset so the
     header content sits below it and the white bar fills the notch area. */
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) max(20px, env(safe-area-inset-right, 0px)) 0 max(20px, env(safe-area-inset-left, 0px));
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.header-logo {
  height: 32px;
  width: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.header-subtitle {
  font-size: 12px;
  color: var(--text-2);
}

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--green);
  color: #fff;
}
.btn-primary:hover { background: var(--green-dark); }
.btn-primary:disabled { background: var(--green-mid); cursor: not-allowed; }

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); border-color: var(--green); color: var(--text); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #FECACA;
}
.btn-danger:hover { background: #FECACA; }

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

/* ── Cards & Panels ────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-green {
  background: var(--green-light);
  color: var(--green-dark);
}

.badge-warn {
  background: var(--warn-light);
  color: var(--warn);
}

.badge-danger {
  background: var(--danger-light);
  color: var(--danger);
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab-btn {
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--green); border-bottom-color: var(--green); }

/* ── Inputs ────────────────────────────────────────────────────────────── */
input[type=text],
input[type=search],
input[type=email],
input[type=date],
input[type=month],
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--green);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-2);
  opacity: 0.7;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green-border); }

/* ── Mobile ────────────────────────────────────────────────────────────── */
/*
  See iOS rules below. At ≤768px:
  - font-size on inputs must be ≥16px to prevent iOS zoom on focus
  - body height must use 100dvh (not 100vh) if you have a fixed-height layout
  - add padding-bottom: max(Xpx, env(safe-area-inset-bottom)) to scroll containers
    that need to clear the iPhone home indicator
*/
@media (max-width: 768px) {
  input, textarea, select { font-size: 16px; }  /* prevent iOS zoom */
}
