/* J-Assist — shared theme. Light by default, dark via [data-theme="dark"] or system preference. */

@import url('https://fonts.googleapis.com/css2?family=Inter:ital,wght@1,100;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

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

/* ============== Tokens ============== */

:root {
  --bg: #e9eaed;
  --bg-deep: #dcdde0;
  --surface: #ffffff;
  --surface-soft: #f4f4f6;
  --surface-elevated: #ffffff;

  --text: #18181b;
  --text-secondary: #5e6168;
  --text-muted: #94979e;

  --border: rgba(0, 0, 0, 0.06);
  --border-strong: rgba(0, 0, 0, 0.12);
  --divider: #ececef;

  --accent: #049ca0;
  --accent-hover: #037c80;
  --accent-soft: #e6f4f5;
  --accent-strong: #24484b;
  --accent-tertiary: #66b8b4;

  --success: #4ca64a;
  --warning: #f4b44c;
  --danger: #d95856;
  --warning-soft: #fbe098;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.05);

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --radius-xl: 32px;
  --radius-pill: 999px;

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-snap: cubic-bezier(0.34, 1.56, 0.64, 1);
  --dur-fast: 140ms;
  --dur-base: 240ms;
  --dur-slow: 420ms;
  --dur-page: 560ms;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0a0c;
    --bg-deep: #050507;
    --surface: #16171a;
    --surface-soft: #1d1e22;
    --surface-elevated: #1f2024;

    --text: #f0f0f2;
    --text-secondary: #a8acb5;
    --text-muted: #6b6e76;

    --border: rgba(255, 255, 255, 0.06);
    --border-strong: rgba(255, 255, 255, 0.14);
    --divider: #232428;

    --accent: #5fc8cb;
    --accent-hover: #7dd6d9;
    --accent-soft: #16383a;
    --accent-strong: #1c3638;
    --accent-tertiary: #3e8684;

    --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.6);
    --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.4);
  }
}

:root[data-theme="dark"] {
  --bg: #0a0a0c;
  --bg-deep: #050507;
  --surface: #16171a;
  --surface-soft: #1d1e22;
  --surface-elevated: #1f2024;

  --text: #f0f0f2;
  --text-secondary: #a8acb5;
  --text-muted: #6b6e76;

  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.14);
  --divider: #232428;

  --accent: #5fc8cb;
  --accent-hover: #7dd6d9;
  --accent-soft: #16383a;
  --accent-strong: #1c3638;
  --accent-tertiary: #3e8684;

  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 12px 32px rgba(0, 0, 0, 0.6);
  --shadow-soft: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* ============== Base ============== */

html,
body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-style: italic;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  font-style: italic;
}

input,
textarea,
select {
  font-family: inherit;
  font-style: italic;
}

/* ============== Layout ============== */

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  margin-right: auto;
  text-decoration: none;
}

.nav-logo:hover { text-decoration: none; color: var(--text); }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.logo-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-mark--lg { width: 64px; height: 64px; }
.logo-mark--sm { width: 26px; height: 26px; }

.nav-link {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: var(--radius-pill);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  text-decoration: none;
  background: var(--surface-soft);
  color: var(--text);
}

.nav-link.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

main {
  flex: 1;
  padding: 36px 32px 64px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  margin-bottom: 28px;
}

.page-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  margin-bottom: 6px;
}

.page-sub {
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 400;
}

/* ============== Cards ============== */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
  padding: 24px 28px;
}

