/* Launcher de la plataforma Gaudi — UI móvil-first (guies: core/docs/spec/UI-GUIDELINES.md) */
:root {
  --gaudi-primary: #4c6ef5;
  --gaudi-secondary: #748ffc;
  --gaudi-cta: #f97316;
  --gaudi-bg: #0e0e14;
  --gaudi-surface: #1a1a2e;
  --gaudi-card: #2a2a42;
  --gaudi-text: #f5f5fa;
  --gaudi-muted: #9a9ab0;
  --gaudi-border: #33334d;
  --gaudi-danger: #f87171;
  --gaudi-radius: 16px;
  --gaudi-radius-sm: 8px;
  --gaudi-space: 4px;
  --gaudi-touch: 44px;
  --gaudi-font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--gaudi-bg);
  color: var(--gaudi-text);
  font-family: var(--gaudi-font);
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100vh; height: 100dvh; }

/* ── App shell (patró "telèfon" de la plataforma) ───────────────────────── */
.phone {
  max-width: 430px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  background: var(--gaudi-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-left: 1px solid var(--gaudi-border);
  border-right: 1px solid var(--gaudi-border);
}

/* ── Login ──────────────────────────────────────────────────────────────── */
.login {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gaudi-bg);
  padding: 24px;
  z-index: 10;
}
.login[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--gaudi-surface);
  border: 1px solid var(--gaudi-border);
  border-radius: var(--gaudi-radius);
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  text-align: center;
}
.login-card p {
  margin: 0;
  text-align: center;
  color: var(--gaudi-muted);
  font-size: 14px;
}
.login-card input {
  height: var(--gaudi-touch);
  padding: 0 14px;
  font-size: 16px;
  color: var(--gaudi-text);
  background: var(--gaudi-bg);
  border: 1px solid var(--gaudi-border);
  border-radius: 10px;
  width: 100%;
}
.login-card input:focus {
  outline: 2px solid var(--gaudi-primary);
  outline-offset: 1px;
  border-color: transparent;
}
.login-card .row {
  display: flex;
  gap: 10px;
}
.login-card .row button { flex: 1; }
.divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--gaudi-muted);
  font-size: 12px;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--gaudi-border);
}
.error { color: var(--gaudi-danger); font-size: 13px; }

/* ── Botons ─────────────────────────────────────────────────────────────── */
button {
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 150ms ease, background-color 200ms ease;
}
button:active { transform: scale(0.97); }
button:focus-visible { outline: 2px solid var(--gaudi-primary); outline-offset: 2px; }

#btn-google {
  height: var(--gaudi-touch);
  background: var(--gaudi-card);
  color: var(--gaudi-text);
}
#btn-signin {
  height: var(--gaudi-touch);
  background: var(--gaudi-primary);
  color: #fff;
}
#btn-signup {
  height: var(--gaudi-touch);
  background: transparent;
  color: var(--gaudi-secondary);
  border: 1px solid var(--gaudi-border);
}

/* ── Home (grid d'apps) ─────────────────────────────────────────────────── */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow-y: auto;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--gaudi-muted);
}
.statusbar .logout-link {
  background: transparent;
  border: none;
  color: var(--gaudi-muted);
  font-size: 13px;
  font-weight: 500;
  min-height: var(--gaudi-touch);
  padding: 0 8px;
}

.clock {
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  margin: 8px 0 4px;
  color: var(--gaudi-text);
}

.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
  gap: 18px 12px;
  justify-items: center;
}

.app-card {
  background: transparent;
  border: none;
  color: var(--gaudi-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 4px;
  min-height: var(--gaudi-touch);
  width: 100%;
  border-radius: 12px;
  transition: background-color 200ms ease, transform 120ms ease;
}
.app-card:hover { background: var(--gaudi-surface); }

.app-icon {
  width: 60px;
  height: 60px;
  border-radius: var(--gaudi-radius);
  background: var(--gaudi-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  overflow: hidden;
}

.app-icon img, .topbar-icon img { width: 100%; height: 100%; object-fit: cover; }

.app-name {
  font-size: 12px;
  color: var(--gaudi-text);
  text-align: center;
  max-width: 76px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty { color: var(--gaudi-muted); font-size: 13px; grid-column: 1 / -1; text-align: center; padding: 24px 0; }

/* ── App dins del frame ─────────────────────────────────────────────────── */
.app-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.app-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 8px;
  background: var(--gaudi-surface);
  border-bottom: 1px solid var(--gaudi-border);
  flex-shrink: 0;
}

.app-topbar .back {
  background: transparent;
  border: none;
  color: var(--gaudi-secondary);
  cursor: pointer;
  min-width: var(--gaudi-touch);
  min-height: var(--gaudi-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.app-topbar .back:hover { background: var(--gaudi-card); }

.app-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.topbar-icon { width: 28px; height: 28px; border-radius: 8px; font-size: 15px; flex-shrink: 0; }

.app-topbar .external {
  color: var(--gaudi-muted);
  background: transparent;
  border: none;
  min-width: var(--gaudi-touch);
  min-height: var(--gaudi-touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
}
.app-topbar .external:hover { background: var(--gaudi-card); color: var(--gaudi-text); }

.app-frame {
  flex: 1;
  border: none;
  background: #fff;
  width: 100%;
  min-height: 0;
}

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