.card-soft {
  background: var(--surface-soft);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-sub {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 400;
  margin-top: 4px;
}

.card-section + .card-section {
  margin-top: 16px;
}

/* ============== Buttons ============== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-style: italic;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  background: transparent;
  color: var(--text);
  white-space: nowrap;
}

.btn:hover {
  text-decoration: none;
}

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

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn-dark {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

.btn-dark:hover {
  opacity: 0.88;
  color: var(--surface);
}

.btn-soft {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--surface-soft);
}

.btn-soft:hover {
  background: var(--bg-deep);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border-strong);
}

.btn-danger:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.btn-lg {
  padding: 13px 26px;
  font-size: 14px;
}

.btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============== Inputs ============== */

.input {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  padding: 10px 16px;
  font-family: inherit;
  font-style: italic;
  font-size: 13px;
  color: var(--text);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.input-search-wrap {
  position: relative;
  max-width: 480px;
}

.input-search-wrap .input {
  padding-left: 40px;
}

.input-search-wrap .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* ============== Badges ============== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-owner {
  background: var(--warning-soft);
  color: #7a5b1f;
}

.badge-admin {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-user {
  background: rgba(76, 166, 74, 0.14);
  color: #2c6f2b;
}

.badge-none {
  background: var(--surface-soft);
  color: var(--text-muted);
}

.badge-jira {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

:root[data-theme="dark"] .badge-owner,
:root:not([data-theme="light"]) .badge-owner {
  background: rgba(244, 180, 76, 0.18);
  color: #f4b44c;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge-owner { background: rgba(244, 180, 76, 0.18); color: #f4b44c; }
  :root:not([data-theme="light"]) .badge-admin { background: var(--accent-soft); color: var(--accent); }
  :root:not([data-theme="light"]) .badge-user { background: rgba(76, 166, 74, 0.18); color: #6cc06a; }
  :root:not([data-theme="light"]) .badge-jira { background: var(--accent-soft); color: var(--accent); }
}

:root[data-theme="dark"] .badge-admin { background: var(--accent-soft); color: var(--accent); }
:root[data-theme="dark"] .badge-user { background: rgba(76, 166, 74, 0.18); color: #6cc06a; }
:root[data-theme="dark"] .badge-jira { background: var(--accent-soft); color: var(--accent); }

/* ============== Avatar ============== */

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-soft);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-sm { width: 28px; height: 28px; font-size: 10px; }
.avatar-lg { width: 56px; height: 56px; font-size: 16px; }

/* ============== Stats row ============== */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.stat-label {
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
}

/* ============== Theme toggle ============== */

.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline-block; }

:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline-block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

/* ============== Status dot ============== */

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  vertical-align: middle;
}

.status-dot.ok { background: var(--success); }
.status-dot.off { background: var(--text-muted); }
.status-dot.warn { background: var(--warning); }

/* ============== Misc ============== */

.grow { flex: 1; }
.hide { display: none !important; }
.muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.divider { height: 1px; background: var(--divider); margin: 20px 0; border: 0; }
.kbd-code {
  display: inline-block;
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
  font-style: normal;
  background: var(--surface-soft);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
}

/* ============== Animations ============== */

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scale-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes pulse-ring {
  0%   { box-shadow: 0 0 0 0 currentColor; opacity: 0.6; }
  70%  { box-shadow: 0 0 0 8px currentColor; opacity: 0; }
  100% { box-shadow: 0 0 0 8px currentColor; opacity: 0; }
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pop {
  0%   { transform: scale(0.7); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* Utility classes */

.animate-in        { animation: fade-up var(--dur-page) var(--ease-out) both; }
.animate-in-scale  { animation: scale-in var(--dur-page) var(--ease-out) both; }
.animate-in-fade   { animation: fade-in var(--dur-page) var(--ease-out) both; }
.animate-slide     { animation: slide-in-right var(--dur-base) var(--ease-out) both; }
.animate-pop       { animation: pop var(--dur-slow) var(--ease-snap) both; }

.stagger-0 { animation-delay: 0ms; }
.stagger-1 { animation-delay: 60ms; }
.stagger-2 { animation-delay: 120ms; }
.stagger-3 { animation-delay: 180ms; }
.stagger-4 { animation-delay: 240ms; }
.stagger-5 { animation-delay: 300ms; }
.stagger-6 { animation-delay: 360ms; }

/* Interactive transitions */

.card,
.stat,
.row {
  transition:
    transform var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out);
}

.card:hover,
.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-strong);
}

.row:hover {
  transform: translateX(2px);
}

.btn,
.btn-icon,
.theme-toggle,
.nav-link,
.signin-btn {
  transition:
    background-color var(--dur-base) var(--ease-out),
    color var(--dur-base) var(--ease-out),
    border-color var(--dur-base) var(--ease-out),
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    opacity var(--dur-base) var(--ease-out);
}

.btn:hover,
.btn-icon:hover,
.theme-toggle:hover,
.signin-btn:hover {
  transform: translateY(-1px);
}

.btn:active,
.btn-icon:active,
.theme-toggle:active,
.signin-btn:active {
  transform: scale(0.96);
  transition-duration: var(--dur-fast);
}

.btn-primary svg,
.signin-btn svg:last-child {
  transition: transform var(--dur-base) var(--ease-out);
}
.btn-primary:hover svg {
  transform: translateX(2px);
}

.input {
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out),
    background-color var(--dur-base) var(--ease-out);
}

/* Status dot pulse for "ok" */
.status-dot {
  position: relative;
  transition: background-color var(--dur-base) var(--ease-out);
}
.status-dot.ok::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  color: var(--success);
  animation: pulse-ring 2.4s var(--ease-out) infinite;
}

/* Avatar in-view */
.avatar { transition: transform var(--dur-base) var(--ease-out); }
.avatar:hover { transform: scale(1.06); }

/* Badge hover */
.badge { transition: transform var(--dur-fast) var(--ease-snap); }
.badge:hover { transform: translateY(-1px); }

/* Theme toggle: icon swap rotation */
.theme-toggle svg { transition: transform var(--dur-base) var(--ease-out); }
.theme-toggle:hover svg { transform: rotate(15deg); }

/* Theme switching crossfade — applied briefly during toggleTheme() */
html.theme-switching,
html.theme-switching *,
html.theme-switching *::before,
html.theme-switching *::after {
  transition:
    background-color var(--dur-slow) var(--ease-in-out),
    color var(--dur-slow) var(--ease-in-out),
    border-color var(--dur-slow) var(--ease-in-out),
    fill var(--dur-slow) var(--ease-in-out),
    stroke var(--dur-slow) var(--ease-in-out),
    box-shadow var(--dur-slow) var(--ease-in-out) !important;
}

/* Skeleton shimmer */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-soft) 0%,
    var(--bg) 50%,
    var(--surface-soft) 100%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius-sm);
  color: transparent;
}

/* Smooth scroll across pages */
html { scroll-behavior: smooth; }

/* Respect users who don't want motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
